From 12eeff6e2fe1eb24b9ec9dc15eb1aeab3e1cd6ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Fri, 9 Aug 2024 21:06:06 +0000 Subject: [PATCH] refactor: move binutils build into independent Docker layer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Kröning --- Dockerfile | 36 ++++++++++++++++++++++++++++++++++-- toolchain.sh | 23 ----------------------- 2 files changed, 34 insertions(+), 25 deletions(-) diff --git a/Dockerfile b/Dockerfile index a1bbd8d..5e5f985 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,38 @@ RUN cargo xtask build \ --no-default-features \ --features pci,smp,acpi,newlib,tcp,dhcpv4 +FROM buildpack-deps:bookworm AS binutils +RUN set -eux; \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + bison \ + flex \ + texinfo \ + ; \ + rm -rf /var/lib/apt/lists/*; +ADD --link https://github.com/hermit-os/binutils.git /binutils +WORKDIR /binutils +ARG TARGET +ARG PREFIX +RUN set -eux; \ + ./configure \ + --target=${TARGET} \ + --prefix=${PREFIX} \ + --with-sysroot \ + --disable-werror \ + --disable-multilib \ + --disable-shared \ + --disable-nls \ + --disable-gdb \ + --disable-libdecnumber \ + --disable-readline \ + --disable-sim \ + --enable-tls \ + --enable-lto \ + --enable-plugin; \ + make -O -j$(nproc); \ + make install + FROM buildpack-deps:bookworm AS builder RUN set -eux; \ @@ -29,15 +61,15 @@ RUN set -eux; \ WORKDIR /root +ARG PREFIX COPY --link --from=kernel /kernel/libhermit.a ./kernel/libhermit.a -ADD --link https://github.com/hermit-os/binutils.git binutils +COPY --link --from=binutils ${PREFIX} ${PREFIX} ADD --link https://github.com/hermit-os/gcc.git gcc ADD --link https://github.com/hermit-os/newlib.git newlib ADD --link https://github.com/hermit-os/pthread-embedded.git pte ADD --link ./toolchain.sh ./toolchain.sh ARG TARGET -ARG PREFIX RUN ./toolchain.sh ${TARGET} ${PREFIX} diff --git a/toolchain.sh b/toolchain.sh index 72b06bb..f38eae3 100755 --- a/toolchain.sh +++ b/toolchain.sh @@ -23,29 +23,6 @@ export CXXFLAGS_FOR_TARGET="-m64 -O3 -fPIE" echo "Build bootstrap toolchain for $TARGET with $NJOBS jobs for $PREFIX" -if [ ! -d "tmp/binutils" ]; then -mkdir -p tmp/binutils -cd tmp/binutils -../../binutils/configure \ - --target=$TARGET \ - --prefix=$PREFIX \ - --with-sysroot \ - --disable-werror \ - --disable-multilib \ - --disable-shared \ - --disable-nls \ - --disable-gdb \ - --disable-libdecnumber \ - --disable-readline \ - --disable-sim \ - --enable-tls \ - --enable-lto \ - --enable-plugin -make -O $NJOBS -make install -cd - -fi - if [ ! -d "tmp/bootstrap" ]; then mkdir -p tmp/bootstrap cd tmp/bootstrap