kit

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

Containerfile.x64 (2061B)


      1 # test/libc/musl/Containerfile.x64 — produces a musl x86_64 sysroot
      2 # tarball on stdout. Pinned to Alpine 3.20.10 + musl 1.2.5.
      3 #
      4 # Companion to ./Containerfile (aarch64). See that file for the design
      5 # notes on what gets staged and why; only the arch-specific bits differ
      6 # here:
      7 #   - amd64/alpine base image
      8 #   - ld-musl-x86_64.so.1 as the dynamic loader (still aliased to
      9 #     libc.so so kit ld can link against it as a shared input).
     10 FROM docker.io/amd64/alpine:3.20.10
     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 apk add --no-cache musl-dev linux-headers gcc
     15 
     16 # Stage a standard FHS sysroot so both kit and a plain `clang --sysroot`
     17 # cross-link can consume it:
     18 #   /sysroot/usr/include/  — libc + linux-headers
     19 #   /sysroot/usr/lib/      — crt objects, static libc, ssp, gcc runtime
     20 #   /sysroot/lib/          — dynamic loader (in musl, this IS libc.so)
     21 # cp -aL dereferences the alpine triple symlink + libgcc_s links so the
     22 # extracted tree is self-contained. find locates libgcc_s.so.1 (musl: /usr/lib).
     23 RUN set -eux; \
     24     mkdir -p /sysroot/usr/include /sysroot/usr/lib /sysroot/lib; \
     25     cp -r /usr/include/. /sysroot/usr/include/; \
     26     cp /usr/lib/crt1.o /usr/lib/Scrt1.o /usr/lib/rcrt1.o \
     27        /usr/lib/crti.o /usr/lib/crtn.o \
     28        /usr/lib/libc.a /usr/lib/libssp_nonshared.a \
     29        /sysroot/usr/lib/; \
     30     cp /lib/ld-musl-x86_64.so.1 /sysroot/lib/; \
     31     ln -s ../../lib/ld-musl-x86_64.so.1 /sysroot/usr/lib/libc.so; \
     32     cp -aL /usr/lib/gcc /sysroot/usr/lib/gcc; \
     33     cp -L "$(find /usr/lib /lib -name libgcc_s.so.1 | head -1)" /sysroot/usr/lib/libgcc_s.so.1; \
     34     ln -sf libgcc_s.so.1 /sysroot/usr/lib/libgcc_s.so; \
     35     for d in /sysroot/usr/lib/gcc/*-alpine-linux-musl; do \
     36         ln -sfn "$(basename "$d")" "${d%-alpine-linux-musl}-linux-musl"; \
     37     done
     38 
     39 RUN echo "alpine 3.20.10  musl 1.2.5-r3" > /sysroot/PROVENANCE \
     40  && uname -m >> /sysroot/PROVENANCE
     41 
     42 ENTRYPOINT ["sh", "-c", "tar -C /sysroot -cf - ."]