Containerfile.x64 (2872B)
1 # test/libc/glibc/Containerfile.x64 — produces a glibc x86_64 sysroot 2 # tarball on stdout. Pinned to Debian bookworm (glibc 2.36). 3 # 4 # Companion to ./Containerfile (aarch64). See that file for the 5 # design notes on what gets staged and why; arch-specific differences: 6 # - amd64/debian base 7 # - multi-arch dir x86_64-linux-gnu (/usr/lib + /usr/include + /lib) 8 # - runtime loader is /lib64/ld-linux-x86-64.so.2 (note /lib64, 9 # not /lib, unlike aarch64 + riscv64). 10 FROM docker.io/amd64/debian:bookworm-slim 11 12 # gcc: runtime only (libgcc + crt{begin,end}*.o), staged below for a complete 13 # clang-usable sysroot — see ./Containerfile for the rationale. 14 RUN apt-get update \ 15 && apt-get install -y --no-install-recommends \ 16 libc6-dev \ 17 linux-libc-dev \ 18 gcc \ 19 && rm -rf /var/lib/apt/lists/* 20 21 # Stage the artifacts into a standard FHS tree under /sysroot/ so the 22 # result works with both `kit` and a plain `clang --sysroot` cross-link. 23 # usr/include/ — full include tree; the multiarch subdir 24 # (x86_64-linux-gnu/bits/libc-header-start.h etc.) is 25 # preserved inside it so -isystem picks it up. 26 # usr/lib/ — crt objects, libc_nonshared.a, shared SOs, gcc runtime, 27 # and libc.so/libm.so linker scripts for -lc/-lm. 28 # lib64/ — dynamic loader (dereferenced, self-contained). 29 RUN set -eux; \ 30 mkdir -p /sysroot/usr/include /sysroot/usr/lib /sysroot/lib64; \ 31 cp -r /usr/include/. /sysroot/usr/include/; \ 32 cd /usr/lib/x86_64-linux-gnu; \ 33 cp Scrt1.o crti.o crtn.o libc_nonshared.a \ 34 libdl.a libpthread.a libpthread_nonshared.a librt.a libutil.a \ 35 /sysroot/usr/lib/; \ 36 cp -L /lib/x86_64-linux-gnu/libc.so.6 /sysroot/usr/lib/libc.so.6; \ 37 cp -L /lib/x86_64-linux-gnu/libm.so.6 /sysroot/usr/lib/libm.so.6; \ 38 cp -L /lib/x86_64-linux-gnu/libdl.so.2 /sysroot/usr/lib/libdl.so.2; \ 39 cp -L /lib/x86_64-linux-gnu/libpthread.so.0 /sysroot/usr/lib/libpthread.so.0; \ 40 cp -L /lib/x86_64-linux-gnu/librt.so.1 /sysroot/usr/lib/librt.so.1; \ 41 cp -L /lib/x86_64-linux-gnu/libutil.so.1 /sysroot/usr/lib/libutil.so.1; \ 42 cp -L /lib64/ld-linux-x86-64.so.2 /sysroot/lib64/ld-linux-x86-64.so.2; \ 43 printf 'GROUP ( libc.so.6 libc_nonshared.a )\n' > /sysroot/usr/lib/libc.so; \ 44 printf 'GROUP ( libm.so.6 )\n' > /sysroot/usr/lib/libm.so; \ 45 cp -aL /usr/lib/gcc /sysroot/usr/lib/gcc; \ 46 cp -L "$(find /usr/lib /lib -name libgcc_s.so.1 | head -1)" /sysroot/usr/lib/libgcc_s.so.1; \ 47 ln -sf libgcc_s.so.1 /sysroot/usr/lib/libgcc_s.so 48 49 RUN set -eux; \ 50 { \ 51 echo "debian bookworm-slim glibc $(dpkg-query -W -f='${Version}' libc6-dev)"; \ 52 echo "linux-libc-dev $(dpkg-query -W -f='${Version}' linux-libc-dev)"; \ 53 uname -m; \ 54 } > /sysroot/PROVENANCE 55 56 ENTRYPOINT ["sh", "-c", "tar -C /sysroot -cf - ."]