Containerfile (2688B)
1 # test/libc/musl/Containerfile — produces a static musl aarch64 sysroot 2 # tarball on stdout. Pinned to Alpine 3.20.10 + musl 1.2.5. 3 # 4 # Usage (driven by test/libc/musl/extract.sh): 5 # podman build --platform linux/arm64 -f Containerfile -t kit-musl-sysroot . 6 # podman run --rm kit-musl-sysroot > sysroot.tar 7 # 8 # The image's ENTRYPOINT writes a tar of /sysroot to stdout. The extract 9 # script unpacks it into build/musl-sysroot/ on the host. 10 FROM docker.io/arm64v8/alpine:3.20.10 11 12 # musl-dev: Scrt1.o, crt1.o, crti.o, crtn.o, libc.a + headers under /usr/include. 13 # Plus the dynamic linker / libc.so used by the dynamic-link variant of the 14 # harness (in musl, /lib/ld-musl-aarch64.so.1 *is* libc — same file). 15 # linux-headers: kernel uapi (linux/*, asm/*, asm-generic/*) — used by syscall 16 # definitions in the musl headers. 17 # gcc: pulled in for its *runtime only* (libgcc + crt{begin,end}*.o), staged 18 # below so this is a COMPLETE toolchain sysroot — a standard `clang --sysroot` 19 # cross-link works against it, not just kit. (kit still links its own rt/ for the 20 # soft-float / TF / 128-bit-int helpers; only gcc's runtime objects are copied 21 # into the sysroot, not the compiler.) 22 RUN apk add --no-cache musl-dev linux-headers gcc 23 24 # Stage a standard FHS sysroot so both kit and a plain `clang --sysroot` 25 # cross-link can consume it: 26 # /sysroot/usr/include/ — libc + linux-headers 27 # /sysroot/usr/lib/ — crt objects, static libc, ssp, gcc runtime 28 # /sysroot/lib/ — dynamic loader (in musl, this IS libc.so) 29 # cp -aL dereferences the alpine triple symlink + libgcc_s links so the 30 # extracted tree is self-contained. find locates libgcc_s.so.1 (musl: /usr/lib). 31 RUN set -eux; \ 32 mkdir -p /sysroot/usr/include /sysroot/usr/lib /sysroot/lib; \ 33 cp -r /usr/include/. /sysroot/usr/include/; \ 34 cp /usr/lib/crt1.o /usr/lib/Scrt1.o /usr/lib/rcrt1.o \ 35 /usr/lib/crti.o /usr/lib/crtn.o \ 36 /usr/lib/libc.a /usr/lib/libssp_nonshared.a \ 37 /sysroot/usr/lib/; \ 38 cp /lib/ld-musl-aarch64.so.1 /sysroot/lib/; \ 39 ln -s ../../lib/ld-musl-aarch64.so.1 /sysroot/usr/lib/libc.so; \ 40 cp -aL /usr/lib/gcc /sysroot/usr/lib/gcc; \ 41 cp -L "$(find /usr/lib /lib -name libgcc_s.so.1 | head -1)" /sysroot/usr/lib/libgcc_s.so.1; \ 42 ln -sf libgcc_s.so.1 /sysroot/usr/lib/libgcc_s.so; \ 43 for d in /sysroot/usr/lib/gcc/*-alpine-linux-musl; do \ 44 ln -sfn "$(basename "$d")" "${d%-alpine-linux-musl}-linux-musl"; \ 45 done 46 47 # Pin the build for cache reuse and reproducibility audits. 48 RUN echo "alpine 3.20.10 musl 1.2.5-r3" > /sysroot/PROVENANCE \ 49 && uname -m >> /sysroot/PROVENANCE 50 51 ENTRYPOINT ["sh", "-c", "tar -C /sysroot -cf - ."]