build: completely refactor static build to support cross-compilation

This commit is contained in:
Marcus Holland-Moritz 2025-07-23 07:31:53 +02:00
parent 9fc2b895b2
commit 2dec20b01f
15 changed files with 1223 additions and 644 deletions

View File

@ -1,9 +1,18 @@
# syntax=docker/dockerfile:1 # syntax=docker/dockerfile:1
ARG ARCH=amd64 ARG ARCH=amd64
FROM $ARCH/alpine:latest FROM $ARCH/alpine:latest
ARG ARCH
ARG TARGET_ARCHS
ARG TOOLCHAIN_OPTIMIZE=2
RUN apk update RUN apk update
RUN apk upgrade RUN apk upgrade
RUN apk add --no-cache \ RUN qemu_pkgs=""; \
for arch in $(echo $TARGET_ARCHS | tr ',' ' '); do \
qemu_pkgs="$qemu_pkgs qemu-$arch"; \
done; \
apk add --no-cache \
bash-completion \ bash-completion \
build-base \ build-base \
wget \ wget \
@ -11,81 +20,90 @@ RUN apk add --no-cache \
vim \ vim \
tar \ tar \
ripgrep \ ripgrep \
py3-pip \
less \ less \
gcc \ gcc \
g++ \ g++ \
clang18 \ clang18 \
clang19 \ clang19 \
clang20 \
lld \
git \ git \
xz \
gzip \
bzip2 \
zstd \
ccache \ ccache \
samurai \ ninja-build \
cmake \ cmake \
make \ make \
bison \ bison \
flex \ flex \
ronn \ ronn \
perf \
py3-pip \
fuse \ fuse \
fuse-dev \
fuse-static \
fuse3 \ fuse3 \
fuse3-dev \
fuse3-static \
pkgconf \ pkgconf \
binutils-dev \
libevent-dev \
libevent-static \
linux-headers \
date-dev \
range-v3-dev \
zlib-static \
libucontext-dev \
libdwarf-dev \
elfutils-dev \
utfcpp \
nlohmann-json \
meson \ meson \
autoconf \ autoconf \
strace \ strace \
gdb gdb \
gmp-dev \
zlib-static \
zstd-static \
zlib-dev \
zstd-dev \
mpfr-dev \
mpc1-dev \
isl-dev \
texinfo \
linux-headers \
gdb-multiarch \
rsync \
screen \
$qemu_pkgs
# Install UPX COPY fetch.sh /usr/local/bin/fetch.sh
ARG ARCH
# UPX isn't supported on RISC-V yet, so skip this
RUN if [ "$ARCH" != "riscv64" ]; then \
wget -O - https://github.com/upx/upx/releases/download/v5.0.0/upx-5.0.0-$(bash -c "echo \${0//v8/}" $ARCH)_linux.tar.xz | tar -xJf - -C /usr/local/bin --strip-components=1 --wildcards "*/upx"; \
else \
echo "Skipping UPX installation for RISC-V architecture while it is not supported."; \
echo "See https://github.com/upx/upx/discussions/793 for details."; \
fi
# Install mistletoe
RUN pip3 install --break-system-packages --root-user-action ignore mistletoe
# Install size-optimized and static-link-optimized libstdc++
RUN apk add --no-cache gmp-dev mpfr-dev mpc1-dev isl-dev
COPY install-libstdcxx.sh /usr/local/bin/install-libstdcxx.sh
RUN bash /usr/local/bin/install-libstdcxx.sh
# Install mold # Install mold
COPY install-mold.sh /usr/local/bin/install-mold.sh COPY install-mold.sh /usr/local/bin/install-mold.sh
RUN bash /usr/local/bin/install-mold.sh RUN --mount=type=cache,id=ccache,target=/root/.ccache --mount=type=cache,id=pkgcache,target=/root/.pkgcache \
bash /usr/local/bin/install-mold.sh
# Install bloaty # Install bloaty
COPY install-bloaty.sh /usr/local/bin/install-bloaty.sh COPY install-bloaty.sh /usr/local/bin/install-bloaty.sh
RUN if [ "$ARCH" != "riscv64" ]; then \ RUN --mount=type=cache,id=ccache,target=/root/.ccache --mount=type=cache,id=pkgcache,target=/root/.pkgcache \
if [ "$ARCH" == "amd64" ]; then \
bash /usr/local/bin/install-bloaty.sh; \ bash /usr/local/bin/install-bloaty.sh; \
else \ else \
echo "Skipping bloaty installation for RISC-V."; \ echo "Skipping bloaty installation for $ARCH."; \
fi fi
RUN apk del linux-headers
# Install size-optimized and static-link-optimized libstdc++
COPY install-toolchain.sh /usr/local/bin/install-toolchain.sh
RUN --mount=type=cache,id=ccache,target=/root/.ccache --mount=type=cache,id=pkgcache,target=/root/.pkgcache \
bash /usr/local/bin/install-toolchain.sh $TOOLCHAIN_OPTIMIZE $TARGET_ARCHS
RUN apk del zlib-dev zstd-dev
# Install all static libraries # Install all static libraries
COPY install-static-libs.sh /usr/local/bin/install-static-libs.sh COPY install-static-libs.sh /usr/local/bin/install-static-libs.sh
RUN bash /usr/local/bin/install-static-libs.sh gcc clang-19 :alpine
# Install the *real* ninja... RUN --mount=type=cache,id=ccache,target=/root/.ccache --mount=type=cache,id=pkgcache,target=/root/.pkgcache \
# TODO: move this up if we change anything bash /usr/local/bin/install-static-libs.sh :all $TARGET_ARCHS
RUN apk add --no-cache ninja-build
# Install UPX
# UPX isn't supported on RISC-V/S390 (yet), so skip this
RUN if [ "$ARCH" == "amd64" ] || [ "$ARCH" == "arm64v8" ]; then \
wget -O - https://github.com/upx/upx/releases/download/v5.0.2/upx-5.0.2-$(bash -c "echo \${0//v8/}" $ARCH)_linux.tar.xz | tar -xJf - -C /usr/local/bin --strip-components=1 --wildcards "*/upx"; \
else \
echo "Skipping UPX installation for $ARCH architecture while it is not supported."; \
echo "See https://github.com/upx/upx/discussions/793 for details."; \
fi
RUN pip3 install --break-system-packages --root-user-action ignore mistletoe
# Set up git & user # Set up git & user
RUN git config --global --add safe.directory /workspace RUN git config --global --add safe.directory /workspace

View File

@ -72,13 +72,6 @@ RUN apt install -y \
libflac++-dev \ libflac++-dev \
nlohmann-json3-dev \ nlohmann-json3-dev \
python3-mistletoe python3-mistletoe
### XXX: no more static libs for Ubuntu
# COPY install-static-libs.sh /usr/local/bin/install-static-libs.sh
# # TODO: gcc-14 cannot build the current version of libunwind
# RUN bash /usr/local/bin/install-static-libs.sh gcc-13 clang-18 :ubuntu
ARG ARCH
# upx-4.2.2 is broken for arm64 (https://github.com/upx/upx/issues/758)
RUN wget -O - https://github.com/upx/upx/releases/download/v5.0.0/upx-5.0.0-$(bash -c "echo \${0//v8/}" $ARCH)_linux.tar.xz | tar -xJf - -C /usr/local/bin --strip-components=1 --wildcards "*/upx"
# current ronn version is horribly broken # current ronn version is horribly broken
RUN gem install ronn-ng RUN gem install ronn-ng
# RUN useradd -g users -u 1000 -m mhx # RUN useradd -g users -u 1000 -m mhx

View File

@ -1,7 +1,7 @@
IMAGE_UBUNTU="dwarfs-buildenv" IMAGE_UBUNTU="dwarfs-buildenv"
IMAGE_DEBIAN="dwarfs-buildenv-debian" IMAGE_DEBIAN="dwarfs-buildenv-debian"
IMAGE_ALPINE="dwarfs-buildenv-alpine" IMAGE_ALPINE="dwarfs-buildenv-alpine"
IMAGE_ALPINE_RISCV="dwarfs-buildenv-alpine-riscv64" IMAGE_ALPINE_NEWARCH="dwarfs-buildenv-alpine-newarch"
IMAGE_UBUNTU2204="dwarfs-buildenv-ubuntu2204" IMAGE_UBUNTU2204="dwarfs-buildenv-ubuntu2204"
IMAGE_FEDORA="dwarfs-buildenv-fedora" IMAGE_FEDORA="dwarfs-buildenv-fedora"
IMAGE_ARCH="dwarfs-buildenv-arch" IMAGE_ARCH="dwarfs-buildenv-arch"
@ -34,16 +34,16 @@ run_debian:
@docker run $(COMMON_RUN_OPTS) $(IMAGE_DEBIAN) @docker run $(COMMON_RUN_OPTS) $(IMAGE_DEBIAN)
build_alpine: build_alpine:
docker build -f Dockerfile.alpine -t $(IMAGE_ALPINE) . docker buildx build -f Dockerfile.alpine --build-arg TARGET_ARCHS=x86_64,aarch64,riscv64,ppc64le,s390x,arm,i386 -t $(IMAGE_ALPINE) .
run_alpine: run_alpine:
@docker run $(COMMON_RUN_OPTS) $(IMAGE_ALPINE) @docker run $(COMMON_RUN_OPTS) $(IMAGE_ALPINE)
build_alpine_riscv: build_alpine_newarch:
docker build -f Dockerfile.alpine -t $(IMAGE_ALPINE_RISCV) --build-arg ARCH=riscv64 . docker buildx build -f Dockerfile.alpine --build-arg TARGET_ARCHS=s390x -t $(IMAGE_ALPINE_NEWARCH) .
run_alpine_riscv: run_alpine_newarch:
@docker run $(COMMON_RUN_OPTS) $(IMAGE_ALPINE_RISCV) @docker run $(COMMON_RUN_OPTS) $(IMAGE_ALPINE_NEWARCH)
build_ubuntu2204: build_ubuntu2204:
docker build -f Dockerfile.ubuntu-2204 -t $(IMAGE_UBUNTU2204) . docker build -f Dockerfile.ubuntu-2204 -t $(IMAGE_UBUNTU2204) .

View File

