checkpoint := get-environment-variable("VINIX_LLVM_BUILD") reuse := if string?(checkpoint) { not(string=?("", checkpoint)) } else { #f } build-dir := if reuse { checkpoint } else { "build" } defpkgbuild(llvm17-libs, #:pkgname, "llvm17-libs", #:pkgver, "17.0.6", #:pkgrel, 2, #:pkgdesc, "LLVM runtime for the native CPU and AMDGPU (LLVM 17)", #:arch, [#:x86-64, #:aarch64], #:license, "Apache-2.0 WITH LLVM-exception", #:url, "https://llvm.org/", #:depends, ["musl", "gcc-libs", "libffi", "libxml2", "zlib", "zstd"], #:makedepends, ["linux-headers"], #:source, if reuse { list() } else { ["llvm-project-17.0.6.src.xz::https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.6/llvm-project-17.0.6.src.tar.xz", "https://raw.githubusercontent.com/alpinelinux/aports/d556464b9015ef9447ce4ecacad98c956d730bb6/main/llvm17/fix-memory-mf_exec-on-aarch64.patch", "https://raw.githubusercontent.com/alpinelinux/aports/d556464b9015ef9447ce4ecacad98c956d730bb6/main/llvm17/llvm-stack-size.patch", "rust-feature-tables-17.patch", "https://raw.githubusercontent.com/alpinelinux/aports/d556464b9015ef9447ce4ecacad98c956d730bb6/main/llvm17/0001-Revert-Pseudo-Probe-Make-.pseudo_probe-GC-able.patch"] }, #:sha256sums, if reuse { list() } else { ["58a8818c60e6627064f312dbf46c02d9949956558340938b71cf731ad8bc0813", "0163a3cf492b5d0b91cafc142a6ac4f1333c65bc52e627bbccbf3ad927f8d527", "3cacabc5c9b540c6240c063f8d9eca64c0f0d955ffec86bafc04d5f9bd986d78", "8b0d457887e701f264ce4359facaf342f528a36c040cb408be04365127d93e56", "989c86cf3f551afa8959ae976e26721569a744cfce6a75aba886ca50dfa87225"] }, #:prepare, fn() { if not(reuse) { ; LLVM's release archive also contains Clang, LLDB and other independent projects. run("tar", "-xf", "llvm-project-17.0.6.src.xz", "llvm-project-17.0.6.src/llvm", "llvm-project-17.0.6.src/cmake", "llvm-project-17.0.6.src/third-party") for-each(fn(patch) { run("patch", "--batch", "--fuzz=0", "-d", "llvm-project-17.0.6.src", "-p1", "-i", string-append("../", patch)) }, list("fix-memory-mf_exec-on-aarch64.patch", "llvm-stack-size.patch", "rust-feature-tables-17.patch", "0001-Revert-Pseudo-Probe-Make-.pseudo_probe-GC-able.patch")) } }, #:build, fn() { if not(reuse) { run("vinix-llvm", "17.0.6", "llvm-project-17.0.6.src/llvm", build-dir) run("vinix-ninja", build-dir, "LLVM") } }, #:check, fn() { run("test", "-s", string-append(build-dir, "/lib/libLLVM-17.so")) }, #:package, fn() { ; CMake replaces the build-tree RUNPATH while installing the runtime. run("env", string-append("DESTDIR=", pkgdir()), "cmake", "--install", build-dir, "--component", "LLVM", "--prefix", "/usr") run("rm", "-f", "--", string-append(pkgdir(), "/usr/lib/libLLVM.so")) run("readelf", "-d", string-append(pkgdir(), "/usr/lib/libLLVM-17.so")) license := string-append(build-dir, "/../llvm-project-17.0.6.src/llvm/LICENSE.TXT") run("install", "-Dm644", license, string-append(pkgdir(), "/usr/share/licenses/llvm17-libs/LICENSE.TXT")) })