Containerfile.rv64 (3376B)
1 # test/libc/glibc/Containerfile.rv64 — produces a glibc riscv64 2 # sysroot tarball on stdout. Pinned to Debian trixie (Debian 13); 3 # riscv64 was promoted to an official Debian architecture in trixie, 4 # so it's the first stable-ish release with libc6-dev available 5 # through the standard apt path. 6 # 7 # Companion to ./Containerfile (aarch64). See that file for the 8 # design notes on what gets staged and why; arch-specific differences: 9 # - riscv64/debian base, trixie release 10 # - multi-arch dir riscv64-linux-gnu 11 # - runtime loader is /lib/ld-linux-riscv64-lp64d.so.1 12 FROM docker.io/riscv64/debian:trixie-slim 13 14 # gcc: runtime only (libgcc + crt{begin,end}*.o), staged below for a complete 15 # clang-usable sysroot — see ./Containerfile for the rationale. 16 RUN apt-get update \ 17 && apt-get install -y --no-install-recommends \ 18 libc6-dev \ 19 linux-libc-dev \ 20 gcc \ 21 && rm -rf /var/lib/apt/lists/* 22 23 # Stage the artifacts into a standard FHS tree under /sysroot/ so the 24 # result works with both `kit` and a plain `clang --sysroot` cross-link. 25 # usr/include/ — full include tree (cp -rL to dereference symlinks; on 26 # trixie linux-libc-dev stages uapi asm headers under 27 # /usr/lib/linux/uapi/<arch>/asm and symlinks them from 28 # /usr/include/<multiarch>/asm/ — plain cp -r leaves 29 # those broken in the sysroot, so -L is required here; 30 # bookworm ships real files so only rv64/trixie needs it). 31 # The multiarch subdir (riscv64-linux-gnu/bits/...) is 32 # preserved inside usr/include/ so -isystem picks it up. 33 # usr/lib/ — crt objects, libc_nonshared.a, shared SOs, gcc runtime, 34 # and libc.so/libm.so linker scripts for -lc/-lm. 35 # lib/ — dynamic loader (dereferenced, self-contained). 36 RUN set -eux; \ 37 mkdir -p /sysroot/usr/include /sysroot/usr/lib /sysroot/lib; \ 38 cp -rL /usr/include/. /sysroot/usr/include/; \ 39 cd /usr/lib/riscv64-linux-gnu; \ 40 cp Scrt1.o crti.o crtn.o libc_nonshared.a \ 41 libdl.a libpthread.a libpthread_nonshared.a librt.a libutil.a \ 42 /sysroot/usr/lib/; \ 43 cp -L /lib/riscv64-linux-gnu/libc.so.6 /sysroot/usr/lib/libc.so.6; \ 44 cp -L /lib/riscv64-linux-gnu/libm.so.6 /sysroot/usr/lib/libm.so.6; \ 45 cp -L /lib/riscv64-linux-gnu/libdl.so.2 /sysroot/usr/lib/libdl.so.2; \ 46 cp -L /lib/riscv64-linux-gnu/libpthread.so.0 /sysroot/usr/lib/libpthread.so.0; \ 47 cp -L /lib/riscv64-linux-gnu/librt.so.1 /sysroot/usr/lib/librt.so.1; \ 48 cp -L /lib/riscv64-linux-gnu/libutil.so.1 /sysroot/usr/lib/libutil.so.1; \ 49 cp -L /lib/ld-linux-riscv64-lp64d.so.1 /sysroot/lib/ld-linux-riscv64-lp64d.so.1; \ 50 printf 'GROUP ( libc.so.6 libc_nonshared.a )\n' > /sysroot/usr/lib/libc.so; \ 51 printf 'GROUP ( libm.so.6 )\n' > /sysroot/usr/lib/libm.so; \ 52 cp -aL /usr/lib/gcc /sysroot/usr/lib/gcc; \ 53 cp -L "$(find /usr/lib /lib -name libgcc_s.so.1 | head -1)" /sysroot/usr/lib/libgcc_s.so.1; \ 54 ln -sf libgcc_s.so.1 /sysroot/usr/lib/libgcc_s.so 55 56 RUN set -eux; \ 57 { \ 58 echo "debian trixie-slim glibc $(dpkg-query -W -f='${Version}' libc6-dev)"; \ 59 echo "linux-libc-dev $(dpkg-query -W -f='${Version}' linux-libc-dev)"; \ 60 uname -m; \ 61 } > /sysroot/PROVENANCE 62 63 ENTRYPOINT ["sh", "-c", "tar -C /sysroot -cf - ."]