Skip to content

Commit f144da5

Browse files
committed
wip: more cleanups
1 parent ff97d2b commit f144da5

5 files changed

Lines changed: 87 additions & 186 deletions

File tree

.docker/Dockerfile.alpine

Lines changed: 60 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,107 @@
11
# syntax=docker/dockerfile:1
22
ARG ARCH=amd64
33
FROM $ARCH/alpine:latest
4+
5+
ARG ARCH
6+
ARG TARGET_ARCHS
7+
ARG TOOLCHAIN_OPTIMIZE=s
8+
49
RUN apk update
510
RUN apk upgrade
6-
RUN apk add --no-cache \
11+
RUN qemu_pkgs=""; \
12+
for arch in $(echo $TARGET_ARCHS | tr ',' ' '); do \
13+
qemu_pkgs="$qemu_pkgs qemu-$arch"; \
14+
done; \
15+
apk add --no-cache \
716
bash-completion \
817
build-base \
918
wget \
1019
curl \
1120
vim \
1221
tar \
1322
ripgrep \
14-
py3-pip \
1523
less \
1624
gcc \
1725
g++ \
1826
clang18 \
1927
clang19 \
28+
clang20 \
2029
git \
30+
xz \
31+
gzip \
32+
bzip2 \
33+
zstd \
2134
ccache \
22-
samurai \
35+
ninja-build \
2336
cmake \
2437
make \
2538
bison \
2639
flex \
2740
ronn \
2841
fuse \
29-
fuse-dev \
30-
fuse-static \
3142
fuse3 \
32-
fuse3-dev \
33-
fuse3-static \
3443
pkgconf \
35-
binutils-dev \
36-
libevent-dev \
37-
libevent-static \
38-
linux-headers \
39-
date-dev \
40-
range-v3-dev \
41-
zlib-static \
42-
libucontext-dev \
43-
libdwarf-dev \
44-
elfutils-dev \
45-
utfcpp \
46-
nlohmann-json \
4744
meson \
4845
autoconf \
4946
strace \
50-
gdb
51-
52-
# Install UPX
53-
ARG ARCH
54-
# UPX isn't supported on RISC-V yet, so skip this
55-
RUN if [ "$ARCH" != "riscv64" ]; then \
56-
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"; \
57-
else \
58-
echo "Skipping UPX installation for RISC-V architecture while it is not supported."; \
59-
echo "See https://github.com/upx/upx/discussions/793 for details."; \
60-
fi
61-
62-
# Install mistletoe
63-
RUN pip3 install --break-system-packages --root-user-action ignore mistletoe
47+
gdb \
48+
gmp-dev \
49+
zlib-static \
50+
zstd-static \
51+
zlib-dev \
52+
zstd-dev \
53+
mpfr-dev \
54+
mpc1-dev \
55+
isl-dev \
56+
texinfo \
57+
linux-headers \
58+
rsync \
59+
$qemu_pkgs
6460

65-
# Install size-optimized and static-link-optimized libstdc++
66-
RUN apk add --no-cache gmp-dev mpfr-dev mpc1-dev isl-dev
67-
COPY install-libstdcxx.sh /usr/local/bin/install-libstdcxx.sh
68-
RUN bash /usr/local/bin/install-libstdcxx.sh
61+
COPY fetch.sh /usr/local/bin/fetch.sh
6962

7063
# Install mold
7164
COPY install-mold.sh /usr/local/bin/install-mold.sh
72-
RUN bash /usr/local/bin/install-mold.sh
65+
RUN --mount=type=cache,id=ccache,target=/root/.ccache --mount=type=cache,id=pkgcache,target=/root/.pkgcache \
66+
bash /usr/local/bin/install-mold.sh
7367

7468
# Install bloaty
7569
COPY install-bloaty.sh /usr/local/bin/install-bloaty.sh
76-
RUN if [ "$ARCH" != "riscv64" ]; then \
70+
RUN --mount=type=cache,id=ccache,target=/root/.ccache --mount=type=cache,id=pkgcache,target=/root/.pkgcache \
71+
if [ "$ARCH" == "amd64" ]; then \
7772
bash /usr/local/bin/install-bloaty.sh; \
7873
else \
79-
echo "Skipping bloaty installation for RISC-V."; \
74+
echo "Skipping bloaty installation for $ARCH."; \
8075
fi
8176

