Files
Luke Street e8790e035f Use ibiblio mirror and fix macOS build
Switch from ftpmirror.gnu.org to mirrors.ibiblio.org for binutils
downloads. Add --with-system-zlib to macOS build to avoid bundled
zlib's fdopen macro conflicting with macOS SDK headers.
2026-02-08 20:46:13 -07:00

44 lines
1.5 KiB
Docker

# Build stage
ARG ALPINE_VERSION=3.19.1
FROM alpine:${ALPINE_VERSION} AS build
# Install dependencies
RUN apk add --no-cache binutils file gcc make musl-dev patch texinfo
# Install zig
ARG ZIG_VERSION=0.11.0
RUN mkdir /zig && \
wget -qO- "https://ziglang.org/download/${ZIG_VERSION}/zig-linux-`uname -m`-${ZIG_VERSION}.tar.xz" | \
tar -xJ -C /zig --strip-components=1
ENV PATH="/zig:$PATH"
# Download binutils
ARG BINUTILS_VERSION=2.45.1
RUN wget -q https://mirrors.ibiblio.org/gnu/binutils/binutils-${BINUTILS_VERSION}.tar.xz
# Build host binutils
ARG GNU_TRIPLE
RUN mkdir /binutils-host && \
tar -xf /binutils-${BINUTILS_VERSION}.tar.xz -C /binutils-host --strip-components=1 && \
cd /binutils-host && \
./configure --target=${GNU_TRIPLE} --prefix=/usr/local \
--disable-nls --disable-shared --disable-gprofng --disable-ld --disable-gold && \
make -j$(nproc) && \
make install-strip
# Build target binutils
ARG ZIG_TRIPLE
COPY *.patch /
RUN mkdir /binutils && \
tar -xf /binutils-${BINUTILS_VERSION}.tar.xz -C /binutils --strip-components=1 && \
cd /binutils && for patch in ../*.patch; do patch -N -p1 -i $patch; done && \
CC="zig cc -target ${ZIG_TRIPLE}" \
./configure --host=${GNU_TRIPLE} --target=powerpc-xenon-pe --prefix=/target \
--disable-nls --disable-shared --disable-gprof --disable-ld --disable-gold --without-zstd && \
make -j$(nproc) && \
make install-strip
# Export binary (usage: docker build --target export --output build .)
FROM scratch AS export
COPY --from=build /target .