diff --git a/build.sh b/build.sh index 89e036c..b37e031 100755 --- a/build.sh +++ b/build.sh @@ -166,6 +166,8 @@ if [ ! -f "$STEPS_DIR/gcc-step1" ]; then --prefix=$LFS_TOOLS \ --with-glibc-version=2.40 \ --with-sysroot=$LFS \ + --with-newlib \ + --disable-gdbtk \ --disable-shared \ --without-headers \ --enable-default-pie \ @@ -181,12 +183,12 @@ if [ ! -f "$STEPS_DIR/gcc-step1" ]; then --disable-libvtv \ --disable-libstdcxx \ --disable-decimal-float \ - --disable-multilib \ - --enable-languages=c,c++ + --enable-languages=c make -j 32 all-gcc # if build fails add --disable-libsanitizer make -j 32 install-gcc + make check-gcc RUNTESTFLAGS=--target_board=$ARCH-sim cd "$BASE_DIR" - #rm -rf "$LFS_BUILD/gcc/build" # Do not remove the whole gcc directory: we need it for libstdc++ + rm -rf "$LFS_BUILD/gcc/build" # Do not remove the whole gcc directory: we need it for libstdc++ touch "$STEPS_DIR/gcc-step1" fi @@ -222,7 +224,7 @@ if [ ! -f "$STEPS_DIR/glibc" ]; then echo 'build-programs=no' >> configparms "../configure" \ - --prefix=$LFS_TOOLS \ + --prefix=/usr \ --target=$LFS_TGT \ --host=$LFS_TGT \ --build=$(../scripts/config.guess) \ @@ -245,7 +247,26 @@ if [ ! -f "$STEPS_DIR/glibc" ]; then make install-bootstrap-headers=yes install_root=$LFS install-headers make -j4 csu/subdir_lib - install csu/crt1.o csu/crti.o csu/crtn.o $LFS/usr/lib + + if [ -f "csu/crt1.o" ]; then + install csu/crt1.o $LFS/usr/lib + fi + + if [ -f "csu/crti.o" ]; then + install csu/crti.o $LFS/usr/lib + fi + + if [ -f "csu/crtn.o" ]; then + install csu/crtn.o $LFS/usr/lib + fi + + if [ -f "csu/Scrt1.o" ]; then + install csu/Scrt1.o $LFS/usr/lib + fi + + if [ -f "csu/crtbeginS.o" ]; then + install csu/crtbeginS.o $LFS/usr/lib + fi $LFS_TGT-gcc \ -nostdlib \ @@ -253,9 +274,9 @@ if [ ! -f "$STEPS_DIR/glibc" ]; then -shared \ -x c /dev/null \ -o $LFS/usr/lib/libc.so - touch $LFS/usr/include/gnu/stubs.h + #touch $LFS/usr/include/gnu/stubs.h - export LD_LIBRARY_PATH="$LD_LIBRARY_PATH_old" + #export LD_LIBRARY_PATH="$LD_LIBRARY_PATH_old" #make DESTDIR=$LFS install #make install_root="$pkgdir"/usr/$_target install @@ -266,20 +287,25 @@ if [ ! -f "$STEPS_DIR/glibc" ]; then touch "$STEPS_DIR/glibc" fi -if [ ! -f "$STEPS_DIR/gcc-step2" ]; then - if [ ! -d "$LFS_BUILD/gcc/build" ]; then - echo "'$LFS_BUILD/gcc/build' directory is supposed to exist. Error." - exit 1 - fi - cd "$LFS_BUILD/gcc/build" +unset CC +unset CXX +unset LD +unset AS +unset AR +unset RANLIB +unset OBJDUMP +export LD_LIBRARY_PATH="$LD_LIBRARY_PATH_old" -# # On x86_64 hosts, set the default directory name for 64-bit libraries to “lib” -# case $(uname -m) in -# x86_64) -# sed -e '/m64=/s/lib64/lib/' \ -# -i.orig gcc/config/i386/t-linux64 -# ;; -# esac +if [ ! -f "$STEPS_DIR/gcc-step2" ]; then + #if [ ! -d "$LFS_BUILD/gcc/build" ]; then + # echo "'$LFS_BUILD/gcc/build' directory is supposed to exist. Error." + # exit 1 + #fi + #cd "$LFS_BUILD/gcc/build" + cd "$LFS_BUILD/gcc" + + mkdir -vp build + cd build # ../configure is already done "../configure" \ @@ -289,12 +315,10 @@ if [ ! -f "$STEPS_DIR/gcc-step2" ]; then --prefix=$LFS_TOOLS \ --with-glibc-version=2.40 \ --with-sysroot=$LFS \ - --without-headers \ --enable-default-pie \ --enable-default-ssp \ --disable-nls \ --disable-multilib \ - --disable-threads \ --disable-libatomic \ --disable-libgomp \ --disable-libquadmath \ @@ -303,8 +327,7 @@ if [ ! -f "$STEPS_DIR/gcc-step2" ]; then --disable-libvtv \ --disable-libstdcxx \ --disable-decimal-float \ - --disable-multilib \ - --enable-languages=c,c++ + --enable-languages=c make -j 32 all-target-libgcc # if build fails add --disable-libsanitizer make -j 32 install-target-libgcc @@ -313,6 +336,18 @@ if [ ! -f "$STEPS_DIR/gcc-step2" ]; then touch "$STEPS_DIR/gcc-step2" fi +export CC="$LFS_TGT-gcc" +export CXX="$LFS_TGT-g++" +export AS="$LFS_TGT-as" +export LD="$LFS_TGT-ld" +export AR="$LFS_TGT-ar" +export RANLIB="$LFS_TGT-ranlib" +# remove hardening options for building libraries +export CFLAGS="-U_FORTIFY_SOURCE -O2" +export CPPFLAGS="-U_FORTIFY_SOURCE -O2" +export LD_LIBRARY_PATH_old="$LD_LIBRARY_PATH" +unset LD_LIBRARY_PATH + if [ ! -f "$STEPS_DIR/glibc-step2" ]; then if [ ! -d "$LFS_BUILD/glibc/build" ]; then echo "'$LFS_BUILD/glibc/build' is supposed to exist. Error." @@ -322,6 +357,9 @@ if [ ! -f "$STEPS_DIR/glibc-step2" ]; then # Configuration is done already + # Remove the stub glibc from before + rm $LFS/usr/lib/libc.so + make -j 32 make install_root=$LFS install @@ -330,7 +368,16 @@ if [ ! -f "$STEPS_DIR/glibc-step2" ]; then touch "$STEPS_DIR/glibc-step2" fi -# build libstdc++ +#unset CC +#unset CXX +#unset LD +#unset AS +#unset AR +#unset RANLIB +#unset OBJDUMP +#export LD_LIBRARY_PATH="$LD_LIBRARY_PATH_old" + +# build the rest of gcc if [ ! -f "$STEPS_DIR/gcc-step3" ]; then if [ ! -d "$LFS_BUILD/gcc/build" ]; then echo "'$LFS_BUILD/gcc/build' directory is supposed to exist. Error." @@ -338,8 +385,8 @@ if [ ! -f "$STEPS_DIR/gcc-step3" ]; then fi cd "$LFS_BUILD/gcc/build" - make -j 32 - make install + make -j 32 all + make -j 32 install cd "$BASE_DIR" #rm -rf "$LFS_BUILD/gcc" diff --git a/unpack-gcc.sh b/unpack-gcc.sh index 803a91f..bac0067 100644 --- a/unpack-gcc.sh +++ b/unpack-gcc.sh @@ -9,13 +9,17 @@ tar -xf "$BASE_DIR/sources/gmp-6.3.0.tar.xz" mv -v gmp-6.3.0 gmp tar -xf "$BASE_DIR/sources/mpc-1.3.1.tar.gz" mv -v mpc-1.3.1 mpc +tar -xf "$BASE_DIR/sources/isl-0.27.tar.gz" +mv -v isl-0.27 isl +tar -xf "$BASE_DIR/sources/cloog-0.18.4.tar.gz" +mv -v cloog-0.18.4 cloog # On x86_64 hosts, set the default directory name for 64-bit libraries to “lib” -case $(uname -m) in -x86_64) - sed -e '/m64=/s/lib64/lib/' \ - -i.orig gcc/config/i386/t-linux64 -;; -esac +#case $(uname -m) in +#x86_64) +# sed -e '/m64=/s/lib64/lib/' \ +# -i.orig gcc/config/i386/t-linux64 +#;; +#esac cd "$BASE_DIR" \ No newline at end of file