Containerfile (3496B)
1 # test/libc/glibc/Containerfile — produces a glibc aarch64 sysroot tarball 2 # on stdout. Pinned to Debian bookworm (glibc 2.36). 3 # 4 # Usage (driven by test/libc/glibc/extract.sh): 5 # podman build --platform linux/arm64 -f Containerfile -t kit-glibc-sysroot . 6 # podman run --rm kit-glibc-sysroot > sysroot.tar 7 # 8 # The image's ENTRYPOINT writes a tar of /sysroot to stdout. The extract 9 # script unpacks it into build/glibc-sysroot/ on the host. 10 # 11 # Notes about glibc on Debian (vs. the musl/Alpine variant): 12 # - libc is split across libc.so.6 (the dynamic SO) and 13 # libc_nonshared.a (a few non-shared callbacks pulled in by every 14 # dynamic exe — atexit, __stack_chk_fail_local, etc.). On disk, 15 # /usr/lib/aarch64-linux-gnu/libc.so is a *linker script* that 16 # GROUPs them. kit ld doesn't parse linker scripts, so we copy 17 # libc.so.6 directly and hand it to the linker by path. 18 # - The runtime loader is /lib/ld-linux-aarch64.so.1, distinct from 19 # libc (unlike musl, where ld-musl-aarch64.so.1 *is* libc). That 20 # means the dynamic-link variant of the harness must pass 21 # -dynamic-linker explicitly; kit ld's default is musl. 22 # - Debian uses multi-arch paths: Scrt1.o + crti/crtn live under 23 # /usr/lib/aarch64-linux-gnu, the runtime SOs under 24 # /lib/aarch64-linux-gnu, and headers under both /usr/include and 25 # /usr/include/aarch64-linux-gnu. We flatten everything into 26 # /sysroot/{lib,include} with the multi-arch include kept as a 27 # subdir so -isystem can pick it up. 28 FROM docker.io/arm64v8/debian:bookworm-slim 29 30 # libc6-dev: Scrt1.o, crti.o, crtn.o, libc_nonshared.a + glibc headers 31 # under /usr/include and /usr/include/aarch64-linux-gnu. We 32 # deliberately do NOT stage libc.a or the static -lpthread/-ldl/-lrt 33 # archives: the harness only exercises dynamic-link (static-glibc is 34 # officially discouraged and isn't a real-world deployment shape). 35 # linux-libc-dev: kernel uapi (linux/*, asm/*, asm-generic/*) under 36 # /usr/include — used by syscall numbers etc. Pulled in transitively 37 # by libc6-dev, listed explicitly for clarity. 38 # Note: we deliberately do NOT pull libgcc / compiler-rt — soft-float 39 # / TF / 128-bit-int helpers come from our own rt/ build. 40 RUN apt-get update \ 41 && apt-get install -y --no-install-recommends \ 42 libc6-dev \ 43 linux-libc-dev \ 44 && rm -rf /var/lib/apt/lists/* 45 46 # Stage the artifacts the linker needs into one tree so the host extract 47 # is a single tar pipe. Multi-arch dirs get flattened to /sysroot/lib/. 48 # Symlinks (notably ld-linux-aarch64.so.1) are dereferenced so the 49 # extracted tree is self-contained. 50 RUN set -eux; \ 51 mkdir -p /sysroot/lib /sysroot/include; \ 52 cd /usr/lib/aarch64-linux-gnu; \ 53 cp Scrt1.o crti.o crtn.o libc_nonshared.a /sysroot/lib/; \ 54 cp -L /lib/aarch64-linux-gnu/libc.so.6 /sysroot/lib/libc.so.6; \ 55 cp -L /lib/aarch64-linux-gnu/libm.so.6 /sysroot/lib/libm.so.6; \ 56 cp -L /lib/ld-linux-aarch64.so.1 /sysroot/lib/ld-linux-aarch64.so.1; \ 57 # Common include tree + multi-arch (sys/cdefs.h, bits/*, gnu/stubs-lp64.h) 58 cp -r /usr/include/. /sysroot/include/ 59 60 # Pin the build for cache reuse and reproducibility audits. 61 RUN set -eux; \ 62 { \ 63 echo "debian bookworm-slim glibc $(dpkg-query -W -f='${Version}' libc6-dev)"; \ 64 echo "linux-libc-dev $(dpkg-query -W -f='${Version}' linux-libc-dev)"; \ 65 uname -m; \ 66 } > /sysroot/PROVENANCE 67 68 ENTRYPOINT ["sh", "-c", "tar -C /sysroot -cf - ."]