Source

FROM scratch AS build
ARG VERSION
COPY --from=stagex/core-llvm . /
COPY --from=stagex/core-libzstd . /
COPY --from=stagex/core-zlib . /
COPY --from=stagex/core-musl . /
COPY --from=stagex/core-make . /
COPY --from=stagex/core-busybox . /
COPY --from=stagex/core-samurai . /
COPY --from=stagex/core-cmake . /
COPY --from=stagex/core-openssl . /
COPY --from=stagex/core-onetbb . /
ADD fetch/mold-${VERSION}.tar.gz .
WORKDIR /mold-${VERSION}
ENV SOURCE_DATE_EPOCH=1
RUN --network=none <<-EOF
	set -eux

	# Downscope `third-party` (the libs `mold` vendors itself) to only what's used
	# TODO: Vendor `blake3` via StageX, as `mold` will automatically prefer a system lib to its own
	mkdir used-third-party
	for folder in blake3 xxhash rust-demangle; do
		mv third-party/$folder used-third-party/
	done
	rm -rf third-party
	mv used-third-party third-party

	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=/usr/lib \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON \
		-DMOLD_LTO=ON \
		-DMOLD_USE_MIMALLOC=OFF \
		-DMOLD_USE_SYSTEM_TBB=ON \
		-DBUILD_TESTING=OFF
	cmake --build build
	DESTDIR="/rootfs" cmake --install build
EOF
FROM stagex/core-filesystem AS package
COPY --from=build /rootfs/ /
Copied to clipboard!