kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

Containerfile.rv64 (2475B)


      1 # test/libc/musl/Containerfile.rv64 — produces a musl riscv64 sysroot
      2 # tarball on stdout. Uses Alpine edge (riscv64 is in community ports;
      3 # stable Alpine has not yet promoted it to a tier-1 release branch).
      4 #
      5 # Companion to ./Containerfile (aarch64). See that file for the design
      6 # notes on what gets staged and why; arch-specific differences:
      7 #   - riscv64/alpine base
      8 #   - ld-musl-riscv64.so.1 as the dynamic loader (still aliased to
      9 #     libc.so so kit ld can link against it as a shared input).
     10 #
     11 # Note: alpine:edge floats. We pin via the digest-bearing tag at
     12 # extract time when possible; the PROVENANCE record below records the
     13 # resolved musl version so a regression in the upstream package is
     14 # visible in test failures.
     15 FROM docker.io/riscv64/alpine:edge
     16 
     17 # gcc: runtime only (libgcc + crt{begin,end}*.o), staged below for a complete
     18 # clang-usable sysroot — see ./Containerfile for the rationale.
     19 RUN apk add --no-cache musl-dev linux-headers gcc
     20 
     21 # Stage a standard FHS sysroot so both kit and a plain `clang --sysroot`
     22 # cross-link can consume it:
     23 #   /sysroot/usr/include/  — libc + linux-headers
     24 #   /sysroot/usr/lib/      — crt objects, static libc, ssp, gcc runtime
     25 #   /sysroot/lib/          — dynamic loader (in musl, this IS libc.so)
     26 # cp -aL dereferences the alpine triple symlink + libgcc_s links so the
     27 # extracted tree is self-contained. find locates libgcc_s.so.1 (musl: /usr/lib).
     28 RUN set -eux; \
     29     mkdir -p /sysroot/usr/include /sysroot/usr/lib /sysroot/lib; \
     30     cp -r /usr/include/. /sysroot/usr/include/; \
     31     cp /usr/lib/crt1.o /usr/lib/Scrt1.o /usr/lib/rcrt1.o \
     32        /usr/lib/crti.o /usr/lib/crtn.o \
     33        /usr/lib/libc.a /usr/lib/libssp_nonshared.a \
     34        /sysroot/usr/lib/; \
     35     cp /lib/ld-musl-riscv64.so.1 /sysroot/lib/; \
     36     ln -s ../../lib/ld-musl-riscv64.so.1 /sysroot/usr/lib/libc.so; \
     37     cp -aL /usr/lib/gcc /sysroot/usr/lib/gcc; \
     38     cp -L "$(find /usr/lib /lib -name libgcc_s.so.1 | head -1)" /sysroot/usr/lib/libgcc_s.so.1; \
     39     ln -sf libgcc_s.so.1 /sysroot/usr/lib/libgcc_s.so; \
     40     for d in /sysroot/usr/lib/gcc/*-alpine-linux-musl; do \
     41         ln -sfn "$(basename "$d")" "${d%-alpine-linux-musl}-linux-musl"; \
     42     done
     43 
     44 RUN sh -c 'set -eu; \
     45     musl_ver=$(apk info -v musl-dev | head -1); \
     46     alpine_rel=$(cat /etc/alpine-release); \
     47     echo "alpine $alpine_rel  $musl_ver" > /sysroot/PROVENANCE; \
     48     uname -m >> /sysroot/PROVENANCE'
     49 
     50 ENTRYPOINT ["sh", "-c", "tar -C /sysroot -cf - ."]