checkpoint := get-environment-variable("VINIX_LLVM_BUILD") reuse := if string?(checkpoint) { not(string=?("", checkpoint)) } else { #f } build-dir := if reuse { checkpoint } else { "build" } defpkgbuild(llvm19-libs, #:pkgname, "llvm19-libs", #:pkgver, "19.1.4", #:pkgrel, 2, #:pkgdesc, "LLVM runtime for the native CPU and AMDGPU (LLVM 19)", #: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-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", "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/llvm19/fix-memory-mf_exec-on-aarch64.patch", "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/llvm19/llvm-stack-size.patch"] }, #:sha256sums, if reuse { list() } else { ["3aa2d2d2c7553164ad5c6f3b932b31816e422635e18620c9349a7da95b98d811", "0163a3cf492b5d0b91cafc142a6ac4f1333c65bc52e627bbccbf3ad927f8d527", "3cacabc5c9b540c6240c063f8d9eca64c0f0d955ffec86bafc04d5f9bd986d78"] }, #:prepare, fn() { if not(reuse) { ; LLVM's release archive also contains Clang, LLDB and other independent projects. 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") for-each(fn(patch) { run("patch", "--batch", "--fuzz=0", "-d", "llvm-project-19.1.4.src", "-p1", "-i", string-append("../", patch)) }, list("fix-memory-mf_exec-on-aarch64.patch", "llvm-stack-size.patch")) } }, #:build, fn() { if not(reuse) { run("vinix-llvm", "19.1.4", "llvm-project-19.1.4.src/llvm", build-dir) run("vinix-ninja", build-dir, "LLVM") } }, #:check, fn() { run("test", "-s", string-append(build-dir, "/lib/libLLVM.so.19.1")) }, #: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.so.19.1")) license := string-append(build-dir, "/../llvm-project-19.1.4.src/llvm/LICENSE.TXT") run("install", "-Dm644", license, string-append(pkgdir(), "/usr/share/licenses/llvm19-libs/LICENSE.TXT")) })