Created
June 14, 2024 00:39
-
-
Save MalTeeez/6f604978d746b17409120ec7edc730c3 to your computer and use it in GitHub Desktop.
Script to build older gcc versions in containers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
# AUTHOR: Mika Hensel | |
# NEEDS: wget make gcc bzip2 diffutils | |
GCC_VERSION=$1 | |
cd /tmp | |
wget https://ftp.gnu.org/pub/gnu/gcc/gcc-$GCC_VERSION/gcc-$GCC_VERSION.tar.gz | |
tar xzf gcc-$GCC_VERSION.tar.gz | |
cd gcc-$GCC_VERSION && rm -f /tmp/gcc-$GCC_VERSION.tar.gz | |
# FROM download_prerequisites | |
MPFR=mpfr-2.4.2 | |
GMP=gmp-4.3.2 | |
MPC=mpc-0.8.1 | |
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/$MPFR.tar.bz2 || exit 1 | |
tar xjf $MPFR.tar.bz2 || exit 1 | |
ln -sf $MPFR mpfr || exit 1 | |
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/$GMP.tar.bz2 || exit 1 | |
tar xjf $GMP.tar.bz2 || exit 1 | |
ln -sf $GMP gmp || exit 1 | |
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/$MPC.tar.gz || exit 1 | |
tar xzf $MPC.tar.gz || exit 1 | |
ln -sf $MPC mpc || exit 1 | |
rm $MPFR.tar.bz2 $GMP.tar.bz2 $MPC.tar.gz || exit 1 | |
cd /tmp && mkdir build && cd build | |
$PWD/../gcc-$GCC_VERSION/configure --prefix=$HOME/GCC-$GCC_VERSION --enable-languages=c,c++ --disable-multilib | |
sed -i 's/struct ucontext/ucontext_t/' /tmp/gcc-$GCC_VERSION/gcc/config/i386/linux-unwind.h | |
make -j 20 STAGE1_CFLAGS='-fgnu89-inline' > out.log 2>err.log | |
make install && rm -rf /tmp/build/ && rm -rf /tmp/gcc-$GCC_VERSION/ | |
cp -rf ~/GCC-$GCC_VERSION/bin/* /usr/bin/ | |
gcc --version | |
bash | |
# FIXES: | |
# https://unix.stackexchange.com/questions/219708/arch-compiling-toplev-o-fails-in-gcc-install#260190 | |
# https://gcc.gnu.org/wiki/FAQ#gnu_stubs-32.h | |
# https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=883312dc79806f513275b72502231c751c14ff72 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment