error: C preprocessor "/lib/cpp" fails sanity check

This commit is contained in:
Denis Benato 2024-12-07 16:09:00 +01:00
parent c9f25de0d0
commit 83cd1ff4a7
2 changed files with 84 additions and 33 deletions

101
build.sh
View file

@ -166,6 +166,8 @@ if [ ! -f "$STEPS_DIR/gcc-step1" ]; then
--prefix=$LFS_TOOLS \ --prefix=$LFS_TOOLS \
--with-glibc-version=2.40 \ --with-glibc-version=2.40 \
--with-sysroot=$LFS \ --with-sysroot=$LFS \
--with-newlib \
--disable-gdbtk \
--disable-shared \ --disable-shared \
--without-headers \ --without-headers \
--enable-default-pie \ --enable-default-pie \
@ -181,12 +183,12 @@ if [ ! -f "$STEPS_DIR/gcc-step1" ]; then
--disable-libvtv \ --disable-libvtv \
--disable-libstdcxx \ --disable-libstdcxx \
--disable-decimal-float \ --disable-decimal-float \
--disable-multilib \ --enable-languages=c
--enable-languages=c,c++
make -j 32 all-gcc # if build fails add --disable-libsanitizer make -j 32 all-gcc # if build fails add --disable-libsanitizer
make -j 32 install-gcc make -j 32 install-gcc
make check-gcc RUNTESTFLAGS=--target_board=$ARCH-sim
cd "$BASE_DIR" 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" touch "$STEPS_DIR/gcc-step1"
fi fi
@ -222,7 +224,7 @@ if [ ! -f "$STEPS_DIR/glibc" ]; then
echo 'build-programs=no' >> configparms echo 'build-programs=no' >> configparms
"../configure" \ "../configure" \
--prefix=$LFS_TOOLS \ --prefix=/usr \
--target=$LFS_TGT \ --target=$LFS_TGT \
--host=$LFS_TGT \ --host=$LFS_TGT \
--build=$(../scripts/config.guess) \ --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 install-bootstrap-headers=yes install_root=$LFS install-headers
make -j4 csu/subdir_lib 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 \ $LFS_TGT-gcc \
-nostdlib \ -nostdlib \
@ -253,9 +274,9 @@ if [ ! -f "$STEPS_DIR/glibc" ]; then
-shared \ -shared \
-x c /dev/null \ -x c /dev/null \
-o $LFS/usr/lib/libc.so -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 DESTDIR=$LFS install
#make install_root="$pkgdir"/usr/$_target install #make install_root="$pkgdir"/usr/$_target install
@ -266,20 +287,25 @@ if [ ! -f "$STEPS_DIR/glibc" ]; then
touch "$STEPS_DIR/glibc" touch "$STEPS_DIR/glibc"
fi fi
if [ ! -f "$STEPS_DIR/gcc-step2" ]; then unset CC
if [ ! -d "$LFS_BUILD/gcc/build" ]; then unset CXX
echo "'$LFS_BUILD/gcc/build' directory is supposed to exist. Error." unset LD
exit 1 unset AS
fi unset AR
cd "$LFS_BUILD/gcc/build" 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” if [ ! -f "$STEPS_DIR/gcc-step2" ]; then
# case $(uname -m) in #if [ ! -d "$LFS_BUILD/gcc/build" ]; then
# x86_64) # echo "'$LFS_BUILD/gcc/build' directory is supposed to exist. Error."
# sed -e '/m64=/s/lib64/lib/' \ # exit 1
# -i.orig gcc/config/i386/t-linux64 #fi
# ;; #cd "$LFS_BUILD/gcc/build"
# esac cd "$LFS_BUILD/gcc"
mkdir -vp build
cd build
# ../configure is already done # ../configure is already done
"../configure" \ "../configure" \
@ -289,12 +315,10 @@ if [ ! -f "$STEPS_DIR/gcc-step2" ]; then
--prefix=$LFS_TOOLS \ --prefix=$LFS_TOOLS \
--with-glibc-version=2.40 \ --with-glibc-version=2.40 \
--with-sysroot=$LFS \ --with-sysroot=$LFS \
--without-headers \
--enable-default-pie \ --enable-default-pie \
--enable-default-ssp \ --enable-default-ssp \
--disable-nls \ --disable-nls \
--disable-multilib \ --disable-multilib \
--disable-threads \
--disable-libatomic \ --disable-libatomic \
--disable-libgomp \ --disable-libgomp \
--disable-libquadmath \ --disable-libquadmath \
@ -303,8 +327,7 @@ if [ ! -f "$STEPS_DIR/gcc-step2" ]; then
--disable-libvtv \ --disable-libvtv \
--disable-libstdcxx \ --disable-libstdcxx \
--disable-decimal-float \ --disable-decimal-float \
--disable-multilib \ --enable-languages=c
--enable-languages=c,c++
make -j 32 all-target-libgcc # if build fails add --disable-libsanitizer make -j 32 all-target-libgcc # if build fails add --disable-libsanitizer
make -j 32 install-target-libgcc make -j 32 install-target-libgcc
@ -313,6 +336,18 @@ if [ ! -f "$STEPS_DIR/gcc-step2" ]; then
touch "$STEPS_DIR/gcc-step2" touch "$STEPS_DIR/gcc-step2"
fi 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 [ ! -f "$STEPS_DIR/glibc-step2" ]; then
if [ ! -d "$LFS_BUILD/glibc/build" ]; then if [ ! -d "$LFS_BUILD/glibc/build" ]; then
echo "'$LFS_BUILD/glibc/build' is supposed to exist. Error." 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 # Configuration is done already
# Remove the stub glibc from before
rm $LFS/usr/lib/libc.so
make -j 32 make -j 32
make install_root=$LFS install make install_root=$LFS install
@ -330,7 +368,16 @@ if [ ! -f "$STEPS_DIR/glibc-step2" ]; then
touch "$STEPS_DIR/glibc-step2" touch "$STEPS_DIR/glibc-step2"
fi 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 [ ! -f "$STEPS_DIR/gcc-step3" ]; then
if [ ! -d "$LFS_BUILD/gcc/build" ]; then if [ ! -d "$LFS_BUILD/gcc/build" ]; then
echo "'$LFS_BUILD/gcc/build' directory is supposed to exist. Error." echo "'$LFS_BUILD/gcc/build' directory is supposed to exist. Error."
@ -338,8 +385,8 @@ if [ ! -f "$STEPS_DIR/gcc-step3" ]; then
fi fi
cd "$LFS_BUILD/gcc/build" cd "$LFS_BUILD/gcc/build"
make -j 32 make -j 32 all
make install make -j 32 install
cd "$BASE_DIR" cd "$BASE_DIR"
#rm -rf "$LFS_BUILD/gcc" #rm -rf "$LFS_BUILD/gcc"

View file

@ -9,13 +9,17 @@ tar -xf "$BASE_DIR/sources/gmp-6.3.0.tar.xz"
mv -v gmp-6.3.0 gmp mv -v gmp-6.3.0 gmp
tar -xf "$BASE_DIR/sources/mpc-1.3.1.tar.gz" tar -xf "$BASE_DIR/sources/mpc-1.3.1.tar.gz"
mv -v mpc-1.3.1 mpc 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” # On x86_64 hosts, set the default directory name for 64-bit libraries to “lib”
case $(uname -m) in #case $(uname -m) in
x86_64) #x86_64)
sed -e '/m64=/s/lib64/lib/' \ # sed -e '/m64=/s/lib64/lib/' \
-i.orig gcc/config/i386/t-linux64 # -i.orig gcc/config/i386/t-linux64
;; #;;
esac #esac
cd "$BASE_DIR" cd "$BASE_DIR"