@ -9,8 +9,8 @@ mkdir -p "$LOCAL_REPO_PATH"
LAST_UPDATE_FILE="$LOCAL_REPO_PATH/last-update" LAST_UPDATE_FILE="$LOCAL_REPO_PATH/last-update"
WORKFLOW_LOG_DIR="/artifacts/workflow-logs/${GITHUB_RUN_ID}" WORKFLOW_LOG_DIR="/artifacts/workflow-logs/${GITHUB_RUN_ID}"
NINJA_LOG_FILE="${WORKFLOW_LOG_DIR}/ninja-${BUILD_ARCH},${BUILD_DIST},${BUILD_TYPE}.log" NINJA_LOG_FILE="${WORKFLOW_LOG_DIR}/ninja-${BUILD_ARCH},${CROSS_ARCH},${BUILD_DIST},${BUILD_TYPE}.log"
BUILD_LOG_FILE="${WORKFLOW_LOG_DIR}/build-${BUILD_ARCH},${BUILD_DIST},${BUILD_TYPE}.log" BUILD_LOG_FILE="${WORKFLOW_LOG_DIR}/build-${BUILD_ARCH},${CROSS_ARCH},${BUILD_DIST},${BUILD_TYPE}.log"
mkdir -p "$WORKFLOW_LOG_DIR" mkdir -p "$WORKFLOW_LOG_DIR"
log() { log() {
@ -77,7 +77,7 @@ cd build
# Stick to clang-18, clang-19 has a regression for nilsimsa performance # Stick to clang-18, clang-19 has a regression for nilsimsa performance
if [[ "$BUILD_DIST" == "alpine" ]]; then if [[ "$BUILD_DIST" == "alpine" ]]; then
GCC_VERSION= GCC_VERSION=
CLANG_VERSION=-19 CLANG_VERSION=-20
elif [[ "$BUILD_DIST" == "ubuntu-2204" ]]; then elif [[ "$BUILD_DIST" == "ubuntu-2204" ]]; then
GCC_VERSION=-12 GCC_VERSION=-12
CLANG_VERSION=-15 CLANG_VERSION=-15
@ -114,6 +114,9 @@ case "-$BUILD_TYPE-" in
*-ubuntu-*|*-debian-*) *-ubuntu-*|*-debian-*)
export CC=gcc$GCC_VERSION CXX=g++$GCC_VERSION export CC=gcc$GCC_VERSION CXX=g++$GCC_VERSION
;; ;;
*)
export CC=gcc CXX=g++
;;
esac esac
export COMPILER=gcc export COMPILER=gcc
;; ;;
@ -182,9 +185,18 @@ esac
case "-$BUILD_TYPE-" in case "-$BUILD_TYPE-" in
*-static-*) *-static-*)
case "$CROSS_ARCH" in
ppc64le)
# https://github.com/rui314/mold/issues/1490
CMAKE_ARGS="${CMAKE_ARGS} -DDISABLE_MOLD=1"
export LDFLAGS="${LDFLAGS} -fuse-ld=lld"
;;
*)
export LDFLAGS="${LDFLAGS} -fuse-ld=mold" export LDFLAGS="${LDFLAGS} -fuse-ld=mold"
;; ;;
esac esac
;;
esac
case "-$BUILD_TYPE-" in case "-$BUILD_TYPE-" in
*-lto-*) *-lto-*)
@ -287,39 +299,49 @@ if [[ "-$BUILD_TYPE-" == *-shared-* ]]; then
fi fi
if [[ "-$BUILD_TYPE-" == *-static-* ]]; then if [[ "-$BUILD_TYPE-" == *-static-* ]]; then
if [[ "-$BUILD_TYPE-" == *-relsize-* ]]; then # A size-optimized libgcc/libstdc++/musl will only save about 10k for the universal
_LIBSTDCXXDIR="/opt/static-libs/libstdc++-Os/lib" # and fuse-extract binaries, so we'll just stick to using the -O2 toolchain.
if [[ "$ARCH" == "aarch64" ]]; then _SYSROOT="/opt/cross/O2"
# Similar to the issue with *not* linking against `gcc_eh` in the CMakeLists.txt, _MARCH="${CROSS_ARCH}"
# if we link against the `gcc_eh` from the `-Os` build, we run into exactly the if [[ -z "$CROSS_ARCH" ]]; then
# same issue. So we temporarily copy the size-optimized `libgcc.a` to a directory _MARCH="${ARCH}"
# we then use for linking. fi
_GCCLIBDIR="/tmp/gcclib" if [[ "$_MARCH" == "arm" ]]; then
mkdir -p "$_GCCLIBDIR" _TARGET="${_MARCH}-linux-musleabihf"
cp -a "$_LIBSTDCXXDIR"/gcc/*/*/libgcc.a "$_GCCLIBDIR"
else else
_GCCLIBDIR=$(ls -d1 $_LIBSTDCXXDIR/gcc/*/*) _TARGET="${_MARCH}-alpine-linux-musl"
fi fi
LDFLAGS="${LDFLAGS} -L$_GCCLIBDIR -L$_LIBSTDCXXDIR" export CC="${_TARGET}-${CC}"
fi export CXX="${_TARGET}-${CXX}"
export LDFLAGS="${LDFLAGS} -L/opt/static-libs/$COMPILER/lib" export STRIP_TOOL="${_TARGET}-strip"
if [[ "$ARCH" == "aarch64" ]]; then export PATH="$_SYSROOT/usr/bin:$PATH"
# For some reason, this dependency of libunwind is not resolved on aarch64
export LDFLAGS="${LDFLAGS} -lz" _staticprefix="/opt/static-libs/$COMPILER/$_TARGET"
fi
CMAKE_ARGS="${CMAKE_ARGS} -DSTATIC_BUILD_DO_NOT_USE=1 -DWITH_UNIVERSAL_BINARY=1 -DWITH_FUSE_EXTRACT_BINARY=1"
if [[ "$BUILD_TYPE" == *-minimal-* ]]; then if [[ "$BUILD_TYPE" == *-minimal-* ]]; then
_jemallocprefix="/opt/static-libs/$COMPILER-jemalloc-minimal" _jemallocprefix="/opt/static-libs/$COMPILER-jemalloc-minimal/$_TARGET"
else else
CMAKE_ARGS="${CMAKE_ARGS} -DWITH_PXATTR=1" CMAKE_ARGS="${CMAKE_ARGS} -DWITH_PXATTR=1"
_jemallocprefix="/opt/static-libs/$COMPILER-jemalloc-full" _jemallocprefix="/opt/static-libs/$COMPILER-jemalloc-full/$_TARGET"
fi fi
if [[ "$BUILD_TYPE" == *-libressl-* ]]; then if [[ "$BUILD_TYPE" == *-libressl-* ]]; then
_sslprefix="/opt/static-libs/$COMPILER-libressl" _sslprefix="/opt/static-libs/$COMPILER-libressl/$_TARGET"
else else
_sslprefix="/opt/static-libs/$COMPILER-openssl" _sslprefix="/opt/static-libs/$COMPILER-openssl/$_TARGET"
fi
export LDFLAGS="${LDFLAGS} -static-libgcc -L$_staticprefix/lib -L$_sslprefix/lib"
export CFLAGS="${CFLAGS} -isystem $_staticprefix/include"
export CXXFLAGS="${CXXFLAGS} -isystem $_staticprefix/include"
if [[ "$_MARCH" == "i386" ]]; then
export LDFLAGS="${LDFLAGS} -lucontext"
fi
CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_SYSROOT=$_SYSROOT -DCMAKE_FIND_ROOT_PATH=$_staticprefix;$_sslprefix;$_jemallocprefix -DCMAKE_PREFIX_PATH=$_staticprefix;$_sslprefix;$_jemallocprefix -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY -DSTATIC_BUILD_DO_NOT_USE=1 -DWITH_UNIVERSAL_BINARY=1 -DWITH_FUSE_EXTRACT_BINARY=1"
if [[ -n "$CROSS_ARCH" ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=$_MARCH -DCMAKE_CROSSCOMPILING_EMULATOR=/usr/bin/qemu-$_MARCH -DFOLLY_HAVE_UNALIGNED_ACCESS=OFF -DFOLLY_HAVE_WEAK_SYMBOLS=ON -DFOLLY_HAVE_LINUX_VDSO=OFF -DFOLLY_HAVE_WCHAR_SUPPORT=OFF -DHAVE_VSNPRINTF_ERRORS=OFF"
fi fi
CMAKE_ARGS="${CMAKE_ARGS} -DSTATIC_BUILD_EXTRA_PREFIX=/opt/static-libs/$COMPILER;$_sslprefix;$_jemallocprefix"
fi fi
INSTALLDIR="$HOME/install" INSTALLDIR="$HOME/install"

View File

@ -23,6 +23,13 @@ repositories = [
# "microsoft/mimalloc", # "microsoft/mimalloc",
"jemalloc/jemalloc", "jemalloc/jemalloc",
"tukaani-project/xz", "tukaani-project/xz",
"davea42/libdwarf-code",
"libevent/libevent",
"nlohmann/json",
"HowardHinnant/date",
"nemtrif/utfcpp",
"ericniebler/range-v3",
"greg7mdp/parallel-hashmap",
] ]

31
.docker/fetch.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/bash
set -ex
URL=$1
FILE=${2:-$(basename "$URL")}
SHA512SUM="${3}"
URLHASH=$(echo -n "$URL" | sha256sum | awk '{print $1}')
CACHEDIR="$HOME/.pkgcache"
CACHEFILE="$CACHEDIR/$URLHASH"
if [ ! -f "$CACHEFILE" ]; then
rm -f "$CACHEFILE.tmp"
curl --retry 5 -L "$URL" > "$CACHEFILE.tmp"
if [ -n "$SHA512SUM" ]; then
echo "$SHA512SUM $CACHEFILE.tmp" | sha512sum -c -
if [ $? -ne 0 ]; then
echo "Checksum verification failed for $URL"
rm -f "$CACHEFILE.tmp"
exit 1
fi
fi
mv -f "$CACHEFILE.tmp" "$CACHEFILE"
fi
if [ "$FILE" == "-" ]; then
cat "$CACHEFILE"
else
cp "$CACHEFILE" "$FILE"
fi

View File

@ -6,13 +6,16 @@ cd "$HOME"
mkdir pkgs mkdir pkgs
cd pkgs cd pkgs
git clone --recurse-submodules https://github.com/google/bloaty git clone --depth=1 --recurse-submodules --shallow-submodules https://github.com/google/bloaty
cd bloaty cd bloaty
mkdir build mkdir build
cd build cd build
export PATH="/usr/lib/ccache/bin:$PATH"
cmake .. -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local cmake .. -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local
ninja ninja
ccache -s
ninja install ninja install
cd "$HOME" cd "$HOME"

View File

@ -1,87 +0,0 @@
#!/bin/bash
set -ex
cd "$HOME"
mkdir pkgs
cd pkgs
GCC_VERSION=14.2.0
ARCH="$(uname -m)"
wget https://ftp.gwdg.de/pub/misc/gcc/releases/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.xz
tar xf gcc-${GCC_VERSION}.tar.xz
cd gcc-${GCC_VERSION}
for p in 0001-posix_memalign.patch \
0002-gcc-poison-system-directories.patch \
0003-specs-turn-on-Wl-z-now-by-default.patch \
0004-Turn-on-D_FORTIFY_SOURCE-2-by-default-for-C-C-ObjC-O.patch \
0005-On-linux-targets-pass-as-needed-by-default-to-the-li.patch \
0006-Enable-Wformat-and-Wformat-security-by-default.patch \
0007-Enable-Wtrampolines-by-default.patch \
0008-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch \
0009-Ensure-that-msgfmt-doesn-t-encounter-problems-during.patch \
0010-Don-t-declare-asprintf-if-defined-as-a-macro.patch \
0011-libiberty-copy-PIC-objects-during-build-process.patch \
0012-libgcc_s.patch \
0013-nopie.patch \
0014-ada-fix-shared-linking.patch \
0015-build-fix-CXXFLAGS_FOR_BUILD-passing.patch \
0016-add-fortify-headers-paths.patch \
0017-Alpine-musl-package-provides-libssp_nonshared.a.-We-.patch \
0018-DP-Use-push-state-pop-state-for-gold-as-well-when-li.patch \
0019-aarch64-disable-multilib-support.patch \
0020-s390x-disable-multilib-support.patch \
0021-ppc64-le-disable-multilib-support.patch \
0022-x86_64-disable-multilib-support.patch \
0023-riscv-disable-multilib-support.patch \
0024-always-build-libgcc_eh.a.patch \
0025-ada-libgnarl-compatibility-for-musl.patch \
0026-ada-musl-support-fixes.patch \
0027-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch \
0028-configure-fix-detection-of-atomic-builtins-in-libato.patch \
0029-libstdc-do-not-throw-exceptions-for-non-C-locales-on.patch \
0030-gdc-unconditionally-link-libgphobos-against-libucont.patch \
0031-druntime-link-against-libucontext-on-all-platforms.patch \
0032-libgnat-time_t-is-always-64-bit-on-musl-libc.patch \
0033-libphobos-do-not-use-LFS64-symbols.patch \
0034-libgo-fix-lfs64-use.patch \
0035-loongarch-disable-multilib-support.patch \
0036-libphobos-add-riscv64-and-loongarch64-support.patch \
fix-arm64.patch \
ppc64le-quadmath.patch \
riscv64-improve-build-time.patch; do
curl https://gitlab.alpinelinux.org/alpine/aports/-/raw/3.21-stable/main/gcc/$p | patch -p1
done
curl https://gcc.gnu.org/pipermail/gcc-patches/attachments/20250220/c6211b02/attachment.bin | patch -p1
# for opt in s 2; do
for opt in s; do
cd "${HOME}"/pkgs
mkdir gcc-${GCC_VERSION}-build-O${opt}
cd gcc-${GCC_VERSION}-build-O${opt}
export CFLAGS="-O${opt} -ffunction-sections -fdata-sections -fmerge-all-constants -fPIC"
export CXXFLAGS="-O${opt} -ffunction-sections -fdata-sections -fmerge-all-constants -fPIC"
export LDFLAGS="-Wl,--gc-sections"
INSTALLDIR=/opt/static-libs/libstdc++-O${opt}
case "$ARCH" in
aarch64)
_arch_config="--with-arch=armv8-a --with-abi=lp64"
;;
esac
"$HOME"/pkgs/gcc-${GCC_VERSION}/configure --prefix=${INSTALLDIR} --libdir=${INSTALLDIR}/lib \
--disable-shared --enable-tls --disable-libstdcxx-pch --disable-multilib --disable-nls --disable-werror --disable-symvers \
--enable-threads --enable-__cxa_atexit --enable-languages=c,c++ --enable-link-serialization=2 --enable-linker-build-id \
--disable-libssp --disable-libsanitizer --with-system-zlib --enable-checking=release --disable-cet --disable-fixed-point \
--enable-default-pie --enable-default-ssp --with-linker-hash-style=gnu ${_arch_config}
make -j"$(nproc)"
make install
done
cd "$HOME"
rm -rf pkgs

View File

@ -6,14 +6,16 @@ cd "$HOME"
mkdir pkgs mkdir pkgs
cd pkgs cd pkgs
MOLD_VERSION=2.37.1 MOLD_VERSION=2.40.2
wget -O mold-${MOLD_VERSION}.tar.gz https://github.com/rui314/mold/archive/refs/tags/v${MOLD_VERSION}.tar.gz fetch.sh https://github.com/rui314/mold/archive/refs/tags/v${MOLD_VERSION}.tar.gz mold-${MOLD_VERSION}.tar.gz
tar xf mold-${MOLD_VERSION}.tar.gz tar xf mold-${MOLD_VERSION}.tar.gz
cd mold-${MOLD_VERSION} cd mold-${MOLD_VERSION}
mkdir build mkdir build
cd build cd build
export PATH="/usr/lib/ccache/bin:$PATH"
cmake .. -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local cmake .. -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local
ninja ninja
ninja install ninja install

View File

@ -6,18 +6,20 @@ cd "$HOME"
mkdir pkgs mkdir pkgs
cd pkgs cd pkgs
GCC="${1:-gcc}"
CLANG="${2:-clang}"
PKGS="${3:-:none}"
ARCH="$(uname -m)" ARCH="$(uname -m)"
GCC="gcc"
CLANG="clang-20"
PKGS="$1"
TARGET_ARCH_STR="${2:-${ARCH}}"
FILE_VERSION=5.46 FILE_VERSION=5.46
FILE_SHA512=a6cb7325c49fd4af159b7555bdd38149e48a5097207acbe5e36deb5b7493ad6ea94d703da6e0edece5bb32959581741f4213707e5cb0528cd46d75a97a5242dc FILE_SHA512=a6cb7325c49fd4af159b7555bdd38149e48a5097207acbe5e36deb5b7493ad6ea94d703da6e0edece5bb32959581741f4213707e5cb0528cd46d75a97a5242dc
BZIP2_VERSION=1.0.8 BZIP2_VERSION=1.0.8
LIBARCHIVE_VERSION=3.8.1 # 2025-06-01 LIBARCHIVE_VERSION=3.8.1 # 2025-06-01
FLAC_VERSION=1.5.0 # 2025-02-11 FLAC_VERSION=1.5.0 # 2025-02-11
LIBUCONTEXT_VERSION=1.3.2 # 2024-10-07
LIBUNWIND_VERSION=1.8.2 # 2025-05-22 LIBUNWIND_VERSION=1.8.2 # 2025-05-22
BENCHMARK_VERSION=1.9.4 # 2025-05-19 BENCHMARK_VERSION=1.9.4 # 2025-05-19
BOOST_VERSION=1.88.0 # 2025-04-11 BOOST_VERSION=1.88.0 # 2025-04-11
@ -31,42 +33,38 @@ XXHASH_VERSION=0.8.3 # 2024-12-30
LZ4_VERSION=1.10.0 # 2024-07-22 LZ4_VERSION=1.10.0 # 2024-07-22
BROTLI_VERSION=1.1.0 # 2023-08-31 BROTLI_VERSION=1.1.0 # 2023-08-31
ZSTD_VERSION=1.5.7 # 2025-02-19 ZSTD_VERSION=1.5.7 # 2025-02-19
LIBFUSE_VERSION=3.17.2 # 2025-04-23 LIBFUSE_VERSION=2.9.9 # 2019-01-04
LIBFUSE3_VERSION=3.17.3 # 2025-07-19
MIMALLOC_VERSION=2.1.7 # 2024-05-21 MIMALLOC_VERSION=2.1.7 # 2024-05-21
JEMALLOC_VERSION=5.3.0 # 2022-05-02 JEMALLOC_VERSION=5.3.0 # 2022-05-02
XZ_VERSION=5.8.1 # 2025-04-03 XZ_VERSION=5.8.1 # 2025-04-03
LIBDWARF_VERSION=2.1.0 # 2025-07-19
LIBEVENT_VERSION=2.1.12 # 2020-07-05
NLOHMANN_VERSION=3.12.0 # 2025-04-07
DATE_VERSION=3.0.4 # 2025-05-28
UTFCPP_VERSION=4.0.6 # 2024-11-03
RANGE_V3_VERSION=0.12.0 # 2022-06-21
PARALLEL_HASHMAP_VERSION=2.0.0 # 2025-01-21
echo "Using $GCC and $CLANG" echo "Using $GCC and $CLANG"
if [[ "$PKGS" == ":ubuntu" ]]; then if [[ "$PKGS" == ":none" ]]; then
PKGS="file,bzip2,libarchive,flac,libunwind,benchmark,openssl,cpptrace"
COMPILERS="clang gcc"
elif [[ "$PKGS" == ":alpine"* ]]; then
if [[ "$PKGS" == ":alpine" ]]; then
PKGS="benchmark,boost,brotli,cpptrace,double-conversion,flac,fmt,fuse,glog,jemalloc,libarchive,libunwind,libressl,lz4,mimalloc,openssl,xxhash,xz,zstd"
else
PKGS="${PKGS#:alpine:}"
fi
export COMMON_CFLAGS="-ffunction-sections -fdata-sections -fmerge-all-constants"
export COMMON_CXXFLAGS="$COMMON_CFLAGS"
export COMMON_LDFLAGS="-fuse-ld=mold"
# COMPILERS="clang clang-lto clang-minsize-lto gcc"
if [[ "$ARCH" != "x86_64" && "$ARCH" != "aarch64" ]]; then
# Let's keep it simple for more exotic architectures
COMPILERS="clang-minsize-lto"
else
COMPILERS="clang clang-minsize-lto gcc"
fi
elif [[ "$PKGS" == ":none" ]]; then
echo "No libraries to build" echo "No libraries to build"
exit 0 exit 0
elif [[ "$PKGS" == ":all" ]]; then
PKGS="benchmark,boost,brotli,cpptrace,date,double-conversion,flac,fmt,fuse,fuse3,glog,jemalloc,libarchive,libdwarf,libevent,libucontext,libunwind,libressl,lz4,mimalloc,nlohmann,openssl,parallel-hashmap,range-v3,utfcpp,xxhash,xz,zstd"
fi fi
export COMMON_CFLAGS="-ffunction-sections -fdata-sections -fmerge-all-constants"
export COMMON_CXXFLAGS="$COMMON_CFLAGS"
export COMMON_LDFLAGS="-static-libgcc"
FILE_TARBALL="file-${FILE_VERSION}.tar.gz" FILE_TARBALL="file-${FILE_VERSION}.tar.gz"
BZIP2_TARBALL="bzip2-${BZIP2_VERSION}.tar.gz" BZIP2_TARBALL="bzip2-${BZIP2_VERSION}.tar.gz"
BOOST_TARBALL="boost-${BOOST_VERSION}.tar.xz" BOOST_TARBALL="boost-${BOOST_VERSION}.tar.xz"
LIBARCHIVE_TARBALL="libarchive-${LIBARCHIVE_VERSION}.tar.xz" LIBARCHIVE_TARBALL="libarchive-${LIBARCHIVE_VERSION}.tar.xz"
FLAC_TARBALL="flac-${FLAC_VERSION}.tar.xz" FLAC_TARBALL="flac-${FLAC_VERSION}.tar.xz"
LIBUCONTEXT_TARBALL="libucontext-${LIBUCONTEXT_VERSION}.tar.gz"
LIBUNWIND_TARBALL="libunwind-${LIBUNWIND_VERSION}.tar.gz" LIBUNWIND_TARBALL="libunwind-${LIBUNWIND_VERSION}.tar.gz"
BENCHMARK_TARBALL="benchmark-${BENCHMARK_VERSION}.tar.gz" BENCHMARK_TARBALL="benchmark-${BENCHMARK_VERSION}.tar.gz"
OPENSSL_TARBALL="openssl-${OPENSSL_VERSION}.tar.gz" OPENSSL_TARBALL="openssl-${OPENSSL_VERSION}.tar.gz"
@ -80,12 +78,35 @@ LZ4_TARBALL="lz4-${LZ4_VERSION}.tar.gz"
BROTLI_TARBALL="brotli-${BROTLI_VERSION}.tar.gz" BROTLI_TARBALL="brotli-${BROTLI_VERSION}.tar.gz"
ZSTD_TARBALL="zstd-${ZSTD_VERSION}.tar.gz" ZSTD_TARBALL="zstd-${ZSTD_VERSION}.tar.gz"
LIBFUSE_TARBALL="fuse-${LIBFUSE_VERSION}.tar.gz" LIBFUSE_TARBALL="fuse-${LIBFUSE_VERSION}.tar.gz"
LIBFUSE3_TARBALL="fuse-${LIBFUSE3_VERSION}.tar.gz"
MIMALLOC_TARBALL="mimalloc-${MIMALLOC_VERSION}.tar.gz" MIMALLOC_TARBALL="mimalloc-${MIMALLOC_VERSION}.tar.gz"
JEMALLOC_TARBALL="jemalloc-${JEMALLOC_VERSION}.tar.bz2" JEMALLOC_TARBALL="jemalloc-${JEMALLOC_VERSION}.tar.bz2"
XZ_TARBALL="xz-${XZ_VERSION}.tar.xz" XZ_TARBALL="xz-${XZ_VERSION}.tar.xz"
LIBDWARF_TARBALL="libdwarf-${LIBDWARF_VERSION}.tar.xz"
LIBEVENT_TARBALL="libevent-${LIBEVENT_VERSION}-stable.tar.gz"
DATE_TARBALL="date-${DATE_VERSION}.tar.gz"
UTFCPP_TARBALL="utfcpp-${UTFCPP_VERSION}.tar.gz"
RANGE_V3_TARBALL="range-v3-${RANGE_V3_VERSION}.tar.gz"
PARALLEL_HASHMAP_TARBALL="parallel-hashmap-${PARALLEL_HASHMAP_VERSION}.tar.gz"
use_lib() { use_lib() {
local lib="$1" local lib="$1"
case "$CARCH" in
ppc64le|arm)
case "$lib" in
libunwind|libdwarf|cpptrace)
return 1
;;
esac
;;
s390x)
case "$lib" in
libunwind|libdwarf|cpptrace|libressl)
return 1
;;
esac
;;
esac
if [[ ",$PKGS," == *",$lib,"* ]]; then if [[ ",$PKGS," == *",$lib,"* ]]; then
return 0 return 0
else else
@ -96,9 +117,7 @@ use_lib() {
if use_lib file; then if use_lib file; then
RETRY=0 RETRY=0
while true; do while true; do
rm -f "$FILE_TARBALL" if fetch.sh "ftp://ftp.astron.com/pub/file/$FILE_TARBALL" "$FILE_TARBALL" "$FILE_SHA512"; then
curl -o "$FILE_TARBALL" "ftp://ftp.astron.com/pub/file/$FILE_TARBALL"
if echo "${FILE_SHA512} $FILE_TARBALL" | sha512sum -c; then
break break
fi fi
RETRY=$((RETRY+1)) RETRY=$((RETRY+1))
@ -114,7 +133,7 @@ fetch_lib() {
local url="$2" local url="$2"
local tarball="${3:-${url##*/}}" local tarball="${3:-${url##*/}}"
if use_lib "$lib"; then if use_lib "$lib"; then
wget -O "$tarball" "$url" fetch.sh "$url" "$tarball"
fi fi
} }
@ -122,6 +141,7 @@ fetch_lib bzip2 https://sourceware.org/pub/bzip2/${BZIP2_TARBALL}
fetch_lib boost https://github.com/boostorg/boost/releases/download/boost-${BOOST_VERSION}/boost-${BOOST_VERSION}-cmake.tar.xz ${BOOST_TARBALL} fetch_lib boost https://github.com/boostorg/boost/releases/download/boost-${BOOST_VERSION}/boost-${BOOST_VERSION}-cmake.tar.xz ${BOOST_TARBALL}
fetch_lib libarchive https://github.com/libarchive/libarchive/releases/download/v${LIBARCHIVE_VERSION}/${LIBARCHIVE_TARBALL} fetch_lib libarchive https://github.com/libarchive/libarchive/releases/download/v${LIBARCHIVE_VERSION}/${LIBARCHIVE_TARBALL}
fetch_lib flac https://github.com/xiph/flac/releases/download/${FLAC_VERSION}/${FLAC_TARBALL} fetch_lib flac https://github.com/xiph/flac/releases/download/${FLAC_VERSION}/${FLAC_TARBALL}
fetch_lib libucontext https://github.com/kaniini/libucontext/archive/refs/tags/${LIBUCONTEXT_TARBALL}
fetch_lib libunwind https://github.com/libunwind/libunwind/releases/download/v${LIBUNWIND_VERSION}/${LIBUNWIND_TARBALL} fetch_lib libunwind https://github.com/libunwind/libunwind/releases/download/v${LIBUNWIND_VERSION}/${LIBUNWIND_TARBALL}
fetch_lib benchmark https://github.com/google/benchmark/archive/refs/tags/v${BENCHMARK_VERSION}.tar.gz ${BENCHMARK_TARBALL} fetch_lib benchmark https://github.com/google/benchmark/archive/refs/tags/v${BENCHMARK_VERSION}.tar.gz ${BENCHMARK_TARBALL}
fetch_lib openssl https://github.com/openssl/openssl/releases/download/openssl-${OPENSSL_VERSION}/${OPENSSL_TARBALL} fetch_lib openssl https://github.com/openssl/openssl/releases/download/openssl-${OPENSSL_VERSION}/${OPENSSL_TARBALL}
@ -135,9 +155,17 @@ fetch_lib lz4 https://github.com/lz4/lz4/releases/download/v${LZ4_VERSION}/${LZ4
fetch_lib brotli https://github.com/google/brotli/archive/refs/tags/v${BROTLI_VERSION}.tar.gz ${BROTLI_TARBALL} fetch_lib brotli https://github.com/google/brotli/archive/refs/tags/v${BROTLI_VERSION}.tar.gz ${BROTLI_TARBALL}
fetch_lib zstd https://github.com/facebook/zstd/releases/download/v${ZSTD_VERSION}/${ZSTD_TARBALL} fetch_lib zstd https://github.com/facebook/zstd/releases/download/v${ZSTD_VERSION}/${ZSTD_TARBALL}
fetch_lib fuse https://github.com/libfuse/libfuse/releases/download/fuse-${LIBFUSE_VERSION}/${LIBFUSE_TARBALL} fetch_lib fuse https://github.com/libfuse/libfuse/releases/download/fuse-${LIBFUSE_VERSION}/${LIBFUSE_TARBALL}
fetch_lib fuse3 https://github.com/libfuse/libfuse/releases/download/fuse-${LIBFUSE3_VERSION}/${LIBFUSE3_TARBALL}
fetch_lib mimalloc https://github.com/microsoft/mimalloc/archive/refs/tags/v${MIMALLOC_VERSION}.tar.gz ${MIMALLOC_TARBALL} fetch_lib mimalloc https://github.com/microsoft/mimalloc/archive/refs/tags/v${MIMALLOC_VERSION}.tar.gz ${MIMALLOC_TARBALL}
fetch_lib jemalloc https://github.com/jemalloc/jemalloc/releases/download/${JEMALLOC_VERSION}/${JEMALLOC_TARBALL} fetch_lib jemalloc https://github.com/jemalloc/jemalloc/releases/download/${JEMALLOC_VERSION}/${JEMALLOC_TARBALL}
fetch_lib xz https://github.com/tukaani-project/xz/releases/download/v${XZ_VERSION}/${XZ_TARBALL} fetch_lib xz https://github.com/tukaani-project/xz/releases/download/v${XZ_VERSION}/${XZ_TARBALL}
fetch_lib libdwarf https://github.com/davea42/libdwarf-code/releases/download/v${LIBDWARF_VERSION}/${LIBDWARF_TARBALL}
fetch_lib libevent https://github.com/libevent/libevent/releases/download/release-${LIBEVENT_VERSION}-stable/${LIBEVENT_TARBALL}
fetch_lib nlohmann https://github.com/nlohmann/json/releases/download/v${NLOHMANN_VERSION}/json.hpp
fetch_lib date https://github.com/HowardHinnant/date/archive/refs/tags/v${DATE_VERSION}.tar.gz ${DATE_TARBALL}
fetch_lib utfcpp https://github.com/nemtrif/utfcpp/archive/refs/tags/v${UTFCPP_VERSION}.tar.gz ${UTFCPP_TARBALL}
fetch_lib range-v3 https://github.com/ericniebler/range-v3/archive/refs/tags/${RANGE_V3_VERSION}.tar.gz ${RANGE_V3_TARBALL}
fetch_lib parallel-hashmap https://github.com/greg7mdp/parallel-hashmap/archive/refs/tags/v${PARALLEL_HASHMAP_VERSION}.tar.gz ${PARALLEL_HASHMAP_TARBALL}
set_build_flags() { set_build_flags() {
if [[ $CFLAGS =~ ^[[:space:]]*$ ]]; then if [[ $CFLAGS =~ ^[[:space:]]*$ ]]; then
@ -166,34 +194,144 @@ set_build_flags() {
opt_size() { opt_size() {
export CFLAGS="$SIZE_CFLAGS" export CFLAGS="$SIZE_CFLAGS"
export CXXFLAGS="$SIZE_CXXFLAGS" export CXXFLAGS="$SIZE_CXXFLAGS"
export CPPFLAGS="$TARGET_FLAGS"
# export CMAKE_ARGS="-DCMAKE_BUILD_TYPE=MinSizeRel" # export CMAKE_ARGS="-DCMAKE_BUILD_TYPE=MinSizeRel"
export CMAKE_ARGS= export CMAKE_ARGS="-GNinja"
if [[ "$CARCH" != "$ARCH" ]]; then
export CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=$CARCH"
fi
set_build_flags set_build_flags
} }
opt_perf() { opt_perf() {
export CFLAGS="$PERF_CFLAGS" export CFLAGS="$PERF_CFLAGS"
export CXXFLAGS="$PERF_CXXFLAGS" export CXXFLAGS="$PERF_CXXFLAGS"
export CPPFLAGS="$TARGET_FLAGS"
# export CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release" # export CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release"
export CMAKE_ARGS= export CMAKE_ARGS="-GNinja"
if [[ "$CARCH" != "$ARCH" ]]; then
export CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=$CARCH"
fi
set_build_flags set_build_flags
} }
for target_arch in ${TARGET_ARCH_STR//,/ }; do
echo "==========================================================="
echo "Building for target architecture: $target_arch"
echo "==========================================================="
export CARCH="$target_arch"
rm -f /tmp/meson-$CARCH.txt
case "$CARCH" in
aarch64*) OPENSSL_TARGET_ARGS="linux-aarch64" ;;
arm*) OPENSSL_TARGET_ARGS="linux-armv4" ;;
mips64*) OPENSSL_TARGET_ARGS="linux64-mips64" ;;
ppc) OPENSSL_TARGET_ARGS="linux-ppc" ;;
ppc64) OPENSSL_TARGET_ARGS="linux-ppc64" ;;
ppc64le) OPENSSL_TARGET_ARGS="linux-ppc64le" ;;
i386) OPENSSL_TARGET_ARGS="linux-elf" ;;
s390x) OPENSSL_TARGET_ARGS="linux64-s390x" ;;
riscv64) OPENSSL_TARGET_ARGS="linux64-riscv64" ;;
loongarch64) OPENSSL_TARGET_ARGS="linux64-loongarch64" ;;
x86_64) OPENSSL_TARGET_ARGS="linux-x86_64" ;;
*) echo "Unable to determine architecture from (CARCH=$CARCH)"; exit 1 ;;
esac
BOOST_CONTEXT_ARCH="$CARCH"
case "$CARCH" in
aarch64*) BOOST_CONTEXT_ARCH="arm64" ;;
ppc64*) BOOST_CONTEXT_ARCH="ppc64" ;;
esac
export TARGET="${CARCH}-alpine-linux-musl"
case "$CARCH" in
arm) export TARGET="arm-linux-musleabihf" ;;
esac
export TRIPLETS="--host=$TARGET --target=$TARGET --build=$ARCH-alpine-linux-musl"
export BOOST_CMAKE_ARGS="-DBOOST_CONTEXT_ARCHITECTURE=$BOOST_CONTEXT_ARCH"
export LIBUCONTEXT_MAKE_ARGS="ARCH=$CARCH"
export MESON_CROSS_FILE="--cross-file=/tmp/meson-$CARCH.txt"
endian="little"
case "$CARCH" in
s390x|powerpc|powerpc64)
endian="big"
;;
esac
cat <<EOF > /tmp/meson-$CARCH.txt
[binaries]
c = '$TARGET-clang'
cpp = '$TARGET-clang++'
ld = '$TARGET-clang'
ar = '$TARGET-ar'
strip = '$TARGET-strip'
[host_machine]
system = 'linux'
cpu_family = '$CARCH'
cpu = '$CARCH'
endian = '$endian'
EOF
export SYSROOT="/opt/cross/O2"
export PATH="$SYSROOT/usr/lib/ccache/bin:$SYSROOT/usr/bin:$PATH"
export WORKROOT="$HOME/pkgs"
# COMPILERS="clang clang-lto clang-minsize-lto gcc"
case "$CARCH" in
# https://github.com/llvm/llvm-project/issues/150913
ppc64le)
COMPILERS="gcc"
;;
*)
if [[ "$ARCH" == "riscv64" ]]; then
# This is so slow natively, stick to the basics for now
COMPILERS="clang"
else
COMPILERS="clang clang-minsize-lto gcc"
fi
;;
esac
INSTALL_ROOT="/opt/static-libs"
for COMPILER in $COMPILERS; do for COMPILER in $COMPILERS; do
export SIZE_CFLAGS="$COMMON_CFLAGS" INSTALL_DIR="$INSTALL_ROOT/$COMPILER/$TARGET"
export SIZE_CXXFLAGS="$COMMON_CXXFLAGS" INSTALL_DIR_OPENSSL="$INSTALL_ROOT/$COMPILER-openssl/$TARGET"
export PERF_CFLAGS="$COMMON_CFLAGS" INSTALL_DIR_LIBRESSL="$INSTALL_ROOT/$COMPILER-libressl/$TARGET"
export PERF_CXXFLAGS="$COMMON_CXXFLAGS" WORKSUBDIR="$COMPILER/$TARGET"
export COMP_LDFLAGS="$COMMON_LDFLAGS" WORKDIR="$WORKROOT/$WORKSUBDIR"
export TARGET_FLAGS="--sysroot=$SYSROOT"
export SIZE_CFLAGS="$TARGET_FLAGS $COMMON_CFLAGS -isystem $INSTALL_DIR/include"
export SIZE_CXXFLAGS="$TARGET_FLAGS $COMMON_CXXFLAGS -isystem $INSTALL_DIR/include"
export PERF_CFLAGS="$TARGET_FLAGS $COMMON_CFLAGS -isystem $INSTALL_DIR/include"
export PERF_CXXFLAGS="$TARGET_FLAGS $COMMON_CXXFLAGS -isystem $INSTALL_DIR/include"
export COMP_LDFLAGS="$TARGET_FLAGS $COMMON_LDFLAGS -L$INSTALL_DIR/lib"
case "$CARCH" in
ppc64le)
# https://github.com/rui314/mold/issues/1490
export COMP_LDFLAGS="-fuse-ld=lld $COMP_LDFLAGS"
;;
*)
export COMP_LDFLAGS="-fuse-ld=mold $COMP_LDFLAGS"
;;
esac
case "$COMPILER" in case "$COMPILER" in
clang*) clang*)
export CC="$CLANG" export CC="$TARGET-clang"
export CXX="${CLANG/clang/clang++}" export CXX="$TARGET-clang++"
;; ;;
gcc*) gcc*)
export CC="$GCC" export CC="$TARGET-gcc"
export CXX="${GCC/gcc/g++}" export CXX="$TARGET-g++"
;; ;;
*) *)
echo "Unknown compiler: $COMPILER" echo "Unknown compiler: $COMPILER"
@ -218,103 +356,158 @@ for COMPILER in $COMPILERS; do
;; ;;
esac esac
cd "$HOME/pkgs" cd "$WORKROOT"
mkdir $COMPILER mkdir -p "$WORKSUBDIR"
INSTALL_DIR=/opt/static-libs/$COMPILER if use_lib libucontext; then
opt_size
cd "$WORKDIR"
mkdir libucontext-${LIBUCONTEXT_VERSION}
tar xf ${WORKROOT}/${LIBUCONTEXT_TARBALL} --strip-components=1 -C libucontext-${LIBUCONTEXT_VERSION}
cd libucontext-${LIBUCONTEXT_VERSION}
make -j$(nproc) ${LIBUCONTEXT_MAKE_ARGS}
make install ${LIBUCONTEXT_MAKE_ARGS} DESTDIR="$INSTALL_DIR" prefix=""
fi
if use_lib libunwind; then if use_lib libunwind; then
opt_size opt_size
cd "$HOME/pkgs/$COMPILER" cd "$WORKDIR"
tar xf ../${LIBUNWIND_TARBALL} tar xf ${WORKROOT}/${LIBUNWIND_TARBALL}
cd libunwind-${LIBUNWIND_VERSION} cd libunwind-${LIBUNWIND_VERSION}
LDFLAGS="$LDFLAGS -lucontext" CFLAGS="$CFLAGS -fno-stack-protector" ./configure \ fetch.sh https://gitlab.alpinelinux.org/alpine/aports/-/raw/master/main/libunwind/Remove-the-useless-endina.h-for-loongarch64.patch - | patch -p1
--prefix="$INSTALL_DIR" --enable-cxx-exceptions --disable-tests fetch.sh https://gitlab.alpinelinux.org/alpine/aports/-/raw/master/main/libunwind/fix-libunwind-pc-in.patch - | patch -p1
LDFLAGS="$LDFLAGS -lucontext" CFLAGS="$CFLAGS -fno-stack-protector" \
./configure ${TRIPLETS} --prefix="$INSTALL_DIR" --enable-cxx-exceptions --disable-tests --disable-shared
make -j$(nproc) make -j$(nproc)
make install make install
fi fi
if use_lib nlohmann; then
mkdir -p "$INSTALL_DIR/include/nlohmann"
cp "$HOME/pkgs/json.hpp" "$INSTALL_DIR/include/nlohmann/json.hpp"
fi
if use_lib date; then
opt_size
cd "$WORKDIR"
tar xf ${WORKROOT}/${DATE_TARBALL}
cd date-${DATE_VERSION}
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" ${CMAKE_ARGS}
ninja
ninja install
fi
if use_lib utfcpp; then
opt_size
cd "$WORKDIR"
tar xf ${WORKROOT}/${UTFCPP_TARBALL}
cd utfcpp-${UTFCPP_VERSION}
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" ${CMAKE_ARGS}
ninja
ninja install
fi
if use_lib boost; then if use_lib boost; then
opt_size opt_size
cd "$HOME/pkgs/$COMPILER" cd "$WORKDIR"
tar xf ../${BOOST_TARBALL} tar xf ${WORKROOT}/${BOOST_TARBALL}
cd boost-${BOOST_VERSION} cd boost-${BOOST_VERSION}
mkdir build mkdir build
cd build cd build
cmake .. -DBOOST_ENABLE_MPI=OFF -DBOOST_ENABLE_PYTHON=OFF -DBUILD_SHARED_LIBS=OFF \ cmake .. -DBOOST_ENABLE_MPI=OFF -DBOOST_ENABLE_PYTHON=OFF -DBUILD_SHARED_LIBS=OFF \
-DBOOST_IOSTREAMS_ENABLE_ZLIB=OFF -DBOOST_IOSTREAMS_ENABLE_BZIP2=OFF \ -DBOOST_IOSTREAMS_ENABLE_ZLIB=OFF -DBOOST_IOSTREAMS_ENABLE_BZIP2=OFF \
-DBOOST_IOSTREAMS_ENABLE_LZMA=OFF -DBOOST_IOSTREAMS_ENABLE_ZSTD=OFF \ -DBOOST_IOSTREAMS_ENABLE_LZMA=OFF -DBOOST_IOSTREAMS_ENABLE_ZSTD=OFF \
-DBOOST_EXCLUDE_LIBRARIES=stacktrace \ -DBOOST_CHARCONV_QUADMATH_FOUND_EXITCODE=0 \
-DBOOST_EXCLUDE_LIBRARIES=stacktrace ${BOOST_CMAKE_ARGS} \
-DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" ${CMAKE_ARGS} -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" ${CMAKE_ARGS}
make -j$(nproc) ninja
make install ninja install
fi fi
if use_lib jemalloc; then if use_lib jemalloc; then
opt_size opt_size
cd "$HOME/pkgs/$COMPILER" cd "$WORKDIR"
tar xf ../${JEMALLOC_TARBALL} tar xf ${WORKROOT}/${JEMALLOC_TARBALL}
cd jemalloc-${JEMALLOC_VERSION} cd jemalloc-${JEMALLOC_VERSION}
curl https://gitlab.alpinelinux.org/alpine/aports/-/raw/abc0b4170e42e2a7d835e4490ecbae49e6f3d137/main/jemalloc/musl-exception-specification-errors.patch | patch -p1 fetch.sh https://gitlab.alpinelinux.org/alpine/aports/-/raw/abc0b4170e42e2a7d835e4490ecbae49e6f3d137/main/jemalloc/musl-exception-specification-errors.patch - | patch -p1
curl https://gitlab.alpinelinux.org/alpine/aports/-/raw/abc0b4170e42e2a7d835e4490ecbae49e6f3d137/main/jemalloc/pkgconf.patch | patch -p1 fetch.sh https://gitlab.alpinelinux.org/alpine/aports/-/raw/abc0b4170e42e2a7d835e4490ecbae49e6f3d137/main/jemalloc/pkgconf.patch - | patch -p1
./autogen.sh ./autogen.sh ${TRIPLETS}
mkdir build-minimal mkdir build-minimal
cd build-minimal cd build-minimal
../configure --prefix="$INSTALL_DIR-jemalloc-minimal" --localstatedir=/var --sysconfdir=/etc --with-lg-hugepage=21 --disable-stats --disable-prof --enable-static --disable-shared --disable-log --disable-debug ../configure ${TRIPLETS} --prefix="$INSTALL_ROOT/$COMPILER-jemalloc-minimal/$TARGET" --localstatedir=/var --sysconfdir=/etc --with-lg-hugepage=21 \
--disable-stats --disable-prof --enable-static --disable-shared --disable-log --disable-debug
make -j$(nproc) make -j$(nproc)
make install make install
cd .. cd ..
mkdir build-full mkdir build-full
cd build-full cd build-full
../configure --prefix="$INSTALL_DIR-jemalloc-full" --localstatedir=/var --sysconfdir=/etc --with-lg-hugepage=21 --enable-stats --enable-prof --enable-static --disable-shared --disable-log --disable-debug ../configure ${TRIPLETS} --prefix="$INSTALL_ROOT/$COMPILER-jemalloc-full/$TARGET" --localstatedir=/var --sysconfdir=/etc --with-lg-hugepage=21 \
--enable-stats --enable-prof --enable-static --disable-shared --disable-log --disable-debug
make -j$(nproc) make -j$(nproc)
make install make install
fi fi
if use_lib mimalloc; then if use_lib mimalloc; then
opt_size opt_size
cd "$HOME/pkgs/$COMPILER" cd "$WORKDIR"
tar xf ../${MIMALLOC_TARBALL} tar xf ${WORKROOT}/${MIMALLOC_TARBALL}
cd mimalloc-${MIMALLOC_VERSION} cd mimalloc-${MIMALLOC_VERSION}
mkdir build mkdir build
cd build cd build
cmake .. -DMI_LIBC_MUSL=ON -DMI_BUILD_SHARED=OFF -DMI_BUILD_OBJECT=OFF -DMI_BUILD_TESTS=OFF -DMI_OPT_ARCH=OFF -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" ${CMAKE_ARGS} cmake .. -DMI_LIBC_MUSL=ON -DMI_BUILD_SHARED=OFF -DMI_BUILD_OBJECT=OFF -DMI_BUILD_TESTS=OFF -DMI_OPT_ARCH=OFF -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" ${CMAKE_ARGS}
make -j$(nproc) ninja
make install ninja install
fi fi
if use_lib double-conversion; then if use_lib double-conversion; then
opt_size opt_size
cd "$HOME/pkgs/$COMPILER" cd "$WORKDIR"
tar xf ../${DOUBLE_CONVERSION_TARBALL} tar xf ${WORKROOT}/${DOUBLE_CONVERSION_TARBALL}
cd double-conversion-${DOUBLE_CONVERSION_VERSION} cd double-conversion-${DOUBLE_CONVERSION_VERSION}
mkdir build mkdir build
cd build cd build
cmake .. -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" -DBUILD_SHARED_LIBS=OFF ${CMAKE_ARGS} cmake .. -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" -DBUILD_SHARED_LIBS=OFF ${CMAKE_ARGS}
make -j$(nproc) ninja
make install ninja install
fi fi
if use_lib fmt; then if use_lib fmt; then
opt_size opt_size
cd "$HOME/pkgs/$COMPILER" cd "$WORKDIR"
tar xf ../${FMT_TARBALL} tar xf ${WORKROOT}/${FMT_TARBALL}
cd fmt-${FMT_VERSION} cd fmt-${FMT_VERSION}
mkdir build mkdir build
cd build cd build
cmake .. -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" -DBUILD_SHARED_LIBS=OFF -DFMT_DOC=OFF -DFMT_TEST=OFF ${CMAKE_ARGS} cmake .. -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" -DBUILD_SHARED_LIBS=OFF -DFMT_DOC=OFF -DFMT_TEST=OFF ${CMAKE_ARGS}
make -j$(nproc) ninja
make install ninja install
fi fi
if use_lib fuse; then if use_lib fuse; then
opt_size opt_size
cd "$HOME/pkgs/$COMPILER" cd "$WORKDIR"
tar xf ../${LIBFUSE_TARBALL} tar xf ${WORKROOT}/${LIBFUSE_TARBALL}
cd fuse-${LIBFUSE_VERSION} cd fuse-${LIBFUSE_VERSION}
./configure ${TRIPLETS} --prefix="$INSTALL_DIR" \
--disable-shared --enable-static \
--disable-example --enable-lib --disable-util
make -j$(nproc)
make install
fi
if use_lib fuse3; then
opt_size
cd "$WORKDIR"
tar xf ${WORKROOT}/${LIBFUSE3_TARBALL}
cd fuse-${LIBFUSE3_VERSION}
mkdir build mkdir build
cd build cd build
meson setup .. --default-library=static --prefix="$INSTALL_DIR" meson setup .. --default-library=static --prefix="$INSTALL_DIR" $MESON_CROSS_FILE
# meson configure ${TRIPLETS} -D utils=false -D tests=false -D examples=false
meson configure -D utils=false -D tests=false -D examples=false meson configure -D utils=false -D tests=false -D examples=false
meson setup --reconfigure .. meson setup --reconfigure ..
ninja ninja
@ -323,32 +516,32 @@ for COMPILER in $COMPILERS; do
if use_lib glog; then if use_lib glog; then
opt_size opt_size
cd "$HOME/pkgs/$COMPILER" cd "$WORKDIR"
tar xf ../${GLOG_TARBALL} tar xf ${WORKROOT}/${GLOG_TARBALL}
cd glog-${GLOG_VERSION} cd glog-${GLOG_VERSION}
mkdir build mkdir build
cd build cd build
cmake .. -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF ${CMAKE_ARGS} cmake .. -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF ${CMAKE_ARGS}
make -j$(nproc) ninja
make install ninja install
fi fi
if use_lib benchmark; then if use_lib benchmark; then
opt_size opt_size
cd "$HOME/pkgs/$COMPILER" cd "$WORKDIR"
tar xf ../${BENCHMARK_TARBALL} tar xf ${WORKROOT}/${BENCHMARK_TARBALL}
cd benchmark-${BENCHMARK_VERSION} cd benchmark-${BENCHMARK_VERSION}
mkdir build mkdir build
cd build cd build
cmake .. -DBENCHMARK_ENABLE_TESTING=OFF -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" ${CMAKE_ARGS} cmake .. -DBENCHMARK_ENABLE_TESTING=OFF -DBENCHMARK_ENABLE_WERROR=OFF -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" ${CMAKE_ARGS}
make -j$(nproc) ninja
make install ninja install
fi fi
if use_lib xxhash; then if use_lib xxhash; then
opt_size opt_size
cd "$HOME/pkgs/$COMPILER" cd "$WORKDIR"
tar xf ../${XXHASH_TARBALL} tar xf ${WORKROOT}/${XXHASH_TARBALL}
cd xxHash-${XXHASH_VERSION} cd xxHash-${XXHASH_VERSION}
make -j$(nproc) make -j$(nproc)
make install PREFIX="$INSTALL_DIR" make install PREFIX="$INSTALL_DIR"
@ -356,8 +549,8 @@ for COMPILER in $COMPILERS; do
if use_lib bzip2; then if use_lib bzip2; then
opt_size opt_size
cd "$HOME/pkgs/$COMPILER" cd "$WORKDIR"
tar xf ../${BZIP2_TARBALL} tar xf ${WORKROOT}/${BZIP2_TARBALL}
cd bzip2-${BZIP2_VERSION} cd bzip2-${BZIP2_VERSION}
make -j$(nproc) make -j$(nproc)
make PREFIX="$INSTALL_DIR" install make PREFIX="$INSTALL_DIR" install
@ -365,47 +558,50 @@ for COMPILER in $COMPILERS; do
if use_lib brotli; then if use_lib brotli; then
opt_size opt_size
cd "$HOME/pkgs/$COMPILER" cd "$WORKDIR"
tar xf ../${BROTLI_TARBALL} tar xf ${WORKROOT}/${BROTLI_TARBALL}
cd brotli-${BROTLI_VERSION} cd brotli-${BROTLI_VERSION}
mkdir build mkdir build
cd build cd build
cmake .. -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" -DBUILD_SHARED_LIBS=OFF ${CMAKE_ARGS} cmake .. -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" -DBROTLI_BUILD_TOOLS=OFF -DBUILD_SHARED_LIBS=OFF ${CMAKE_ARGS}
make -j$(nproc) ninja
make install ninja install
fi fi
if use_lib lz4; then if use_lib lz4; then
opt_size opt_size
cd "$HOME/pkgs/$COMPILER" cd "$WORKDIR"
tar xf ../${LZ4_TARBALL} tar xf ${WORKROOT}/${LZ4_TARBALL}
cd lz4-${LZ4_VERSION}/build/cmake cd lz4-${LZ4_VERSION}/build/cmake
mkdir build mkdir build
cd build cd build
cmake .. -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" -DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_LIBS=ON ${CMAKE_ARGS} cmake .. -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" -DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_LIBS=ON ${CMAKE_ARGS}
make -j$(nproc) ninja
make install ninja install
fi fi
if use_lib xz; then if use_lib xz; then
opt_size opt_size
cd "$HOME/pkgs/$COMPILER" cd "$WORKDIR"
tar xf ../${XZ_TARBALL} tar xf ${WORKROOT}/${XZ_TARBALL}
cd xz-${XZ_VERSION} cd xz-${XZ_VERSION}
./configure --prefix="$INSTALL_DIR" --localstatedir=/var --sysconfdir=/etc --disable-rpath --disable-werror --disable-doc --disable-shared --disable-nls ./configure ${TRIPLETS} --prefix="$INSTALL_DIR" --localstatedir=/var --sysconfdir=/etc \
--disable-rpath --disable-werror --disable-doc --disable-shared --disable-nls \
--disable-xz --disable-xzdec --disable-lzmainfo --disable-lzmadec \
--disable-lzma-links --disable-scripts
make -j$(nproc) make -j$(nproc)
make install make install
fi fi
if use_lib zstd; then if use_lib zstd; then
opt_size opt_size
cd "$HOME/pkgs/$COMPILER" cd "$WORKDIR"
tar xf ../${ZSTD_TARBALL} tar xf ${WORKROOT}/${ZSTD_TARBALL}
cd zstd-${ZSTD_VERSION} cd zstd-${ZSTD_VERSION}
mkdir meson-build mkdir meson-build
cd meson-build cd meson-build
meson setup ../build/meson --default-library=static --prefix="$INSTALL_DIR" meson setup ../build/meson --default-library=static --prefix="$INSTALL_DIR" $MESON_CROSS_FILE
meson configure -D zlib=disabled -D lzma=disabled -D lz4=disabled meson configure -D bin_programs=false -D bin_contrib=false -D zlib=disabled -D lzma=disabled -D lz4=disabled
meson setup --reconfigure ../build/meson meson setup --reconfigure ../build/meson
ninja ninja
ninja install ninja install
@ -413,53 +609,81 @@ for COMPILER in $COMPILERS; do
if use_lib openssl; then if use_lib openssl; then
opt_size opt_size
cd "$HOME/pkgs/$COMPILER" cd "$WORKDIR"
tar xf ../${OPENSSL_TARBALL} tar xf ${WORKROOT}/${OPENSSL_TARBALL}
cd openssl-${OPENSSL_VERSION} cd openssl-${OPENSSL_VERSION}
./Configure --prefix="$INSTALL_DIR-openssl" --libdir=lib threads no-fips no-shared no-pic no-dso no-aria no-async no-atexit \ ./Configure ${OPENSSL_TARGET_ARGS} --prefix="$INSTALL_DIR_OPENSSL" --libdir=lib \
threads no-fips no-shared no-pic no-dso no-aria no-async no-atexit \
no-autoload-config no-blake2 no-bf no-camellia no-cast no-chacha no-cmac no-cms no-cmp no-comp no-ct no-des \ no-autoload-config no-blake2 no-bf no-camellia no-cast no-chacha no-cmac no-cms no-cmp no-comp no-ct no-des \
no-dgram no-dh no-dsa no-ec no-engine no-filenames no-idea no-ktls no-md4 no-multiblock \ no-dgram no-dh no-dsa no-ec no-engine no-filenames no-idea no-ktls no-md4 no-multiblock \
no-nextprotoneg no-ocsp no-ocb no-poly1305 no-psk no-rc2 no-rc4 no-seed no-siphash no-siv no-sm3 no-sm4 \ no-nextprotoneg no-ocsp no-ocb no-poly1305 no-psk no-rc2 no-rc4 no-seed no-siphash no-siv no-sm3 no-sm4 \
no-srp no-srtp no-ssl3-method no-ssl-trace no-tfo no-ts no-ui-console no-whirlpool no-fips-securitychecks \ no-srp no-srtp no-ssl3-method no-ssl-trace no-tfo no-ts no-ui-console no-whirlpool no-fips-securitychecks \
no-tests no-docs no-tests no-docs
make -j$(nproc) make -j$(nproc) build_libs
make install_sw make install_dev
fi fi
if use_lib libressl; then if use_lib libressl; then
opt_size opt_size
cd "$HOME/pkgs/$COMPILER" cd "$WORKDIR"
tar xf ../${LIBRESSL_TARBALL} tar xf ${WORKROOT}/${LIBRESSL_TARBALL}
cd libressl-${LIBRESSL_VERSION} cd libressl-${LIBRESSL_VERSION}
./configure --prefix="$INSTALL_DIR-libressl" --enable-static --disable-shared --disable-tests mkdir build
make -j$(nproc) cd build
make install cmake .. -DCMAKE_PREFIX_PATH="$INSTALL_DIR" -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR_LIBRESSL" \
-DBUILD_SHARED_LIBS=OFF -DLIBRESSL_APPS=OFF -DLIBRESSL_TESTS=OFF \
${CMAKE_ARGS}
ninja
ninja install
fi
if use_lib libevent; then
opt_size
cd "$WORKDIR"
tar xf ${WORKROOT}/${LIBEVENT_TARBALL}
cd libevent-${LIBEVENT_VERSION}-stable
fetch.sh https://github.com/libevent/libevent/commit/883630f76cbf512003b81de25cd96cb75c6cf0f9.diff - | patch -p1
mkdir build
cd build
cmake .. -DCMAKE_PREFIX_PATH="$INSTALL_DIR" -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" ${CMAKE_ARGS} \
-DEVENT__DISABLE_DEBUG_MODE=ON -DEVENT__DISABLE_THREAD_SUPPORT=ON -DEVENT__DISABLE_OPENSSL=ON \
-DEVENT__DISABLE_MBEDTLS=ON -DEVENT__DISABLE_BENCHMARK=ON -DEVENT__DISABLE_TESTS=ON \
-DEVENT__DISABLE_REGRESS=ON -DEVENT__DISABLE_SAMPLES=ON -DEVENT__LIBRARY_TYPE=STATIC
ninja
ninja install
fi
SSL_PREFIXES=""
if [ -d "$INSTALL_DIR_OPENSSL" ]; then
SSL_PREFIXES="$SSL_PREFIXES $INSTALL_DIR_OPENSSL"
fi
if [ -d "$INSTALL_DIR_LIBRESSL" ]; then
SSL_PREFIXES="$SSL_PREFIXES $INSTALL_DIR_LIBRESSL"
fi
if [[ -z "$SSL_PREFIXES" ]]; then
SSL_PREFIXES="$INSTALL_DIR"
fi fi
if use_lib libarchive; then if use_lib libarchive; then
unset LIBARCHIVE_PREFIXES for prefix in $SSL_PREFIXES; do
if use_lib openssl; then sslsuffix=""
LIBARCHIVE_PREFIXES="$LIBARCHIVE_PREFIXES $INSTALL_DIR-openssl" if [[ "$prefix" == *libressl* ]]; then
sslsuffix="-libressl"
elif [[ "$prefix" == *openssl* ]]; then
sslsuffix="-openssl"
fi fi
if use_lib libressl; then
LIBARCHIVE_PREFIXES="$LIBARCHIVE_PREFIXES $INSTALL_DIR-libressl"
fi
if [[ -z "$LIBARCHIVE_PREFIXES" ]]; then
LIBARCHIVE_PREFIXES="$INSTALL_DIR"
fi
for prefix in $LIBARCHIVE_PREFIXES; do
opt_size opt_size
cd "$HOME/pkgs/$COMPILER" # This is safe because `opt_size` will re-initialize CFLAGS, CPPFLAGS, and LDFLAGS
rm -rf libarchive-${LIBARCHIVE_VERSION}
tar xf ../${LIBARCHIVE_TARBALL}
cd libarchive-${LIBARCHIVE_VERSION}
# TODO: once DwarFS supports ACLs / xattrs, we need to update this
export CFLAGS="-I$prefix/include $CFLAGS" export CFLAGS="-I$prefix/include $CFLAGS"
export CPPFLAGS="-I$prefix/include $CPPFLAGS" export CPPFLAGS="-I$prefix/include $CPPFLAGS"
export LDFLAGS="-L$prefix/lib $LDFLAGS" export LDFLAGS="-L$prefix/lib $LDFLAGS -latomic"
./configure --prefix="$prefix" \ cd "$WORKDIR"
rm -rf libarchive-${LIBARCHIVE_VERSION}
tar xf ${WORKROOT}/${LIBARCHIVE_TARBALL}
cd libarchive-${LIBARCHIVE_VERSION}
# TODO: once DwarFS supports ACLs / xattrs, we need to update this
./configure ${TRIPLETS} --prefix="$prefix" \
--without-iconv --without-xml2 --without-expat \ --without-iconv --without-xml2 --without-expat \
--without-bz2lib --without-zlib \ --without-bz2lib --without-zlib \
--disable-shared --disable-acl --disable-xattr \ --disable-shared --disable-acl --disable-xattr \
@ -472,37 +696,100 @@ for COMPILER in $COMPILERS; do
if use_lib file; then if use_lib file; then
opt_size opt_size
cd "$HOME/pkgs/$COMPILER" cd "$WORKDIR"
tar xf ../${FILE_TARBALL} tar xf ${WORKROOT}/${FILE_TARBALL}
cd file-${FILE_VERSION} cd file-${FILE_VERSION}
./configure --prefix="$INSTALL_DIR" --enable-static=yes --enable-shared=no ./configure ${TRIPLETS} --prefix="$INSTALL_DIR" --enable-static=yes --enable-shared=no
make -j$(nproc) make -j$(nproc)
make install make install
fi fi
if use_lib flac; then if use_lib flac; then
opt_perf opt_perf
cd "$HOME/pkgs/$COMPILER" cd "$WORKDIR"
tar xf ../${FLAC_TARBALL} tar xf ${WORKROOT}/${FLAC_TARBALL}
cd flac-${FLAC_VERSION} cd flac-${FLAC_VERSION}
./configure --prefix="$INSTALL_DIR" --enable-static=yes --enable-shared=no \ ./configure ${TRIPLETS} --prefix="$INSTALL_DIR" --enable-static=yes --enable-shared=no \
--disable-doxygen-docs --disable-ogg --disable-programs --disable-examples --disable-doxygen-docs --disable-ogg --disable-programs --disable-examples
make -j$(nproc) make -j$(nproc)
make install make install
fi fi
if use_lib cpptrace; then if use_lib libdwarf; then
for prefix in $SSL_PREFIXES; do
opt_size opt_size
cd "$HOME/pkgs/$COMPILER" # This is safe because `opt_size` will re-initialize CFLAGS, CPPFLAGS, and LDFLAGS
tar xf ../${CPPTRACE_TARBALL} export CFLAGS="-isystem $prefix/include $CFLAGS"
export CPPFLAGS="-isystem $prefix/include $CPPFLAGS"
export LDFLAGS="-L$prefix/lib $LDFLAGS"
cd "$WORKDIR"
rm -rf libdwarf-${LIBDWARF_VERSION}
tar xf ${WORKROOT}/${LIBDWARF_TARBALL}
cd libdwarf-${LIBDWARF_VERSION}
mkdir meson-build
cd meson-build
meson setup .. --default-library=static --prefix="$prefix" $MESON_CROSS_FILE
# meson configure
# meson setup --reconfigure ..
ninja
ninja install
done
fi
if use_lib cpptrace; then
for prefix in $SSL_PREFIXES; do
opt_size
# This is safe because `opt_size` will re-initialize CFLAGS, CPPFLAGS, and LDFLAGS
export CFLAGS="-isystem $prefix/include $CFLAGS"
export CPPFLAGS="-isystem $prefix/include $CPPFLAGS"
export LDFLAGS="-L$prefix/lib $LDFLAGS"
cd "$WORKDIR"
rm -rf cpptrace-${CPPTRACE_VERSION}
tar xf ${WORKROOT}/${CPPTRACE_TARBALL}
cd cpptrace-${CPPTRACE_VERSION} cd cpptrace-${CPPTRACE_VERSION}
mkdir build mkdir build
cd build cd build
cmake .. -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" ${CMAKE_ARGS} cmake .. -DCMAKE_PREFIX_PATH="$prefix;$INSTALL_DIR" -DCMAKE_INSTALL_PREFIX="$prefix" \
make -j$(nproc) -DCPPTRACE_USE_EXTERNAL_LIBDWARF=ON -DCPPTRACE_FIND_LIBDWARF_WITH_PKGCONFIG=ON \
make install -DCPPTRACE_UNWIND_WITH_LIBUNWIND=ON -DCPPTRACE_GET_SYMBOLS_WITH_LIBDWARF=ON \
${CMAKE_ARGS}
ninja
ninja install
done
fi fi
if use_lib range-v3; then
opt_size
cd "$WORKDIR"
tar xf ${WORKROOT}/${RANGE_V3_TARBALL}
cd range-v3-${RANGE_V3_VERSION}
mkdir build
cd build
cmake .. -DCMAKE_PREFIX_PATH="$INSTALL_DIR" -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" \
-DBUILD_SHARED_LIBS=OFF -DRANGE_V3_EXAMPLES=OFF -DRANGE_V3_TESTS=OFF \
-DRANGE_V3_DOCS=OFF -DRANGES_BUILD_CALENDAR_EXAMPLE=OFF \
-DRANGES_ENABLE_WERROR=OFF -DRANGES_NATIVE=OFF -DRANGES_DEBUG_INFO=OFF \
${CMAKE_ARGS}
ninja
ninja install
fi
if use_lib parallel-hashmap; then
opt_size
cd "$WORKDIR"
tar xf ${WORKROOT}/${PARALLEL_HASHMAP_TARBALL}
cd parallel-hashmap-${PARALLEL_HASHMAP_VERSION}
mkdir build
cd build
cmake .. -DCMAKE_PREFIX_PATH="$INSTALL_DIR" -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" \
-DBUILD_SHARED_LIBS=OFF -DPHMAP_BUILD_EXAMPLES=OFF -DPHMAP_BUILD_TESTS=OFF \
${CMAKE_ARGS}
ninja
ninja install
fi
done
done done
cd "$HOME" cd "$HOME"
rm -rf pkgs rm -rf pkgs
rm -f /tmp/meson-*.txt

