vinix-ports / llvm17-dev / PKGBUILD.vile
61 lines · 60 sloc · 3.81 KB · 8a4086957dd6293071929a854b19ba1eb190198c
Raw
1checkpoint := get-environment-variable("VINIX_LLVM_BUILD")
2reuse := if string?(checkpoint) { not(string=?("", checkpoint)) } else { false }
3build-dir := if reuse { checkpoint } else { "build" }
4sdk := get-environment-variable("VPAC_MAKEPKG_ROOT")
5
6defpkgbuild(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-1"],
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 run("cmp", string-append(build-dir, "/lib/libLLVM-17.so"),
30 string-append(sdk, "/usr/lib/libLLVM-17.so"))
31 run("test", "-s", string-append(build-dir, "/CMakeCache.txt"))
32 } else {
33 ; LLVM's release archive also contains Clang, LLDB and other independent projects.
34 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")
35 for-each(fn(patch) { run("patch", "--batch", "--fuzz=0", "-d", "llvm-project-17.0.6.src", "-p1", "-i", string-append("../", patch)) },
36 list("fix-memory-mf_exec-on-aarch64.patch", "llvm-stack-size.patch", "rust-feature-tables-17.patch",
37 "0001-Revert-Pseudo-Probe-Make-.pseudo_probe-GC-able.patch"))
38 }
39 },
40 #:build, fn() {
41 if not(reuse) {
42 run("vinix-llvm", "17.0.6", "llvm-project-17.0.6.src/llvm", build-dir)
43 }
44 run("vinix-ninja", build-dir, "llvm-headers", "llvm-config")
45 },
46 #:check, fn() {
47 run("vinix-run", string-append(build-dir, "/bin/llvm-config"), "--version")
48 run("test", "-s", string-append(build-dir, "/include/llvm/Config/llvm-config.h"))
49 },
50 #:package, fn() {
51 run("env", string-append("DESTDIR=", pkgdir()), "cmake", "--install", build-dir, "--component", "llvm-headers")
52 run("install", "-Dm755", string-append(build-dir, "/bin/llvm-config"),
53 string-append(pkgdir(), "/usr/lib/llvm17/bin/llvm-config"))
54 run("mkdir", "-p", string-append(pkgdir(), "/usr/bin"), string-append(pkgdir(), "/usr/lib/llvm17/lib"))
55 run("ln", "-s", "../lib/llvm17/bin/llvm-config", string-append(pkgdir(), "/usr/bin/llvm-config-17"))
56 for-each(fn(soname) {
57 run("ln", "-s", "../../libLLVM-17.so", string-append(pkgdir(), "/usr/lib/llvm17/lib/", soname))
58 }, list("libLLVM-17.so", "libLLVM-17.0.6.so", "libLLVM.so"))
59 run("install", "-Dm644", string-append(sdk, "/usr/share/licenses/llvm17-libs/LICENSE.TXT"),
60 string-append(pkgdir(), "/usr/share/licenses/llvm17-dev/LICENSE.TXT"))
61 })
62