|
1 | 1 | # syntax=docker/dockerfile:1 |
2 | 2 | ARG ARCH=amd64 |
3 | 3 | FROM $ARCH/alpine:latest |
| 4 | + |
| 5 | +ARG ARCH |
| 6 | +ARG TARGET_ARCHS |
| 7 | +ARG TOOLCHAIN_OPTIMIZE=s |
| 8 | + |
4 | 9 | RUN apk update |
5 | 10 | 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 \ |
7 | 16 | bash-completion \ |
8 | 17 | build-base \ |
9 | 18 | wget \ |
10 | 19 | curl \ |
11 | 20 | vim \ |
12 | 21 | tar \ |
13 | 22 | ripgrep \ |
14 | | - py3-pip \ |
15 | 23 | less \ |
16 | 24 | gcc \ |
17 | 25 | g++ \ |
18 | 26 | clang18 \ |
19 | 27 | clang19 \ |
| 28 | + clang20 \ |
20 | 29 | git \ |
| 30 | + xz \ |
| 31 | + gzip \ |
| 32 | + bzip2 \ |
| 33 | + zstd \ |
21 | 34 | ccache \ |
22 | | - samurai \ |
| 35 | + ninja-build \ |
23 | 36 | cmake \ |
24 | 37 | make \ |
25 | 38 | bison \ |
26 | 39 | flex \ |
27 | 40 | ronn \ |
28 | 41 | fuse \ |
29 | | - fuse-dev \ |
30 | | - fuse-static \ |
31 | 42 | fuse3 \ |
32 | | - fuse3-dev \ |
33 | | - fuse3-static \ |
34 | 43 | 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 \ |
47 | 44 | meson \ |
48 | 45 | autoconf \ |
49 | 46 | 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 |
64 | 60 |
|
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 |
69 | 62 |
|
70 | 63 | # Install mold |
71 | 64 | 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 |
73 | 67 |
|
74 | 68 | # Install bloaty |
75 | 69 | 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 \ |
77 | 72 | bash /usr/local/bin/install-bloaty.sh; \ |
78 | 73 | else \ |
79 | | - echo "Skipping bloaty installation for RISC-V."; \ |
| 74 | + echo "Skipping bloaty installation for $ARCH."; \ |
80 | 75 | fi |
81 | 76 |
|
| 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 | + |
82 | 90 | # Install all static libraries |
83 | 91 | 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 |
85 | 92 |
|
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 |
89 | 105 |
|
90 | 106 | # Set up git & user |
91 | 107 | RUN git config --global --add safe.directory /workspace |
|
0 commit comments