| 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 | |
| 5 | defpkgbuild(llvm19-libs, |
| 6 | #:pkgname, "llvm19-libs", |
| 7 | #:pkgver, "19.1.4", |
| 8 | #:pkgrel, 2, |
| 9 | #:pkgdesc, "LLVM runtime for the native CPU and AMDGPU (LLVM 19)", |
| 10 | #:arch, [#:x86-64, #:aarch64], |
| 11 | #:license, "Apache-2.0 WITH LLVM-exception", |
| 12 | #:url, "https://llvm.org/", |
| 13 | #:depends, ["musl", "gcc-libs", "libffi", "libxml2", "zlib", "zstd"], |
| 14 | #:makedepends, ["linux-headers"], |
| 15 | #: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", |
| 16 | "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/llvm19/fix-memory-mf_exec-on-aarch64.patch", |
| 17 | "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/llvm19/llvm-stack-size.patch"] }, |
| 18 | #:sha256sums, if reuse { list() } else { ["3aa2d2d2c7553164ad5c6f3b932b31816e422635e18620c9349a7da95b98d811", |
| 19 | "0163a3cf492b5d0b91cafc142a6ac4f1333c65bc52e627bbccbf3ad927f8d527", |
| 20 | "3cacabc5c9b540c6240c063f8d9eca64c0f0d955ffec86bafc04d5f9bd986d78"] }, |
| 21 | #:prepare, fn() { |
| 22 | if not(reuse) { |
| 23 | ; LLVM's release archive also contains Clang, LLDB and other independent projects. |
| 24 | 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") |
| 25 | for-each(fn(patch) { run("patch", "--batch", "--fuzz=0", "-d", "llvm-project-19.1.4.src", "-p1", "-i", string-append("../", patch)) }, |
| 26 | list("fix-memory-mf_exec-on-aarch64.patch", "llvm-stack-size.patch")) |
| 27 | } |
| 28 | }, |
| 29 | #:build, fn() { |
| 30 | if not(reuse) { |
| 31 | run("vinix-llvm", "19.1.4", "llvm-project-19.1.4.src/llvm", build-dir) |
| 32 | run("vinix-ninja", build-dir, "LLVM") |
| 33 | } |
| 34 | }, |
| 35 | #:check, fn() { |
| 36 | run("test", "-s", string-append(build-dir, "/lib/libLLVM.so.19.1")) |
| 37 | }, |
| 38 | #:package, fn() { |
| 39 | ; CMake replaces the build-tree RUNPATH while installing the runtime. |
| 40 | run("env", string-append("DESTDIR=", pkgdir()), "cmake", "--install", build-dir, "--component", "LLVM", "--prefix", "/usr") |
| 41 | run("rm", "-f", "--", string-append(pkgdir(), "/usr/lib/libLLVM.so")) |
| 42 | run("readelf", "-d", string-append(pkgdir(), "/usr/lib/libLLVM.so.19.1")) |
| 43 | license := string-append(build-dir, "/../llvm-project-19.1.4.src/llvm/LICENSE.TXT") |
| 44 | run("install", "-Dm644", license, string-append(pkgdir(), "/usr/share/licenses/llvm19-libs/LICENSE.TXT")) |
| 45 | }) |
| 46 | |