From d40db637e16fc44ebbc1efb71274dfc251318c8a Mon Sep 17 00:00:00 2001 From: Aditya Date: Sun, 8 Jan 2023 14:51:58 +0530 Subject: [PATCH] Add 5.3 - build gcc --- scripts/chapter5/5.3-gcc.sh | 69 +++++++++++++++++++++++++++++++++++++ scripts/main.sh | 10 ++++++ 2 files changed, 79 insertions(+) create mode 100644 scripts/chapter5/5.3-gcc.sh diff --git a/scripts/chapter5/5.3-gcc.sh b/scripts/chapter5/5.3-gcc.sh new file mode 100644 index 0000000..a3ee992 --- /dev/null +++ b/scripts/chapter5/5.3-gcc.sh @@ -0,0 +1,69 @@ +#!/bin/bash + +# Extract and switch to the directory +cd $LFS/sources +tar xf gcc-12.2.0.tar.xz +cd $LFS/sources/gcc-12.2.0 + +tar -xf ../mpfr-4.1.0.tar.xz +mv -v mpfr-4.1.0 mpfr +tar -xf ../gmp-6.2.1.tar.xz +mv -v gmp-6.2.1 gmp +tar -xf ../mpc-1.2.1.tar.gz +mv -v mpc-1.2.1 mpc + +case $(uname -m) in + x86_64) + sed -e '/m64=/s/lib64/lib/' \ + -i.orig gcc/config/i386/t-linux64 + ;; +esac + +mkdir -v build +cd build + +../configure \ + --target=$LFS_TGT \ + --prefix=$LFS/tools \ + --with-glibc-version=2.36 \ + --with-sysroot=$LFS \ + --with-newlib \ + --without-headers \ + --disable-nls \ + --disable-shared \ + --disable-multilib \ + --disable-decimal-float \ + --disable-threads \ + --disable-libatomic \ + --disable-libgomp \ + --disable-libquadmath \ + --disable-libssp \ + --disable-libvtv \ + --disable-libstdcxx \ + --enable-languages=c,c++ + +# Exit on error +if [ $? -ne 0 ] +then + exit 1 +fi + +make -j5 + +# Exit on error +if [ $? -ne 0 ] +then + exit 1 +fi + +make install + + +if [ $? -ne 0 ] +then + exit 1 +fi + +cd .. +cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \ + `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/install-tools/include/limits.h diff --git a/scripts/main.sh b/scripts/main.sh index 7a56c63..b89216e 100644 --- a/scripts/main.sh +++ b/scripts/main.sh @@ -140,4 +140,14 @@ then stop_script "chapter5/5.2-binutils.sh" fi +# Chapter 5.3 +# =========== +echo "Building gcc" +su - lfs -c "$PWD/chapter5/5.3-gcc.sh" +# Exit on error +check_exit_code +if [ $exit_status -ne 0 ] +then + stop_script "chapter5/5.3-gcc.sh" +fi