View File

@ -0,0 +1,219 @@
#!/bin/bash
set -ex
ARCH="$(uname -m)"
OPTIMIZE_STR="${1:-2}"
TARGET_ARCH_STR="${2:-$ARCH}"
BINUTILS_VERSION=2.44
GCC_VERSION=14.2.0
MUSL_VERSION=1.2.5
LINUX_VERSION=6.15.7
BINUTILS_TARBALL=binutils-${BINUTILS_VERSION}.tar.xz
GCC_TARBALL=gcc-${GCC_VERSION}.tar.xz
MUSL_TARBALL=musl-${MUSL_VERSION}.tar.gz
LINUX_TARBALL=linux-${LINUX_VERSION}.tar.xz
cd "$HOME"
mkdir pkgs
cd pkgs
fetch.sh https://mirror.netcologne.de/gnu/binutils/${BINUTILS_TARBALL}
fetch.sh https://ftp.gwdg.de/pub/misc/gcc/releases/gcc-${GCC_VERSION}/${GCC_TARBALL}
fetch.sh https://www.musl-libc.org/releases/${MUSL_TARBALL}
fetch.sh https://cdn.kernel.org/pub/linux/kernel/v6.x/${LINUX_TARBALL}
tar xf ${BINUTILS_TARBALL}
tar xf ${GCC_TARBALL}
tar xf ${LINUX_TARBALL}
cd gcc-${GCC_VERSION}
for p in 0001-posix_memalign.patch \
0002-gcc-poison-system-directories.patch \
0003-specs-turn-on-Wl-z-now-by-default.patch \
0004-Turn-on-D_FORTIFY_SOURCE-2-by-default-for-C-C-ObjC-O.patch \
0005-On-linux-targets-pass-as-needed-by-default-to-the-li.patch \
0006-Enable-Wformat-and-Wformat-security-by-default.patch \
0007-Enable-Wtrampolines-by-default.patch \
0008-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch \
0009-Ensure-that-msgfmt-doesn-t-encounter-problems-during.patch \
0010-Don-t-declare-asprintf-if-defined-as-a-macro.patch \
0011-libiberty-copy-PIC-objects-during-build-process.patch \
0012-libgcc_s.patch \
0013-nopie.patch \
0014-ada-fix-shared-linking.patch \
0015-build-fix-CXXFLAGS_FOR_BUILD-passing.patch \
0016-add-fortify-headers-paths.patch \
0017-Alpine-musl-package-provides-libssp_nonshared.a.-We-.patch \
0018-DP-Use-push-state-pop-state-for-gold-as-well-when-li.patch \
0019-aarch64-disable-multilib-support.patch \
0020-s390x-disable-multilib-support.patch \
0021-ppc64-le-disable-multilib-support.patch \
0022-x86_64-disable-multilib-support.patch \
0023-riscv-disable-multilib-support.patch \
0024-always-build-libgcc_eh.a.patch \
0025-ada-libgnarl-compatibility-for-musl.patch \
0026-ada-musl-support-fixes.patch \
0027-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch \
0028-configure-fix-detection-of-atomic-builtins-in-libato.patch \
0029-libstdc-do-not-throw-exceptions-for-non-C-locales-on.patch \
0030-gdc-unconditionally-link-libgphobos-against-libucont.patch \
0031-druntime-link-against-libucontext-on-all-platforms.patch \
0032-libgnat-time_t-is-always-64-bit-on-musl-libc.patch \
0033-libphobos-do-not-use-LFS64-symbols.patch \
0034-libgo-fix-lfs64-use.patch \
0035-loongarch-disable-multilib-support.patch \
0036-libphobos-add-riscv64-and-loongarch64-support.patch \
fix-arm64.patch \
ppc64le-quadmath.patch \
riscv64-improve-build-time.patch; do
fetch.sh https://gitlab.alpinelinux.org/alpine/aports/-/raw/3.21-stable/main/gcc/$p - | patch -p1
done
fetch.sh https://gcc.gnu.org/pipermail/gcc-patches/attachments/20250220/c6211b02/attachment.bin - | patch -p1
ORIGPATH="$PATH"
export CC="/usr/bin/ccache /usr/bin/gcc"
export CXX="/usr/bin/ccache /usr/bin/g++"
export LD="/usr/bin/ld"
for target_arch in ${TARGET_ARCH_STR//,/ }; do
for OPT in ${OPTIMIZE_STR//,/ }; do
echo "==========================================================="
echo "Building for target architecture: $target_arch (-O${OPT})"
echo "==========================================================="
export TARGETARCH="$target_arch"
TARGET="${TARGETARCH}-alpine-linux-musl"
CARCH="$TARGETARCH"
case "$TARGETARCH" in
aarch64*) CARCH="arm64" ;;
arm*) CARCH="arm" ;;
mips*) CARCH="mips" ;;
s390*) CARCH="s390" ;;
ppc*) CARCH="powerpc" ;;
riscv*) CARCH="riscv" ;;
loongarch*) CARCH="loongarch" ;;
esac
case "$TARGETARCH" in
i386)
GCC_CONFIGURE_ARGS="--with-arch=i486 --with-tune=generic"
;;
aarch64*)
GCC_CONFIGURE_ARGS="--with-arch=armv8-a --with-abi=lp64"
;;
arm*)
GCC_CONFIGURE_ARGS="--with-arch=armv6 --with-fpu=vfp --with-float=hard"
TARGET="arm-linux-musleabihf"
;;
s390x)
GCC_CONFIGURE_ARGS="--with-arch=z10"
;;
*)
GCC_CONFIGURE_ARGS=""
;;
esac
export CFLAGS="-O${OPT} -ffunction-sections -fdata-sections -fmerge-all-constants -fPIC"
export CXXFLAGS="$CFLAGS"
export LDFLAGS="-Wl,--gc-sections"
SYSROOT="/opt/cross/O${OPT}"
PREFIX="$SYSROOT/usr"
PATH="$PREFIX/bin:$ORIGPATH"
GCC_NODOCS="MAKEINFO=/bin/true gcc_cv_prog_makeinfo_modern=no HELP2MAN=/bin/true TEXI2POD=/bin/true POD2MAN=/bin/true"
# Stage 1
cd "${HOME}"/pkgs
mkdir binutils-${BINUTILS_VERSION}-build-${TARGETARCH}-O${OPT}
cd binutils-${BINUTILS_VERSION}-build-${TARGETARCH}-O${OPT}
"$HOME"/pkgs/binutils-${BINUTILS_VERSION}/configure \
--target=$TARGET --program-prefix="$TARGET-" --prefix=$PREFIX --with-sysroot=$SYSROOT \
--disable-nls --disable-werror
make -j"$(nproc)"
make install
cd "$HOME"/pkgs/linux-${LINUX_VERSION}
make ARCH="$CARCH" INSTALL_HDR_PATH=$PREFIX/$TARGET headers_install
if [[ "$TARGETARCH" != "$ARCH" ]]; then
cd "$HOME"/pkgs
mkdir gcc-${GCC_VERSION}-build-${TARGETARCH}-O${OPT}-stage1
cd gcc-${GCC_VERSION}-build-${TARGETARCH}-O${OPT}-stage1
"$HOME"/pkgs/gcc-${GCC_VERSION}/configure \
--target=$TARGET --prefix=$PREFIX --with-sysroot=$SYSROOT --with-newlib --without-headers \
--disable-nls --disable-shared --disable-multilib --disable-decimal-float --disable-threads \
--disable-libatomic --disable-libgomp --disable-libquadmath --disable-libssp --disable-libvtv \
--disable-libstdcxx --enable-languages=c,c++ ${GCC_NODOCS}
make -j"$(nproc)" all-gcc ${GCC_NODOCS}
make -j"$(nproc)" all-target-libgcc ${GCC_NODOCS}
make install-gcc
make install-target-libgcc
MUSL_CC="${TARGET}-gcc"
else
MUSL_CC="gcc"
fi
cd "$HOME"/pkgs
rm -rf musl-${MUSL_VERSION}
tar xf ${MUSL_TARBALL}
cd musl-${MUSL_VERSION}
fetch.sh https://gitlab.alpinelinux.org/alpine/aports/-/raw/3.22-stable/main/musl/__stack_chk_fail_local.c
${MUSL_CC} $CFLAGS -c __stack_chk_fail_local.c -o __stack_chk_fail_local.o
${TARGET}-ar r libssp_nonshared.a __stack_chk_fail_local.o
./configure --prefix=$PREFIX/$TARGET --target=$TARGET CC=$MUSL_CC
make install-headers
make -j"$(nproc)"
make install
cp libssp_nonshared.a $PREFIX/$TARGET/lib/
if [[ "$TARGETARCH" == "$ARCH" ]]; then
# Fix for aarch64 build: rsync musl headers to native sysroot
rsync -av $PREFIX/$TARGET/include/ $PREFIX/include/
rsync -av $PREFIX/$TARGET/lib/ $PREFIX/lib/
fi
# Stage 2
cd "$HOME"/pkgs
mkdir gcc-${GCC_VERSION}-build-${TARGETARCH}-O${OPT}-final
cd gcc-${GCC_VERSION}-build-${TARGETARCH}-O${OPT}-final
"$HOME"/pkgs/gcc-${GCC_VERSION}/configure \
--target=$TARGET --prefix=$PREFIX --with-sysroot=$SYSROOT ${GCC_CONFIGURE_ARGS} \
--with-gmp=/usr --with-mpfr=/usr --with-mpc=/usr \
--disable-shared --enable-tls --disable-libstdcxx-pch --disable-multilib --disable-nls --disable-werror --disable-symvers \
--enable-threads --enable-__cxa_atexit --enable-languages=c,c++ --enable-link-serialization=2 --enable-linker-build-id \
--enable-libssp --disable-libsanitizer --enable-checking=release --disable-cet --disable-fixed-point \
--enable-libstdcxx-time=yes --enable-default-pie --enable-default-ssp --with-linker-hash-style=gnu ${GCC_NODOCS}
make -j"$(nproc)" ${GCC_NODOCS}
make install
# Directory for ccache symlinks
mkdir -p $PREFIX/lib/ccache/bin
# Symbolic links for clang
for clang_binary in /usr/bin/clang{++,}{-[1-9]*,}; do
name=$(basename $clang_binary)
ln -s $clang_binary $PREFIX/bin/$TARGET-$name
ln -s /usr/bin/ccache $PREFIX/lib/ccache/bin/$TARGET-$name
done
# Also provide ccache symlinks for gcc
for gcc_binary in $PREFIX/bin/$TARGET-{c++,g++,gcc,gcc-[1-9]*}; do
name=$(basename $gcc_binary)
ln -s /usr/bin/ccache $PREFIX/lib/ccache/bin/$name
done
done
done
cd "$HOME"
rm -rf pkgs

