Compile binutils and gcc from scratch

Turns out the alpine versione doesn't quite work well with low-level 32
bit code...
This commit is contained in:
Thomas Lovén 2017-11-11 17:53:09 +01:00
parent 261cc76e8f
commit d339e27080
2 changed files with 49 additions and 3 deletions

View File

@ -1,8 +1,8 @@
FROM alpine FROM alpine
RUN apk --update add make binutils gcc && \ ADD build-toolchain.sh /opt/build-toolchain.sh
apk add grub-bios xorriso qemu-system-x86_64 gdb && \
rm -rf /var/cache/apk/* RUN /opt/build-toolchain.sh
ENV PATH "/opt/toolchain:$PATH" ENV PATH "/opt/toolchain:$PATH"
ENV MITTOS64 "true" ENV MITTOS64 "true"

46
toolchain/build-toolchain.sh Executable file
View File

@ -0,0 +1,46 @@
#!/bin/sh -e
apk --update add build-base
apk add gmp-dev mpfr-dev mpc1-dev
apk add make
apk add grub-bios xorriso
apk add qemu-system-x86_64 gdb
rm -rf /var/cache/apk/*
target=x86_64-elf
binutils=binutils-2.26
gcc=gcc-6.1.0
cd /opt
wget http://ftp.gnu.org/gnu/binutils/${binutils}.tar.gz
tar -xf ${binutils}.tar.gz
mkdir binutils-build && cd binutils-build
../${binutils}/configure \
--target=${target} \
--disable-nls \
--disable-werror \
--with-sysroot \
make
make install
cd /opt
wget http://ftp.gnu.org/gnu/gcc/${gcc}/${gcc}.tar.gz
tar -xf ${gcc}.tar.gz
mkdir gcc-build && cd gcc-build
../${gcc}/configure \
--target=${target} \
--disable-nls \
--enable-languages=c \
--without-headers \
make all-gcc all-target-libgcc
make install-gcc install-target-libgcc
apk del build-base
cd /
rm -rf /opt