77+
RUN apk del linux-headers
78+
79+
# Install size-optimized and static-link-optimized libstdc++
80+
COPY install-toolchain.sh /usr/local/bin/install-toolchain.sh
81+
RUN --mount=type=cache,id=ccache,target=/root/.ccache --mount=type=cache,id=pkgcache,target=/root/.pkgcache \
82+
bash /usr/local/bin/install-toolchain.sh $TOOLCHAIN_OPTIMIZE $TARGET_ARCHS
83+
84+
RUN apk del zlib-dev zstd-dev
85+
86+
# Clear the config cache after a toolchain update
87+
RUN --mount=type=cache,id=cfgcache,target=/root/.cfgcache \
88+
rm -rf /root/.cfgcache/*
89+
8290
# Install all static libraries
8391
COPY install-static-libs.sh /usr/local/bin/install-static-libs.sh
84-
RUN bash /usr/local/bin/install-static-libs.sh gcc clang-19 :alpine
8592

86-
# Install the *real* ninja...
87-
# TODO: move this up if we change anything
88-
RUN apk add --no-cache ninja-build
93+
RUN --mount=type=cache,id=ccache,target=/root/.ccache --mount=type=cache,id=pkgcache,target=/root/.pkgcache \
94+
--mount=type=cache,id=cfgcache,target=/root/.cfgcache \
95+
bash /usr/local/bin/install-static-libs.sh :all $TARGET_ARCHS
96+
97+
# Install UPX
98+
# UPX isn't supported on RISC-V/S390 (yet), so skip this
99+
RUN if ! [ "$ARCH" == "amd64" ] || [ "$ARCH" == "arm64v8" ]; then \
100+
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"; \
101+
else \
102+
echo "Skipping UPX installation for $ARCH architecture while it is not supported."; \
103+
echo "See https://github.com/upx/upx/discussions/793 for details."; \
104+
fi
89105

90106
# Set up git & user
91107
RUN git config --global --add safe.directory /workspace

.docker/Dockerfile.alpine-xx

Lines changed: 0 additions & 108 deletions
This file was deleted.

.docker/Makefile

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
IMAGE_UBUNTU="dwarfs-buildenv"
22
IMAGE_DEBIAN="dwarfs-buildenv-debian"
33
IMAGE_ALPINE="dwarfs-buildenv-alpine"
4-
IMAGE_ALPINE_RISCV="dwarfs-buildenv-alpine-riscv64"
5-
IMAGE_ALPINE_XX="dwarfs-buildenv-alpine-xx"
64
IMAGE_UBUNTU2204="dwarfs-buildenv-ubuntu2204"
75
IMAGE_FEDORA="dwarfs-buildenv-fedora"
86
IMAGE_ARCH="dwarfs-buildenv-arch"
@@ -35,23 +33,11 @@ run_debian:
3533
@docker run $(COMMON_RUN_OPTS) $(IMAGE_DEBIAN)
3634

3735
build_alpine:
38-
docker build -f Dockerfile.alpine -t $(IMAGE_ALPINE) .
36+
docker buildx build -f Dockerfile.alpine --build-arg TARGET_ARCHS=x86_64,aarch64,riscv64,i386 -t $(IMAGE_ALPINE) .
3937

4038
run_alpine:
4139
@docker run $(COMMON_RUN_OPTS) $(IMAGE_ALPINE)
4240

43-
build_alpine_xx:
44-
docker buildx build -f Dockerfile.alpine-xx --build-arg TARGET_ARCHS=x86_64,riscv64,i386 -t $(IMAGE_ALPINE_XX) .
45-
46-
run_alpine_xx:
47-
@docker run $(COMMON_RUN_OPTS) $(IMAGE_ALPINE_XX)
48-
49-
build_alpine_riscv:
50-
docker build -f Dockerfile.alpine -t $(IMAGE_ALPINE_RISCV) --build-arg ARCH=riscv64 .
51-
52-
run_alpine_riscv:
53-
@docker run $(COMMON_RUN_OPTS) $(IMAGE_ALPINE_RISCV)
54-
5541
build_ubuntu2204:
5642
docker build -f Dockerfile.ubuntu-2204 -t $(IMAGE_UBUNTU2204) .
5743

.docker/install-static-libs.sh

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ cd pkgs
99
ARCH="$(uname -m)"
1010

1111
GCC="gcc"
12-
CLANG="clang"
12+
CLANG="clang-20"
1313
PKGS="$1"
1414
TARGET_ARCH_STR="${2:-${ARCH}}"
1515

@@ -398,16 +398,17 @@ EOF
398398
fetch.sh https://gitlab.alpinelinux.org/alpine/aports/-/raw/abc0b4170e42e2a7d835e4490ecbae49e6f3d137/main/jemalloc/musl-exception-specification-errors.patch - | patch -p1
399399
fetch.sh https://gitlab.alpinelinux.org/alpine/aports/-/raw/abc0b4170e42e2a7d835e4490ecbae49e6f3d137/main/jemalloc/pkgconf.patch - | patch -p1
400400
./autogen.sh ${TRIPLETS}
401-
# mkdir build-minimal
402-
# cd build-minimal
403-
# ../configure ${TRIPLETS} --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
404-
# make -j$(nproc)
405-
# make install
406-
# cd ..
407-
# mkdir build-full
408-
mkdir build
409-
cd build
410-
../configure ${TRIPLETS} --prefix="$INSTALL_DIR" --localstatedir=/var --sysconfdir=/etc --with-lg-hugepage=21 \
401+
mkdir build-minimal
402+
cd build-minimal
403+
../configure ${TRIPLETS} --prefix="$INSTALL_DIR-jemalloc-minimal" --localstatedir=/var --sysconfdir=/etc --with-lg-hugepage=21 \
404+
--disable-stats --disable-prof --enable-static --disable-shared --disable-log --disable-debug \
405+
--cache-file=$HOME/.cfgcache/jemalloc-minimal-${JEMALLOC_VERSION}-${CARCH}-${COMPILER}.cache
406+
make -j$(nproc)
407+
make install
408+
cd ..
409+
mkdir build-full
410+
cd build-full
411+
../configure ${TRIPLETS} --prefix="$INSTALL_DIR-jemalloc-full" --localstatedir=/var --sysconfdir=/etc --with-lg-hugepage=21 \
411412
--enable-stats --enable-prof --enable-static --disable-shared --disable-log --disable-debug \
412413
--cache-file=$HOME/.cfgcache/jemalloc-${JEMALLOC_VERSION}-${CARCH}-${COMPILER}.cache
413414
make -j$(nproc)

.docker/install-toolchain.sh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
set -ex
44

55
ARCH="$(uname -m)"
6-
TARGET_ARCH_STR="${1:-$ARCH}"
7-
OPTIMIZE_STR="${2:-s}"
6+
OPTIMIZE_STR="${1:-s}"
7+
TARGET_ARCH_STR="${2:-$ARCH}"
88

99
BINUTILS_VERSION=2.44
1010
GCC_VERSION=14.2.0
@@ -173,14 +173,20 @@ for target_arch in ${TARGET_ARCH_STR//,/ }; do
173173
make -j"$(nproc)" ${GCC_NODOCS}
174174
make install
175175

176+
# Directory for ccache symlinks
177+
mkdir -p $PREFIX/lib/ccache/bin
178+
176179
# Symbolic links for clang
177-
ln -s /usr/bin/clang $PREFIX/bin/$TARGET-clang
178-
ln -s /usr/bin/clang++ $PREFIX/bin/$TARGET-clang++
180+
for clang_binary in /usr/bin/clang{++,}{-[1-9]*,}; do
181+
name=$(basename $clang_binary)
182+
ln -s $clang_binary $PREFIX/bin/$TARGET-$name
183+
ln -s /usr/bin/ccache $PREFIX/lib/ccache/bin/$TARGET-$name
184+
done
179185

180-
# Also provide ccache symlinks
181-
mkdir -p $PREFIX/lib/ccache/bin
182-
for binary in gcc g++ clang clang++; do
183-
ln -s /usr/bin/ccache $PREFIX/lib/ccache/bin/$TARGET-$binary
186+
# Also provide ccache symlinks for gcc
187+
for gcc_binary in $PREFIX/bin/$TARGET-{c++,g++,gcc,gcc-[1-9]*}; do
188+
name=$(basename $gcc_binary)
189+
ln -s /usr/bin/ccache $PREFIX/lib/ccache/bin/$name
184190
done
185191
done
186192
done

0 commit comments

Comments
 (0)