View File

@ -108,143 +108,222 @@ jobs:
strategy: strategy:
matrix: matrix:
arch:
- amd64
- arm64v8
dist:
- ubuntu
- fedora
- arch
build_type:
- gcc-debug-shared-ninja-full
- gcc-release-ninja-split
- gcc-release-shared-ninja-split
- clang-release-shared-ninja-full
exclude:
- arch: arm64v8
dist: arch
build_type: gcc-debug-shared-ninja-full
- arch: arm64v8
dist: arch
build_type: gcc-release-ninja-split
- arch: arm64v8
dist: arch
build_type: gcc-release-shared-ninja-split
- arch: arm64v8
dist: arch
build_type: clang-release-shared-ninja-full
- arch: arm64v8
dist: ubuntu
build_type: gcc-release-ninja-split
- arch: arm64v8
dist: ubuntu
build_type: gcc-release-shared-ninja-split
- arch: arm64v8
dist: fedora
build_type: gcc-release-ninja-split
- arch: arm64v8
dist: fedora
build_type: gcc-release-shared-ninja-split
include: include:
- arch: amd64 - build_arch: amd64
dist: debian build_dist: ubuntu
build_type: gcc-release-make-full build_type: gcc-release-ninja-split
- arch: amd64
dist: debian - build_arch: amd64
build_type: clang-debug-shared-ninja-split build_dist: ubuntu
- arch: amd64
dist: ubuntu
build_type: clang-reldbg-shared-asan-ninja
- arch: amd64
dist: ubuntu
build_type: clang-debug-shared-tsan-ninja
- arch: amd64
dist: ubuntu
build_type: clang-reldbg-shared-ubsan-ninja
- arch: amd64
dist: ubuntu
build_type: oldgcc-debug-shared-make-split
- arch: amd64
dist: ubuntu
build_type: gcc-debug-shared-noperfmon-ninja-split
- arch: amd64
dist: ubuntu
build_type: oldclang-debug-shared-make-split
- arch: amd64
dist: ubuntu-2204
build_type: gcc-release-shared-ninja-split build_type: gcc-release-shared-ninja-split
- arch: amd64
dist: ubuntu-2204 - build_arch: amd64
build_dist: ubuntu
build_type: gcc-debug-shared-ninja-full build_type: gcc-debug-shared-ninja-full
- arch: amd64
dist: ubuntu-2204 - build_arch: amd64
build_type: clang-release-ninja-split build_dist: ubuntu
- arch: amd64 build_type: gcc-debug-shared-noperfmon-ninja-split
dist: ubuntu
- build_arch: amd64
build_dist: ubuntu
build_type: clang-release-shared-ninja-full
- build_arch: amd64
build_dist: ubuntu
build_type: clang-reldbg-shared-asan-ninja
- build_arch: amd64
build_dist: ubuntu
build_type: clang-reldbg-shared-ubsan-ninja
- build_arch: amd64
build_dist: ubuntu
build_type: clang-debug-shared-tsan-ninja
- build_arch: amd64
build_dist: ubuntu
build_type: clang-debug-coverage-ninja build_type: clang-debug-coverage-ninja
- arch: amd64
dist: alpine - build_arch: amd64
build_dist: ubuntu
build_type: oldgcc-debug-shared-make-split
- build_arch: amd64
build_dist: ubuntu
build_type: oldclang-debug-shared-make-split
- build_arch: amd64
build_dist: ubuntu-2204
build_type: gcc-release-shared-ninja-split
- build_arch: amd64
build_dist: ubuntu-2204
build_type: gcc-debug-shared-ninja-full
- build_arch: amd64
build_dist: ubuntu-2204
build_type: clang-release-ninja-split
- build_arch: amd64
build_dist: fedora
build_type: gcc-release-ninja-split
- build_arch: amd64
build_dist: fedora
build_type: gcc-release-shared-ninja-split
- build_arch: amd64
build_dist: fedora
build_type: gcc-debug-shared-ninja-full
- build_arch: amd64
build_dist: fedora
build_type: clang-release-shared-ninja-full
- build_arch: amd64
build_dist: arch
build_type: gcc-release-ninja-split
- build_arch: amd64
build_dist: arch
build_type: gcc-release-shared-ninja-split
- build_arch: amd64
build_dist: arch
build_type: gcc-debug-shared-ninja-full
- build_arch: amd64
build_dist: arch
build_type: clang-release-shared-ninja-full
- build_arch: amd64
build_dist: debian
build_type: gcc-release-make-full
- build_arch: amd64
build_dist: debian
build_type: clang-debug-shared-ninja-split
- build_arch: amd64
build_dist: alpine
build_type: gcc-release-ninja-static build_type: gcc-release-ninja-static
- arch: arm64v8
dist: alpine - build_arch: amd64
build_type: gcc-release-ninja-static build_dist: alpine
- arch: amd64
dist: alpine
build_type: clang-release-ninja-static build_type: clang-release-ninja-static
- arch: arm64v8
dist: alpine - build_arch: amd64
build_type: clang-release-ninja-static build_dist: alpine
- arch: amd64
dist: alpine
build_type: clang-relsize-lto-ninja-static build_type: clang-relsize-lto-ninja-static
- arch: arm64v8
dist: alpine - build_arch: amd64
build_type: clang-relsize-lto-ninja-static build_dist: alpine
- arch: amd64
dist: alpine
build_type: clang-relsize-libressl-lto-ninja-static build_type: clang-relsize-libressl-lto-ninja-static
- arch: arm64v8
dist: alpine - build_arch: amd64
build_type: clang-relsize-libressl-lto-ninja-static build_dist: alpine
- arch: riscv64
dist: alpine
build_type: clang-relsize-libressl-lto-ninja-static
- arch: amd64
dist: alpine
build_type: clang-relsize-minimal-lto-ninja-static build_type: clang-relsize-minimal-lto-ninja-static
- arch: arm64v8
dist: alpine - build_arch: amd64
build_type: clang-relsize-minimal-lto-ninja-static build_dist: alpine
- arch: amd64
dist: alpine
build_type: clang-relsize-minimal-libressl-lto-ninja-static build_type: clang-relsize-minimal-libressl-lto-ninja-static
# - arch: arm64v8
# dist: alpine - build_arch: amd64
# build_type: clang-relsize-minimal-libressl-lto-ninja-static build_dist: alpine
- arch: amd64
dist: alpine
build_type: clang-relsize-minimal-mimalloc-lto-ninja-static build_type: clang-relsize-minimal-mimalloc-lto-ninja-static
- arch: arm64v8
dist: alpine - build_arch: amd64
build_type: clang-relsize-minimal-mimalloc-lto-ninja-static build_dist: alpine
- arch: amd64
dist: alpine
build_type: clang-relsize-minimal-mimalloc-libressl-lto-ninja-static build_type: clang-relsize-minimal-mimalloc-libressl-lto-ninja-static
# - arch: arm64v8
# dist: alpine - build_arch: amd64
# build_type: clang-relsize-minimal-mimalloc-libressl-lto-ninja-static build_dist: alpine
- arch: amd64
dist: alpine
build_type: clang-reldbg-stacktrace-ninja-static build_type: clang-reldbg-stacktrace-ninja-static
- arch: arm64v8
dist: alpine - build_arch: arm64v8
build_dist: ubuntu
build_type: gcc-debug-shared-ninja-full
- build_arch: arm64v8
build_dist: ubuntu
build_type: clang-release-shared-ninja-full
- build_arch: arm64v8
build_dist: fedora
build_type: gcc-debug-shared-ninja-full
- build_arch: arm64v8
build_dist: fedora
build_type: clang-release-shared-ninja-full
- build_arch: arm64v8
build_dist: alpine
build_type: gcc-release-ninja-static
- build_arch: arm64v8
build_dist: alpine
build_type: clang-release-ninja-static
- build_arch: arm64v8
build_dist: alpine
build_type: clang-relsize-lto-ninja-static
- build_arch: arm64v8
build_dist: alpine
build_type: clang-relsize-libressl-lto-ninja-static
- build_arch: arm64v8
build_dist: alpine
build_type: clang-relsize-minimal-lto-ninja-static
- build_arch: arm64v8
build_dist: alpine
build_type: clang-relsize-minimal-mimalloc-lto-ninja-static
- build_arch: arm64v8
build_dist: alpine
build_type: clang-reldbg-stacktrace-ninja-static build_type: clang-reldbg-stacktrace-ninja-static
- build_arch: riscv64
build_dist: debian
build_type: gcc-release-ninja-full
- build_arch: riscv64
build_dist: ubuntu
build_type: clang-debug-shared-ninja-split
- build_arch: amd64
build_dist: alpine
build_type: clang-relsize-libressl-lto-ninja-static
cross_arch: aarch64
- build_arch: amd64
build_dist: alpine
build_type: clang-relsize-libressl-lto-ninja-static
cross_arch: riscv64
- build_arch: amd64
build_dist: alpine
build_type: clang-relsize-libressl-lto-ninja-static
cross_arch: i386
- build_arch: amd64
build_dist: alpine
build_type: clang-relsize-libressl-lto-ninja-static
cross_arch: arm
- build_arch: amd64
build_dist: alpine
build_type: gcc-release-ninja-static
cross_arch: ppc64le
uses: ./.github/workflows/docker-run-build.yml uses: ./.github/workflows/docker-run-build.yml
with: with:
build_type: ${{ matrix.build_type }} build_type: ${{ matrix.build_type }}
build_arch: ${{ matrix.arch }} build_arch: ${{ matrix.build_arch }}
build_dist: ${{ matrix.dist }} build_dist: ${{ matrix.build_dist }}
cross_arch: ${{ matrix.cross_arch }}
build_from_tarball: true build_from_tarball: true
upload_coverage: ${{ matrix.build_type == 'clang-debug-coverage-ninja' }} upload_coverage: ${{ matrix.build_type == 'clang-debug-coverage-ninja' }}
upload_artifacts: ${{ endsWith(matrix.build_type, '-static') }} upload_artifacts: ${{ endsWith(matrix.build_type, '-static') }}

