gcc native: first successful compilation (with a few trick)

This commit is contained in:
Giacomo Tesio 2019-12-15 23:39:06 +01:00
parent 629d1eef1c
commit 66ea00e263
2 changed files with 16 additions and 10 deletions

View File

@ -46,7 +46,6 @@ failOnError $? "fetching sources"
echo -n Building libstdc++-v3... | tee -a $LOG
# libstdc++-v3 is part of GCC but must be built after newlib.
# So we make its build fail and reconfigure it properly after making it fail.
export GCC_BUILD_DIR=$WORKING_DIR/build/gcc
mkdir -p $GCC_BUILD_DIR
(
@ -63,10 +62,10 @@ mkdir -p $GCC_BUILD_DIR
rm -fr $WORKING_DIR/src/gcc/mpc-1.0.3 &&
rm -fr $WORKING_DIR/src/gcc/mpc &&
cd $GCC_BUILD_DIR &&
make all-target-libstdc++-v3 ||
cd x86_64-jehanne/libstdc++-v3 &&
rm config.cache &&
$WORKING_DIR/src/gcc/libstdc++-v3/configure --srcdir=$WORKING_DIR/src/gcc/libstdc++-v3 --cache-file=./config.cache --enable-multilib --with-cross-host=x86_64-pc-linux-gnu --prefix=/posix/ --with-sysroot=$JEHANNE --enable-languages=c,c++,lto --program-transform-name='s&^&x86_64-jehanne-&' --disable-option-checking --with-target-subdir=x86_64-jehanne --build=x86_64-pc-linux-gnu --host=x86_64-jehanne --target=x86_64-jehanne
mkdir -p $GCC_BUILD_DIR/x86_64-jehanne/libstdc++-v3 &&
cd $GCC_BUILD_DIR/x86_64-jehanne/libstdc++-v3 &&
rm -f config.cache &&
$WORKING_DIR/src/gcc/libstdc++-v3/configure --srcdir=$WORKING_DIR/src/gcc/libstdc++-v3 --cache-file=./config.cache --enable-multilib --with-cross-host=x86_64-pc-linux-gnu --prefix=/posix --with-sysroot=/ --with-build-sysroot=$JEHANNE --enable-languages=c,c++,lto --program-transform-name='s&^&x86_64-jehanne-&' --disable-option-checking --with-target-subdir=x86_64-jehanne --build=x86_64-pc-linux-gnu --host=x86_64-jehanne --target=x86_64-jehanne &&
make &&
make DESTDIR=$JEHANNE/pkgs/libstdc++-v3/9.2.0/ install
) >> $LOG 2>&1
@ -75,7 +74,7 @@ echo done.
# Copy to /posix (to emulate bind during cross compilation)
cp -pfr $JEHANNE/pkgs/libstdc++-v3/9.2.0/posix/* $JEHANNE/posix
find posix/|grep '\.la$'|xargs rm
find $JEHANNE/posix/|grep '\.la$'|xargs rm
echo -n Building libgmp... | tee -a $LOG
(
@ -168,8 +167,10 @@ if [ ! -d $GCC_BUILD_DIR ]; then
mkdir $GCC_BUILD_DIR
fi
(
export CFLAGS="-DHIDE_JEHANNE_APW" &&
export CXXFLAGS=$CFLAGS &&
cd $GCC_BUILD_DIR &&
$WORKING_DIR/src/gcc/configure --host=x86_64-jehanne --without-isl --with-newlib --prefix=/posix --with-sysroot=/ --with-build-sysroot=$JEHANNE --enable-languages=c,c++ --with-gmp=$JEHANNE/posix --with-mpfr=$JEHANNE/posix --with-mpc=$JEHANNE/posix --disable-threads --disable-tls --disable-bootstrap --disable-libgomp --disable-werror --disable-nls &&
$WORKING_DIR/src/gcc/configure --host=x86_64-jehanne --without-isl --with-newlib --prefix=/posix --with-sysroot=/ --with-build-sysroot=$JEHANNE --enable-languages=c,c++ --with-gmp=$JEHANNE/posix --with-mpfr=$JEHANNE/posix --with-mpc=$JEHANNE/posix --disable-shared --disable-threads --disable-tls --disable-bootstrap --disable-libgomp --disable-werror --disable-nls &&
make all-gcc all-target-libgcc &&
make DESTDIR=$JEHANNE/pkgs/gcc/9.2.0/ install-gcc install-target-libgcc
) >> $LOG 2>&1
@ -177,6 +178,11 @@ failOnError $? "building gcc"
cp -pfr $JEHANNE/pkgs/gcc/9.2.0/posix/* $JEHANNE/posix
# NOTES work in progress
# in cstdlib replaced #include_next <stdlib.h> with #include.
# in newlib: preserved libm.a
# in GCC's src commented ifdef TIOCGWINSZ in gcc/diagnostic.c, function get_terminal_width
#
## add sh
#ln -sf /bin/bash $JEHANNE/hacking/cross/toolchain/bin/x86_64-jehanne-sh

View File

@ -7,14 +7,14 @@ WORKING_DIR=`dirname $JEHANNE`
WORKING_DIR="$WORKING_DIR/$REPONAME.TOOLCHAIN"
if [ -z "$WRAPPER_LOG" ]; then
WRAPPER_LOG="$JEHANNE/hacking/cross/pkgs/gcc/wrappers.log"
WRAPPER_LOG="$WORKING_DIR/wrappers.log"
fi
echo >> $WRAPPER_LOG
echo >> $WRAPPER_LOG
if echo $ARGS|grep -e '\.cpp\b' -e '\b\-o\b' -e ' -o ' > /dev/null; then
TOINCLUDE="-I$JEHANNE/posix/x86_64-jehanne/include/c++/9.2.0/ -I$JEHANNE/posix/x86_64-jehanne/include/c++/9.2.0/x86_64-jehanne -I$JEHANNE/posix/include -I$JEHANNE/sys/include/apw -I$JEHANNE/sys/include -I$JEHANNE/arch/amd64/include"
TOLINK="-L$JEHANNE/posix/lib -L$JEHANNE/arch/amd64/lib -lnewlibc -lposix -lc"
TOINCLUDE="-I$JEHANNE/posix/x86_64-jehanne/include/c++/9.2.0/ -I$JEHANNE/posix/x86_64-jehanne/include/c++/9.2.0/x86_64-jehanne -I$JEHANNE/posix/include -I$JEHANNE/sys/include -I$JEHANNE/arch/amd64/include"
TOLINK="-L$JEHANNE/posix/lib -L$JEHANNE/arch/amd64/lib -lstdc++ -lm -lnewlibc -lposix -lc"
date --rfc-3339="ns" |tee -a $WRAPPER_LOG
export >> $WRAPPER_LOG
echo $WORKING_DIR/cross/posix/bin/x86_64-jehanne-g++ "$@" $TOINCLUDE $TOLINK >> $WRAPPER_LOG