Skip to content

Commit

Permalink
refactor: move binutils build into independent Docker layer
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Kröning <[email protected]>
  • Loading branch information
mkroening committed Aug 9, 2024
1 parent 77db1f8 commit 13639dd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 24 deletions.
34 changes: 33 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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; \
Expand All @@ -34,7 +66,7 @@ RUN set -eux; \
WORKDIR /root

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
Expand Down
23 changes: 0 additions & 23 deletions toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 13639dd

Please sign in to comment.