View File

@ -10,6 +10,10 @@ on:
build_arch: build_arch:
required: true required: true
type: string type: string
cross_arch:
required: false
type: string
default: ''
build_dist: build_dist:
required: true required: true
type: string type: string
@ -47,12 +51,15 @@ jobs:
fetch-depth: '0' fetch-depth: '0'
ref: ${{ github.ref }} ref: ${{ github.ref }}
# Only if inputs.build_arch is `amd64`, we want to build a cross-compiling
# container by setting TARGET_ARCHS. Otherwise, don't set TARGET_ARCHS.
- name: Build Docker Image - name: Build Docker Image
run: | run: |
docker build \ docker buildx build --progress=plain \
-f .docker/Dockerfile.${{ inputs.build_dist }} \ -f .docker/Dockerfile.${{ inputs.build_dist }} \
-t dwarfs-linux-build-${{ inputs.build_dist }} \ -t dwarfs-linux-build-${{ inputs.build_dist }} \
--build-arg ARCH=${{ inputs.build_arch }} \ --build-arg ARCH=${{ inputs.build_arch }} \
${{ inputs.build_arch == 'amd64' && '--build-arg TARGET_ARCHS=x86_64,aarch64,riscv64,ppc64le,s390x,arm,i386' || '' }} \
.docker .docker
- name: Run Build - name: Run Build
@ -67,6 +74,7 @@ jobs:
${{ inputs.build_from_tarball && '--env BUILD_FROM_TARBALL=1' || '' }} \ ${{ inputs.build_from_tarball && '--env BUILD_FROM_TARBALL=1' || '' }} \
--env BUILD_TYPE=${{ inputs.build_type }} \ --env BUILD_TYPE=${{ inputs.build_type }} \
--env BUILD_ARCH=${{ inputs.build_arch }} \ --env BUILD_ARCH=${{ inputs.build_arch }} \
--env CROSS_ARCH=${{ inputs.cross_arch }} \
--env BUILD_DIST=${{ inputs.build_dist }} \ --env BUILD_DIST=${{ inputs.build_dist }} \
--env GITHUB_REF_NAME \ --env GITHUB_REF_NAME \
--env GITHUB_REF_TYPE \ --env GITHUB_REF_TYPE \

