diff --git a/cross/init.sh b/cross/init.sh index fed3edf..2f81324 100755 --- a/cross/init.sh +++ b/cross/init.sh @@ -21,12 +21,12 @@ if [ "$JEHANNE" = "" ]; then exit 1 fi -REPONAME=`basename $JEHANNE` -WORKING_DIR=`dirname $JEHANNE` -WORKING_DIR="$WORKING_DIR/$REPONAME.TOOLCHAIN" +WORKING_DIR="$JEHANNE_TOOLCHAIN" CROSS_DIR="$JEHANNE/hacking/cross" LOG="$WORKING_DIR/cross.build.log" +export LD_PRELOAD= + function failOnError { # $1 -> exit status on a previous command # $2 -> task description @@ -110,7 +110,7 @@ mkdir -p $GCC_BUILD_DIR ( cd $WORKING_DIR && ( grep -q jehanne src/gcc/gcc/config.gcc || patch -p1 < $CROSS_DIR/patch/gcc.patch ) && - cp $CROSS_DIR/patch/gcc/gcc/config/jehanne.h src/gcc/gcc/config && + cp $CROSS_DIR/patch/gcc/gcc/config/* src/gcc/gcc/config && sed -i 's/ftp/https/g' src/gcc/contrib/download_prerequisites && cd src && ( cd gcc && ./contrib/download_prerequisites ) && diff --git a/cross/native.sh b/cross/native.sh index 42f8cb5..cffd608 100755 --- a/cross/native.sh +++ b/cross/native.sh @@ -6,14 +6,11 @@ WORKING_DIR=$JEHANNE_TOOLCHAIN CROSS_DIR="$JEHANNE/hacking/cross" LOG="$WORKING_DIR/native.build.log" +export LD_PRELOAD= + OPATH=$PATH export PATH="$CROSS_DIR/wrappers:$PATH" -# include x86_64-jehanne-pkg-config in PATH -#export PATH="$JEHANNE/hacking/cross/:$PATH" -#unset CPATH #set in $JEHANNE/hacking/devshell.sh -#export CPATH="$JEHANNE/posix/include:$JEHANNE/sys/include/apw:$JEHANNE/sys/include:$JEHANNE/arch/amd64/include:$CPATH" - function failOnError { # $1 -> exit status on a previous command # $2 -> task description @@ -140,7 +137,7 @@ date > $LOG # export LIBS="-L$JEHANNE/posix/lib -L$JEHANNE/arch/amd64/lib -lmpc -lmpfr -lgmp -lnewlibc -lposix -lc" && # export CC_FOR_BUILD='CPATH="" LIBS="" gcc' && # mkdir -p $BINUTILS_BUILD_DIR && cd $BINUTILS_BUILD_DIR && -# $WORKING_DIR/src/binutils/configure --host=x86_64-jehanne --prefix=/posix --with-sysroot=/ --with-build-sysroot=$JEHANNE --with-gmp=$JEHANNE/posix/ --with-mpfr=$JEHANNE/posix/ --with-mpc=$JEHANNE/posix/ --enable-interwork --enable-multilib --enable-newlib-long-time_t --disable-nls --disable-werror && +# $WORKING_DIR/src/binutils/configure --host=x86_64-jehanne --with-sysroot=/ --with-build-sysroot=$JEHANNE --prefix=/posix --with-gmp=$JEHANNE/posix/ --with-mpfr=$JEHANNE/posix/ --with-mpc=$JEHANNE/posix/ --enable-interwork --enable-multilib --enable-newlib-long-time_t --disable-nls --disable-werror && # cp $CROSS_DIR/patch/MakeNothing.in $WORKING_DIR/src/binutils/bfd/doc/Makefile.in && # cp $CROSS_DIR/patch/MakeNothing.in $WORKING_DIR/src/binutils/bfd/po/Makefile.in && # cp $CROSS_DIR/patch/MakeNothing.in $WORKING_DIR/src/binutils/gas/doc/Makefile.in && @@ -162,14 +159,23 @@ echo -n Building gcc... | tee -a $LOG export GCC_BUILD_DIR=$WORKING_DIR/build/gcc-native && mkdir -p $GCC_BUILD_DIR && cd $GCC_BUILD_DIR && - $WORKING_DIR/src/gcc/configure --host=x86_64-jehanne --without-isl --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 && - make DESTDIR=$JEHANNE/pkgs/gcc/9.2.0/ install-gcc && - mkdir -p $GCC_BUILD_DIR/x86_64-jehanne/libgcc && - cd $GCC_BUILD_DIR/x86_64-jehanne/libgcc && - $WORKING_DIR/src/gcc/libgcc/configure --srcdir=$WORKING_DIR/src/gcc/libgcc --without-isl --prefix=/posix --with-sysroot=/ --with-build-sysroot=$JEHANNE --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 --enable-languages=c,c++,lto --program-transform-name=s,y,y, --disable-option-checking --with-target-subdir=x86_64-jehanne --build=x86_64-pc-linux-gnu --host=x86_64-jehanne --target=x86_64-jehanne && - make && - cd $GCC_BUILD_DIR && make DESTDIR=$JEHANNE/pkgs/gcc/9.2.0/ install-target-libgcc + $WORKING_DIR/src/gcc/configure --host=x86_64-jehanne \ + --prefix=/posix --with-sysroot=/ --with-build-sysroot=$JEHANNE \ + --enable-languages=c,c++ \ + --disable-multiarch --with-multilib-list=m64 \ + --without-isl --with-gmp=$JEHANNE/posix --with-mpfr=$JEHANNE/posix --with-mpc=$JEHANNE/posix \ + --disable-shared --disable-threads --disable-tls \ + --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 +# $WORKING_DIR/src/gcc/configure --host=x86_64-jehanne --without-isl --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 && +# make DESTDIR=$JEHANNE/pkgs/gcc/9.2.0/ install-gcc && +# mkdir -p $GCC_BUILD_DIR/x86_64-jehanne/libgcc && +# cd $GCC_BUILD_DIR/x86_64-jehanne/libgcc && +# $WORKING_DIR/src/gcc/libgcc/configure --srcdir=$WORKING_DIR/src/gcc/libgcc --without-isl --prefix=/posix --with-sysroot=/ --with-build-sysroot=$JEHANNE --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 --enable-languages=c,c++,lto --program-transform-name=s,y,y, --disable-option-checking --with-target-subdir=x86_64-jehanne --build=x86_64-pc-linux-gnu --host=x86_64-jehanne --target=x86_64-jehanne && +# make && +# cd $GCC_BUILD_DIR && make DESTDIR=$JEHANNE/pkgs/gcc/9.2.0/ install-target-libgcc ) >> $LOG 2>&1 failOnError $? "building gcc" diff --git a/cross/patch/gcc.patch b/cross/patch/gcc.patch index eb38b7e..ee21081 100644 --- a/cross/patch/gcc.patch +++ b/cross/patch/gcc.patch @@ -1,14 +1,16 @@ diff --git a/src/gcc/gcc/config.gcc b/src/gcc/gcc/config.gcc -index f02ddbd..e5ebfe0 100644 +index ddd3b8f..702aa59 100644 --- a/src/gcc/gcc/config.gcc +++ b/src/gcc/gcc/config.gcc -@@ -862,6 +862,16 @@ case ${target} in +@@ -947,6 +947,18 @@ case ${target} in tmake_file="$tmake_file vms/t-vmsnative" fi ;; +*-*-jehanne*) + gas=yes + gnu_ld=yes ++ c_target_objs="${c_target_objs} jehanne.o" ++ cxx_target_objs="${cxx_target_objs} jehanne.o" + default_use_cxa_atexit=yes + case $target in + x86_64-*) @@ -19,12 +21,12 @@ index f02ddbd..e5ebfe0 100644 *-*-vxworks*) tmake_file=t-vxworks xm_defines=POSIX -@@ -1347,6 +1357,9 @@ x86_64-*-darwin*) +@@ -1635,6 +1647,9 @@ i[34567]86-*-elfiamcu) i[34567]86-*-elf*) tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/i386elf.h" ;; +x86_64-*-jehanne*) -+ tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h glibc-stdint.h i386/i386elf.h i386/x86-64.h jehanne.h" ++ tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/i386elf.h i386/x86-64.h jehanne.h" + ;; x86_64-*-elf*) tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/i386elf.h i386/x86-64.h" diff --git a/cross/patch/gcc/gcc/config/jehanne.c b/cross/patch/gcc/gcc/config/jehanne.c new file mode 100644 index 0000000..9573a88 --- /dev/null +++ b/cross/patch/gcc/gcc/config/jehanne.c @@ -0,0 +1,31 @@ +/* + * This file is part of Jehanne. + * + * Copyright (C) 2020 Giacomo Tesio + * + * Jehanne is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 of the License. + * + * Jehanne is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jehanne. If not, see . + */ +extern "C" { + +#include +#include +#include + +} + +void +__application_newlib_init(int argc, char *argv[]) +{ + sys_rfork(RFFDG | RFREND | RFNOTEG); + libposix_emulate_SIGCHLD(); +} diff --git a/cross/patch/gcc/gcc/config/t-jehanne b/cross/patch/gcc/gcc/config/t-jehanne new file mode 100644 index 0000000..f239bbf --- /dev/null +++ b/cross/patch/gcc/gcc/config/t-jehanne @@ -0,0 +1,19 @@ +# This file is part of Jehanne. +# +# Copyright (C) 2020 Giacomo Tesio +# +# Jehanne is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 2 of the License. +# +# Jehanne is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Jehanne. If not, see . + +jehanne.o: $(srcdir)/config/jehanne.c + $(COMPILE) $< + $(POSTCOMPILE)