| 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(llvm19-dev, |
| 7 | #:pkgname, "llvm19-dev", |
| 8 | #:pkgver, "19.1.4", |
| 9 | #:pkgrel, 1, |
| 10 | #:pkgdesc, "LLVM headers and configuration utility for Mesa (LLVM 19)", |
| 11 | #:arch, [#:x86-64, #:aarch64], |
| 12 | #:license, "Apache-2.0 WITH LLVM-exception", |
| 13 | #:url, "https://llvm.org/", |
| 14 | #:depends, ["llvm19-libs=19.1.4-1"], |
| 15 | #:makedepends, ["linux-headers"], |
| 16 | #:source, if reuse { list() } else { ["llvm-project-19.1.4.src.xz::https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.4/llvm-project-19.1.4.src.tar.xz", |
| 17 | "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/llvm19/fix-memory-mf_exec-on-aarch64.patch", |
| 18 | "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/llvm19/llvm-stack-size.patch"] }, |
| 19 | #:sha256sums, if reuse { list() } else { ["3aa2d2d2c7553164ad5c6f3b932b31816e422635e18620c9349a7da95b98d811", |
| 20 | "0163a3cf492b5d0b91cafc142a6ac4f1333c65bc52e627bbccbf3ad927f8d527", |
| 21 | "3cacabc5c9b540c6240c063f8d9eca64c0f0d955ffec86bafc04d5f9bd986d78"] }, |
| 22 | #:prepare, fn() { |
| 23 | if reuse { |
| 24 | ; Use only the tree whose library is the installed runtime from this feed. |
| 25 | run("cmp", string-append(build-dir, "/lib/libLLVM.so.19.1"), |
| 26 | string-append(sdk, "/usr/lib/libLLVM.so.19.1")) |
| 27 | run("test", "-s", string-append(build-dir, "/CMakeCache.txt")) |
| 28 | } else { |
| 29 | ; LLVM's release archive also contains Clang, LLDB and other independent projects. |
| 30 | run("tar", "-xf", "llvm-project-19.1.4.src.xz", "llvm-project-19.1.4.src/llvm", "llvm-project-19.1.4.src/cmake", "llvm-project-19.1.4.src/third-party") |
| 31 | for-each(fn(patch) { run("patch", "--batch", "--fuzz=0", "-d", "llvm-project-19.1.4.src", "-p1", "-i", string-append("../", patch)) }, |
| 32 | list("fix-memory-mf_exec-on-aarch64.patch", "llvm-stack-size.patch")) |
| 33 | } |
| 34 | }, |
| 35 | #:build, fn() { |
| 36 | if not(reuse) { |
| 37 | run("vinix-llvm", "19.1.4", "llvm-project-19.1.4.src/llvm", build-dir) |
| 38 | } |
| 39 | run("vinix-ninja", build-dir, "llvm-headers", "llvm-config") |
| 40 | }, |
| 41 | #:check, fn() { |
| 42 | run("vinix-run", string-append(build-dir, "/bin/llvm-config"), "--version") |
| 43 | run("test", "-s", string-append(build-dir, "/include/llvm/Config/llvm-config.h")) |
| 44 | }, |
| 45 | #:package, fn() { |
| 46 | run("env", string-append("DESTDIR=", pkgdir()), "cmake", "--install", build-dir, "--component", "llvm-headers") |
| 47 | run("install", "-Dm755", string-append(build-dir, "/bin/llvm-config"), |
| 48 | string-append(pkgdir(), "/usr/lib/llvm19/bin/llvm-config")) |
| 49 | run("mkdir", "-p", string-append(pkgdir(), "/usr/bin"), string-append(pkgdir(), "/usr/lib/llvm19/lib")) |
| 50 | run("ln", "-s", "../lib/llvm19/bin/llvm-config", string-append(pkgdir(), "/usr/bin/llvm-config-19")) |
| 51 | for-each(fn(soname) { |
| 52 | run("ln", "-s", "../../libLLVM.so.19.1", string-append(pkgdir(), "/usr/lib/llvm19/lib/", soname)) |
| 53 | }, list("libLLVM.so.19.1", "libLLVM-19.so", "libLLVM.so")) |
| 54 | run("install", "-Dm644", string-append(sdk, "/usr/share/licenses/llvm19-libs/LICENSE.TXT"), |
| 55 | string-append(pkgdir(), "/usr/share/licenses/llvm19-dev/LICENSE.TXT")) |
| 56 | }) |
| 57 | |