View File

@ -136,10 +136,11 @@ def main():
if args.ninja and step.get("name") == "Run Build": if args.ninja and step.get("name") == "Run Build":
run_id = job.get("run_id", 0) run_id = job.get("run_id", 0)
# get arch, dist, config from "linux (arm64v8, alpine, clang-release-ninja-static) / docker-build" # get arch, dist, config from "linux (arm64v8, alpine, clang-release-ninja-static) / docker-build"
m = re.match(r"linux \(([^,]+), ([^,]+), ([^,]+)\)", name) m = re.match(r"linux \(([^,]+), ([^,]+), ([^,]+)(, ([^,]+))?\)", name)
if m: if m:
build_log_path = f"{args.log_base}/{run_id}/build-{m.group(1)},{m.group(2)},{m.group(3)}.log" cross = m.group(5) if m.group(5) else ""
ninja_log_path = f"{args.log_base}/{run_id}/ninja-{m.group(1)},{m.group(2)},{m.group(3)}.log" build_log_path = f"{args.log_base}/{run_id}/build-{m.group(1)},{cross},{m.group(2)},{m.group(3)}.log"
ninja_log_path = f"{args.log_base}/{run_id}/ninja-{m.group(1)},{cross},{m.group(2)},{m.group(3)}.log"
build_events = {} build_events = {}
if os.path.exists(build_log_path): if os.path.exists(build_log_path):
with open(build_log_path, "r") as f: with open(build_log_path, "r") as f:

