vinix-ports / musl / PKGBUILD.vile
55 lines · 54 sloc · 3.12 KB
Raw
1; Source and patch order follow Vinix build-support/musl at a58255423ede.
2defpkgbuild(musl,
3 #:pkgname, "musl",
4 #:pkgver, "1.2.6",
5 #:pkgrel, 1,
6 #:pkgdesc, "Vinix C runtime, development headers and GCC specs",
7 #:arch, [#:x86-64],
8 #:url, "https://musl.libc.org/",
9 #:license, "MIT",
10 #:source, ["https://musl.libc.org/releases/musl-1.2.6.tar.gz",
11 "patches/handle-aux-at_base.patch",
12 "patches/0001-add-stub-for-pthread_mutexattr_setprioceiling.patch",
13 "patches/fix-loongarch64-zero-len-extcontext.patch",
14 "patches/CVE-2026-6042.patch",
15 "patches/CVE-2026-40200.patch",
16 "patches/malloc-retain.patch"],
17 #:sha256sums, ["d585fd3b613c66151fc3249e8ed44f77020cb5e6c1e635a616d3f9f82460512a",
18 "2a65e03b94217063d72fe998e5fb2e25cd01716078a3ba1b0ab574ab205111e6",
19 "b2067680c66af9eb9f4fdc1fa5d9337a9fd62bdab2c437b416aa97d79eb884ee",
20 "92c8e965798ed516c15cb2a4e7c4ac45ec1eb68b6abff16c73adff2a3bae1b14",
21 "1d0be2e72b9d5bd16546b923aa8af861d271322f01644716a81823bec4065c99",
22 "1ee29f64f9ca8e8ad7c349779d661ff6b52126a27575d3586981357a52c406fb",
23 "ec459e48e5c3c9946c91e805428149802d0ab1835c64e5e023811ab54a48af1d"],
24
25 #:prepare, fn() {
26 for-each(fn(patch) {
27 run("patch", "--batch", "--fuzz=0", "-d", "musl-1.2.6", "-p1", "-i", string-append("../", patch))
28 }, list("handle-aux-at_base.patch", "0001-add-stub-for-pthread_mutexattr_setprioceiling.patch",
29 "fix-loongarch64-zero-len-extcontext.patch", "CVE-2026-6042.patch",
30 "CVE-2026-40200.patch", "malloc-retain.patch"))
31 ; Match the x86-64 string routines selected by the Vinix system libc.
32 run("rm", "musl-1.2.6/src/string/x86_64/memcpy.s", "musl-1.2.6/src/string/x86_64/memmove.s")
33 },
34 #:build, fn() {
35 run("env", "CC=gcc", "AR=ar", "RANLIB=ranlib", "CFLAGS=-fstack-protector-strong -DVINIX_MALLOC_RETAIN=1",
36 "LDFLAGS=-Wl,-soname,libc.musl-x86_64.so.1", "musl-1.2.6/configure",
37 "--target=x86_64-linux-musl", "--prefix=/usr", "--syslibdir=/lib", "--enable-wrapper=gcc",
38 "--enable-optimize=internal,malloc,malloc/mallocng/*.c,string")
39 run("make")
40 },
41 #:package, fn() {
42 run("make", "install", string-append("DESTDIR=", pkgdir()))
43 ; The SONAME, ELF interpreter and development linker name refer to one file.
44 loader := string-append(pkgdir(), "/lib/ld-musl-x86_64.so.1")
45 devlib := string-append(pkgdir(), "/usr/lib/libc.so")
46 run("rm", loader)
47 run("mv", devlib, loader)
48 run("ln", "-s", "ld-musl-x86_64.so.1", string-append(pkgdir(), "/lib/libc.musl-x86_64.so.1"))
49 run("ln", "-s", "../../lib/ld-musl-x86_64.so.1", devlib)
50 ; GCC expands %R to its --sysroot. Leave the interpreter path guest-absolute.
51 specs := string-append(pkgdir(), "/usr/lib/musl-gcc-sysroot.specs")
52 run("cp", string-append(pkgdir(), "/usr/lib/musl-gcc.specs"), specs)
53 run("sed", "-i", "-e", "s|/usr/include|%R/usr/include|g", "-e", "s|/usr/lib|%R/usr/lib|g", specs)
54 run("install", "-Dm644", "musl-1.2.6/COPYRIGHT", string-append(pkgdir(), "/usr/share/licenses/musl/COPYRIGHT"))
55 })
56