| 1 | checkpoint := get-environment-variable("VINIX_LLVM_BUILD") |
| 2 | reuse := if string?(checkpoint) { not(string=?("", checkpoint)) } else { #f } |
| 3 | build-dir := if reuse { checkpoint } else { "build" } |
| 4 | sdk := get-environment-variable("VPAC_MAKEPKG_ROOT") |
| 5 | |
| 6 | defpkgbuild(llvm17-dev, |
| 7 | #:pkgname, "llvm17-dev", |
| 8 | #:pkgver, "17.0.6", |
| 9 | #:pkgrel, 1, |
| 10 | #:pkgdesc, "LLVM headers and configuration utility for Mesa (LLVM 17)", |
| 11 | #:arch, [#:x86-64, #:aarch64], |
| 12 | #:license, "Apache-2.0 WITH LLVM-exception", |
| 13 | #:url, "https://llvm.org/", |
| 14 | #:depends, ["llvm17-libs=17.0.6-2"], |
| 15 | #:makedepends, ["linux-headers"], |
| 16 | #: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", |
| 17 | "https://raw.githubusercontent.com/alpinelinux/aports/d556464b9015ef9447ce4ecacad98c956d730bb6/main/llvm17/fix-memory-mf_exec-on-aarch64.patch", |
| 18 | "https://raw.githubusercontent.com/alpinelinux/aports/d556464b9015ef9447ce4ecacad98c956d730bb6/main/llvm17/llvm-stack-size.patch", |
| 19 | "rust-feature-tables-17.patch", |
| 20 | "https://raw.githubusercontent.com/alpinelinux/aports/d556464b9015ef9447ce4ecacad98c956d730bb6/main/llvm17/0001-Revert-Pseudo-Probe-Make-.pseudo_probe-GC-able.patch"] }, |
| 21 | #:sha256sums, if reuse { list() } else { ["58a8818c60e6627064f312dbf46c02d9949956558340938b71cf731ad8bc0813", |
| 22 | "0163a3cf492b5d0b91cafc142a6ac4f1333c65bc52e627bbccbf3ad927f8d527", |
| 23 | "3cacabc5c9b540c6240c063f8d9eca64c0f0d955ffec86bafc04d5f9bd986d78", |
| 24 | "8b0d457887e701f264ce4359facaf342f528a36c040cb408be04365127d93e56", |
| 25 | "989c86cf3f551afa8959ae976e26721569a744cfce6a75aba886ca50dfa87225"] }, |
| 26 | #:prepare, fn() { |
| 27 | if reuse { |
| 28 | ; Use only the tree whose library is the installed runtime from this feed. |
| 29 | normalized := string-append(srcdir(), "/llvm-runtime-check") |
| 30 | run("env", string-append("DESTDIR=", normalized), "cmake", "--install", build-dir, "--component", "LLVM", "--prefix", "/usr") |
| 31 | run("cmp", string-append(normalized, "/usr/lib/libLLVM-17.so"), |
| 32 | string-append(sdk, "/usr/lib/libLLVM-17.so")) |
| 33 | run("rm", "-r", "--", normalized) |
| 34 | run("test", "-s", string-append(build-dir, "/CMakeCache.txt")) |
| 35 | } else { |
| 36 | ; LLVM's release archive also contains Clang, LLDB and other independent projects. |
| 37 | 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") |
| 38 | for-each(fn(patch) { run("patch", "--batch", "--fuzz=0", "-d", "llvm-project-17.0.6.src", "-p1", "-i", string-append("../", patch)) }, |
| 39 | list("fix-memory-mf_exec-on-aarch64.patch", "llvm-stack-size.patch", "rust-feature-tables-17.patch", |
| 40 | "0001-Revert-Pseudo-Probe-Make-.pseudo_probe-GC-able.patch")) |
| 41 | } |
| 42 | }, |
| 43 | #:build, fn() { |
| 44 | if not(reuse) { |
| 45 | run("vinix-llvm", "17.0.6", "llvm-project-17.0.6.src/llvm", build-dir) |
| 46 | } |
| 47 | run("vinix-ninja", build-dir, "llvm-headers", "llvm-config") |
| 48 | }, |
| 49 | #:check, fn() { |
| 50 | run("vinix-run", string-append(build-dir, "/bin/llvm-config"), "--version") |
| 51 | run("test", "-s", string-append(build-dir, "/include/llvm/Config/llvm-config.h")) |
| 52 | }, |
| 53 | #:package, fn() { |
| 54 | run("env", string-append("DESTDIR=", pkgdir()), "cmake", "--install", build-dir, "--component", "llvm-headers") |
| 55 | run("env", string-append("DESTDIR=", pkgdir()), "cmake", "--install", build-dir, "--component", "llvm-config", "--prefix", "/usr/lib/llvm17") |
| 56 | run("mkdir", "-p", string-append(pkgdir(), "/usr/bin"), string-append(pkgdir(), "/usr/lib/llvm17/lib")) |
| 57 | run("ln", "-s", "../lib/llvm17/bin/llvm-config", string-append(pkgdir(), "/usr/bin/llvm-config-17")) |
| 58 | for-each(fn(soname) { |
| 59 | run("ln", "-s", "../../libLLVM-17.so", string-append(pkgdir(), "/usr/lib/llvm17/lib/", soname)) |
| 60 | }, list("libLLVM-17.so", "libLLVM-17.0.6.so", "libLLVM.so")) |
| 61 | run("install", "-Dm644", string-append(sdk, "/usr/share/licenses/llvm17-libs/LICENSE.TXT"), |
| 62 | string-append(pkgdir(), "/usr/share/licenses/llvm17-dev/LICENSE.TXT")) |
| 63 | }) |
| 64 | |