View File

@ -140,17 +140,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules")
find_package(PkgConfig) find_package(PkgConfig)
if(STATIC_BUILD_DO_NOT_USE) if(STATIC_BUILD_DO_NOT_USE)
# Strangely this is needed when linking statically against FLAC++
#add_compile_options(-fno-omit-frame-pointer)
if(STATIC_BUILD_EXTRA_PREFIX)
foreach (prefix ${STATIC_BUILD_EXTRA_PREFIX})
include_directories(BEFORE ${prefix}/include)
endforeach()
list(PREPEND CMAKE_PREFIX_PATH ${STATIC_BUILD_EXTRA_PREFIX})
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON)
endif()
set(CMAKE_FIND_LIBRARY_SUFFIXES set(CMAKE_FIND_LIBRARY_SUFFIXES
".a" ".a"
CACHE STRING "please look for static libs") CACHE STRING "please look for static libs")
@ -991,7 +980,11 @@ if(STATIC_BUILD_DO_NOT_USE OR APPLE)
if(APPLE) if(APPLE)
add_custom_target(strip COMMAND strip ${FILES_TO_STRIP}) add_custom_target(strip COMMAND strip ${FILES_TO_STRIP})
else() else()
add_custom_target(strip COMMAND strip $<IF:$<BOOL:${ENABLE_STACKTRACE}>,--strip-debug,--strip-all> ${FILES_TO_STRIP}) set(STRIP_TOOL strip)
if(DEFINED ENV{STRIP_TOOL})
set(STRIP_TOOL $ENV{STRIP_TOOL})
endif()
add_custom_target(strip COMMAND ${STRIP_TOOL} $<IF:$<BOOL:${ENABLE_STACKTRACE}>,--strip-debug,--strip-all> ${FILES_TO_STRIP})
endif() endif()
endif() endif()
endif() endif()
@ -1018,6 +1011,9 @@ endif()
if(DWARFS_ARTIFACT_SUFFIX) if(DWARFS_ARTIFACT_SUFFIX)
set(DWARFS_ARTIFACT_ID "${DWARFS_ARTIFACT_ID}${DWARFS_ARTIFACT_SUFFIX}") set(DWARFS_ARTIFACT_ID "${DWARFS_ARTIFACT_ID}${DWARFS_ARTIFACT_SUFFIX}")
endif() endif()
if(CMAKE_CROSSCOMPILING)
set(DWARFS_ARTIFACT_ID "${DWARFS_ARTIFACT_ID}-cross-${CMAKE_HOST_SYSTEM_PROCESSOR}")
endif()
if(STATIC_BUILD_DO_NOT_USE OR WIN32) if(STATIC_BUILD_DO_NOT_USE OR WIN32)
if(TARGET dwarfsuniversal) if(TARGET dwarfsuniversal)
@ -1043,7 +1039,7 @@ if(STATIC_BUILD_DO_NOT_USE OR WIN32)
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
) )
else() else()
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^(i386|x86_64|AMD64|aarch64)$") if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^(i386|x86_64|AMD64|aarch64|ppc64le|arm)$")
find_program(UPX_EXE upx upx.exe PATHS "c:/bin" DOC "ultimate packer for executables") find_program(UPX_EXE upx upx.exe PATHS "c:/bin" DOC "ultimate packer for executables")
endif() endif()