packages/

zig

Details
Source
FROM scratch AS base
ENV VERSION=0.13.0
ENV SRC_HASH=06c73596beeccb71cc073805bdb9c0e05764128f16478fa53bf17dfabc1d4318
ENV SRC_FILE=zig-${VERSION}.tar.xz
ENV SRC_SITE=https://ziglang.org/download/${VERSION}/${SRC_FILE}

FROM base AS fetch
ADD --checksum=sha256:${SRC_HASH} ${SRC_SITE} .

FROM fetch AS build
COPY --from=stagex/binutils . /
COPY --from=stagex/busybox . /
COPY --from=stagex/clang . /
COPY --from=stagex/cmake . /
COPY --from=stagex/gcc . /
COPY --from=stagex/libzstd . /
COPY --from=stagex/lld . /
COPY --from=stagex/llvm . /
COPY --from=stagex/make . /
COPY --from=stagex/musl . /
COPY --from=stagex/openssl . /
COPY --from=stagex/zlib . /
COPY --from=stagex/ninja . /

RUN --network=none tar -xf ${SRC_FILE}
WORKDIR /zig-${VERSION}
ADD *.patch .
RUN --network=none <<-EOF
    set -eux
    patch -p1 < fix-pie-support-detection.patch
    cmake -B build -G Ninja \
      -DCMAKE_BUILD_TYPE=Release \
      -DCMAKE_PREFIX_PATH=/usr \
      -DCMAKE_INSTALL_PREFIX=/usr \
      -DCMAKE_VERBOSE_MAKEFILE=ON \
      -DZIG_PIE=ON \
      -DZIG_VERSION="${VERSION}" \
      -DZIG_SHARED_LLVM=ON \
      -DZIG_USE_LLVM_CONFIG=ON \
      -DZIG_TARGET_MCPU=baseline \
      -DZIG_TARGET_TRIPLE=native-linux.6.1-musl
    cmake --build build
EOF

FROM build AS install
RUN --network=none DESTDIR=/rootfs cmake --install build

FROM stagex/filesystem AS package
COPY --from=install /rootfs/. /