checkpoint := get-environment-variable("VINIX_LLVM_BUILD") reuse := if string?(checkpoint) { not(string=?("", checkpoint)) } else { false } build-dir := if reuse { checkpoint } else { "build" } sdk := get-environment-variable("VPAC_MAKEPKG_ROOT") defpkgbuild(llvm17-dev, #:pkgname, "llvm17-dev", #:pkgver, "17.0.6", #:pkgrel, 1, #:pkgdesc, "LLVM headers and configuration utility for Mesa (LLVM 17)", #:arch, [#:x86-64, #:aarch64], #:license, "Apache-2.0 WITH LLVM-exception", #:url, "https://llvm.org/", #:depends, ["llvm17-libs=17.0.6-1"], #: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 reuse { ; Use only the tree whose library is the installed runtime from this feed. run("cmp", string-append(build-dir, "/lib/libLLVM-17.so"), string-append(sdk, "/usr/lib/libLLVM-17.so")) run("test", "-s", string-append(build-dir, "/CMakeCache.txt")) } else { ; 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-headers", "llvm-config") }, #:check, fn() { run("vinix-run", string-append(build-dir, "/bin/llvm-config"), "--version") run("test", "-s", string-append(build-dir, "/include/llvm/Config/llvm-config.h")) }, #:package, fn() { run("env", string-append("DESTDIR=", pkgdir()), "cmake", "--install", build-dir, "--component", "llvm-headers") run("install", "-Dm755", string-append(build-dir, "/bin/llvm-config"), string-append(pkgdir(), "/usr/lib/llvm17/bin/llvm-config")) run("mkdir", "-p", string-append(pkgdir(), "/usr/bin"), string-append(pkgdir(), "/usr/lib/llvm17/lib")) run("ln", "-s", "../lib/llvm17/bin/llvm-config", string-append(pkgdir(), "/usr/bin/llvm-config-17")) for-each(fn(soname) { run("ln", "-s", "../../libLLVM-17.so", string-append(pkgdir(), "/usr/lib/llvm17/lib/", soname)) }, list("libLLVM-17.so", "libLLVM-17.0.6.so", "libLLVM.so")) run("install", "-Dm644", string-append(sdk, "/usr/share/licenses/llvm17-libs/LICENSE.TXT"), string-append(pkgdir(), "/usr/share/licenses/llvm17-dev/LICENSE.TXT")) })