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