From e0db39786288cc23f6025019eb41045a20ee12b6 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Mon, 26 Nov 2018 00:57:13 +0100 Subject: [PATCH 01/91] native gcc: build libgmp --- cross/pkgs/gcc/.gitignore | 2 ++ cross/pkgs/gcc/build.sh | 40 +++++++++++++++++++++++++++++++ cross/pkgs/gcc/patch/libgmp.patch | 11 +++++++++ cross/pkgs/gcc/src/fetch.json | 12 ++++++++++ cross/x86_64-jehanne-pkg-config | 15 ++++++++++++ 5 files changed, 80 insertions(+) create mode 100644 cross/pkgs/gcc/.gitignore create mode 100755 cross/pkgs/gcc/build.sh create mode 100644 cross/pkgs/gcc/patch/libgmp.patch create mode 100644 cross/pkgs/gcc/src/fetch.json create mode 100755 cross/x86_64-jehanne-pkg-config diff --git a/cross/pkgs/gcc/.gitignore b/cross/pkgs/gcc/.gitignore new file mode 100644 index 0000000..b7d701c --- /dev/null +++ b/cross/pkgs/gcc/.gitignore @@ -0,0 +1,2 @@ +src/ +out/ diff --git a/cross/pkgs/gcc/build.sh b/cross/pkgs/gcc/build.sh new file mode 100755 index 0000000..4882444 --- /dev/null +++ b/cross/pkgs/gcc/build.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +echo "Cross compiling GCC and dependencies" + +export WORKING_DIR="$JEHANNE/hacking/cross/pkgs/gcc" + +# include x86_64-jehanne-pkg-config in PATH +export PATH="$JEHANNE/hacking/cross/:$PATH" + +function failOnError { + # $1 -> exit status on a previous command + # $2 -> task description + if [ $1 -ne 0 ]; then + kill $dotter + wait $dotter 2>/dev/null + + echo "ERROR $2" + echo + echo BUILD LOG: + echo + cat cross-toolchain.build.log + exit $1 + fi +} + +date > $WORKING_DIR/gcc.build.log + +(cd src && fetch) >> $WORKING_DIR/gcc.build.log +failOnError $? "fetching sources" + +echo -n Building libgmp... +( + cd libgmp + patch -p0 < $WORKING_DIR/patch/libgmp.patch + ./configure --host=x86_64-jehanne --prefix=/pkgs/libgmp/6.1.2/ + make + make DESTDIR=$JEHANNE install +) >> $WORKING_DIR/gcc.build.log +failOnError $? "Building libgmp" +echo done. diff --git a/cross/pkgs/gcc/patch/libgmp.patch b/cross/pkgs/gcc/patch/libgmp.patch new file mode 100644 index 0000000..7a33851 --- /dev/null +++ b/cross/pkgs/gcc/patch/libgmp.patch @@ -0,0 +1,11 @@ +diff -Naru ../orig/configfsf.sub ./configfsf.sub +--- ../orig/configfsf.sub 2018-11-26 11:59:08.897396848 +0100 ++++ ./configfsf.sub 2018-11-26 12:20:10.079672849 +0100 +@@ -1399,6 +1399,7 @@ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ ++ | -jehanne* \ + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; diff --git a/cross/pkgs/gcc/src/fetch.json b/cross/pkgs/gcc/src/fetch.json new file mode 100644 index 0000000..47c0c9e --- /dev/null +++ b/cross/pkgs/gcc/src/fetch.json @@ -0,0 +1,12 @@ +{ + "libgmp" : { + "Upstream":"https://gmplib.org/download/gmp/gmp-6.1.2.tar.bz2", + "Digest": { + "sha256":"5275bb04f4863a13516b2f39392ac5e272f5e1bb8057b18aec1c9b79d73d8fb2" + }, + "Compress":"bzip2", + "RemovePrefix": true, + "Exclude": [ + ] + } +} diff --git a/cross/x86_64-jehanne-pkg-config b/cross/x86_64-jehanne-pkg-config new file mode 100755 index 0000000..6431f07 --- /dev/null +++ b/cross/x86_64-jehanne-pkg-config @@ -0,0 +1,15 @@ +#!/bin/sh + +# from https://wiki.osdev.org/Cross-Porting_Software + +# Fill these in appropriately: +export PKG_CONFIG_SYSROOT_DIR=$JEHANNE +export PKG_CONFIG_LIBDIR=$JEHANNE/lib/pkgconfig + +# TODO: If it works this should probably just be set to the empty string. +export PKG_CONFIG_PATH=$PKG_CONFIG_LIBDIR + +# Use --static here if your OS only has static linking. +# TODO: Perhaps it's a bug in the libraries if their pkg-config files +# doesn't record that only static libraries were built. +exec pkg-config --static "$@" From 88889951db6a129762c79a263f70d032976477c8 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Mon, 26 Nov 2018 01:52:25 +0100 Subject: [PATCH 02/91] native gcc: draft libmpfr (not working) --- cross/pkgs/gcc/.gitignore | 1 + cross/pkgs/gcc/build.sh | 22 ++++++++++++++++++---- cross/pkgs/gcc/patch/libmpfr.patch | 11 +++++++++++ cross/pkgs/gcc/src/fetch.json | 12 ++++++++++++ 4 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 cross/pkgs/gcc/patch/libmpfr.patch diff --git a/cross/pkgs/gcc/.gitignore b/cross/pkgs/gcc/.gitignore index b7d701c..9025a76 100644 --- a/cross/pkgs/gcc/.gitignore +++ b/cross/pkgs/gcc/.gitignore @@ -1,2 +1,3 @@ +!src/fetch.json src/ out/ diff --git a/cross/pkgs/gcc/build.sh b/cross/pkgs/gcc/build.sh index 4882444..2bb6f04 100755 --- a/cross/pkgs/gcc/build.sh +++ b/cross/pkgs/gcc/build.sh @@ -30,11 +30,25 @@ failOnError $? "fetching sources" echo -n Building libgmp... ( - cd libgmp - patch -p0 < $WORKING_DIR/patch/libgmp.patch - ./configure --host=x86_64-jehanne --prefix=/pkgs/libgmp/6.1.2/ - make + cd libgmp && + patch -p0 < $WORKING_DIR/patch/libgmp.patch && + ./configure --host=x86_64-jehanne --prefix=/pkgs/libgmp/6.1.2/ && + make && make DESTDIR=$JEHANNE install ) >> $WORKING_DIR/gcc.build.log failOnError $? "Building libgmp" echo done. + +# Copy to /posix (to emulate bind during cross compilation) +cp $JEHANNE/pkgs/libgmp/6.1.2/* $JEHANNE/posix + +echo -n Building libmpfr... +( + cd libmpfr + patch -p0 < $WORKING_DIR/patch/libmpfr.patch + ./configure --host=x86_64-jehanne --prefix=/pkgs/libmpfr/4.0.1/ + make + make DESTDIR=$JEHANNE install +) >> $WORKING_DIR/gcc.build.log +failOnError $? "Building libmpfr" +echo done. diff --git a/cross/pkgs/gcc/patch/libmpfr.patch b/cross/pkgs/gcc/patch/libmpfr.patch new file mode 100644 index 0000000..74f3e61 --- /dev/null +++ b/cross/pkgs/gcc/patch/libmpfr.patch @@ -0,0 +1,11 @@ +diff -Naru ../orig/config.sub ./config.sub +--- ../orig/config.sub 2018-11-26 14:23:59.224388851 +0100 ++++ ./config.sub 2018-11-26 14:24:55.300412850 +0100 +@@ -1416,6 +1416,7 @@ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ ++ | -jehanne* \ + | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; diff --git a/cross/pkgs/gcc/src/fetch.json b/cross/pkgs/gcc/src/fetch.json index 47c0c9e..077ee4d 100644 --- a/cross/pkgs/gcc/src/fetch.json +++ b/cross/pkgs/gcc/src/fetch.json @@ -8,5 +8,17 @@ "RemovePrefix": true, "Exclude": [ ] + }, + + "libmpfr" : { + "Upstream":"https://www.mpfr.org/mpfr-current/mpfr-4.0.1.tar.bz2", + "Digest": { + "sha256":"a4d97610ba8579d380b384b225187c250ef88cfe1d5e7226b89519374209b86b" + }, + "Compress":"bzip2", + "RemovePrefix": true, + "Exclude": [ + ] } + } From e7ffc3d9061aa19760031680c3a6cf66725f0a95 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Mon, 26 Nov 2018 04:02:20 +0100 Subject: [PATCH 03/91] newlib: ansification + upstream update --- cross/pkgs/newlib/build.sh | 12 +++++------- cross/pkgs/newlib/src | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/cross/pkgs/newlib/build.sh b/cross/pkgs/newlib/build.sh index 5a90bb7..24c2fc8 100755 --- a/cross/pkgs/newlib/build.sh +++ b/cross/pkgs/newlib/build.sh @@ -71,7 +71,7 @@ export CC=gcc # NOTE: we use -O0 because apparently vsprintf functions do not # work with -O2. -export CFLAGS_FOR_TARGET="-g -gdwarf-2 -ggdb -O$NEWLIB_OPTIMIZATION" +export CFLAGS_FOR_TARGET="-g -gdwarf-2 -ggdb -O$NEWLIB_OPTIMIZATION -std=gnu11" ( rm -fr $NEWLIB_BUILD && @@ -79,14 +79,12 @@ export CFLAGS_FOR_TARGET="-g -gdwarf-2 -ggdb -O$NEWLIB_OPTIMIZATION" mkdir $NEWLIB_BUILD && mkdir $NEWLIB_PREFIX && cd $NEWLIB_BUILD && - $NEWLIB_SRC/configure --enable-newlib-mb --disable-newlib-fvwrite-in-streamio --prefix=$NEWLIB_PREFIX --target=x86_64-jehanne && - make all && make install && + $NEWLIB_SRC/configure --enable-newlib-mb --disable-newlib-fvwrite-in-streamio --prefix=/pkgs/newlib --target=x86_64-jehanne && + make all && make DESTDIR=$NEWLIB_PREFIX install && rm -fr $JEHANNE/sys/posix/newlib && rm -fr $JEHANNE/arch/amd64/lib/newlib && - mv $NEWLIB_PREFIX/x86_64-jehanne/include/ $JEHANNE/sys/posix/newlib && - echo "Newlib headers installed at $JEHANNE/sys/posix/newlib/" && - mv $NEWLIB_PREFIX/x86_64-jehanne/lib/ $JEHANNE/arch/amd64/lib/newlib/ && - echo "Newlib libraries installed at $JEHANNE/arch/amd64/lib/newlib/" + cp -fr $NEWLIB_PREFIX/pkgs/newlib/ $JEHANNE/pkgs/ && + echo "Newlib headers installed at $JEHANNE/pkgs/newlib/" ) >> $NEWLIB/newlib.build.log 2>&1 failOnError $? "building newlib" diff --git a/cross/pkgs/newlib/src b/cross/pkgs/newlib/src index 699179a..266d2c4 160000 --- a/cross/pkgs/newlib/src +++ b/cross/pkgs/newlib/src @@ -1 +1 @@ -Subproject commit 699179a66987482b0156645ee6fc7ea318c40d01 +Subproject commit 266d2c4d3456b39c1a989c9808499865bf6b1364 From 7401210ed2fe26e138364bb7e86d84477927139f Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Mon, 26 Nov 2018 23:29:26 +0100 Subject: [PATCH 04/91] mksh: use $JEHENNE/posix --- cross/pkgs/mksh/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cross/pkgs/mksh/build.sh b/cross/pkgs/mksh/build.sh index b7539bd..783856e 100755 --- a/cross/pkgs/mksh/build.sh +++ b/cross/pkgs/mksh/build.sh @@ -27,8 +27,8 @@ export MKSH=$CROSS_DIR/pkgs/mksh/ export MKSH_SRC=$MKSH/src/ export MKSH_BUILD=$MKSH/out/ export MKSHRC_PATH='~/lib/mkshrc' -export LIBS="$JEHANNE/arch/$ARCH/lib/newlib/libc.a $JEHANNE/arch/$ARCH/lib/newlib/libm.a $JEHANNE/arch/$ARCH/lib/newlib/libg.a -lposix -lc" -export CPPFLAGS="-I$JEHANNE/sys/posix/newlib/ '-DMKSHRC_PATH=\"$MKSHRC_PATH\"' '-DARCH=\"$ARCH\"'" +export LIBS="$JEHANNE/posix/lib/libc.a $JEHANNE/posix/lib/libm.a $JEHANNE/posix/lib/libg.a -lposix -lc" +export CPPFLAGS="'-DMKSHRC_PATH=\"$MKSHRC_PATH\"' '-DARCH=\"$ARCH\"'" export LD_PRELOAD= From 1a903c6e2fb47ec9134b6c070e165822a4764b5a Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Tue, 27 Nov 2018 00:28:08 +0100 Subject: [PATCH 05/91] gcc native: fix libgmp build; fix libmpfr build --- cross/pkgs/gcc/build.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/cross/pkgs/gcc/build.sh b/cross/pkgs/gcc/build.sh index 2bb6f04..76380f0 100755 --- a/cross/pkgs/gcc/build.sh +++ b/cross/pkgs/gcc/build.sh @@ -32,23 +32,24 @@ echo -n Building libgmp... ( cd libgmp && patch -p0 < $WORKING_DIR/patch/libgmp.patch && - ./configure --host=x86_64-jehanne --prefix=/pkgs/libgmp/6.1.2/ && + ./configure --host=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE && make && - make DESTDIR=$JEHANNE install + make DESTDIR=$JEHANNE/pkgs/libgmp/6.1.2/ install ) >> $WORKING_DIR/gcc.build.log failOnError $? "Building libgmp" echo done. # Copy to /posix (to emulate bind during cross compilation) -cp $JEHANNE/pkgs/libgmp/6.1.2/* $JEHANNE/posix +cp -fr $JEHANNE/pkgs/libgmp/6.1.2/posix/* $JEHANNE/posix echo -n Building libmpfr... ( - cd libmpfr - patch -p0 < $WORKING_DIR/patch/libmpfr.patch - ./configure --host=x86_64-jehanne --prefix=/pkgs/libmpfr/4.0.1/ - make - make DESTDIR=$JEHANNE install + cd libmpfr && + patch -p0 < $WORKING_DIR/patch/libmpfr.patch && + ./configure --host=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE --with-gmp=$JEHANNE/pkgs/libgmp/6.1.2/posix/ && + cp ../../../../patch/MakeNothing.in doc/Makefile && + make && + make DESTDIR=$JEHANNE/pkgs/libmpfr/4.0.1/ install ) >> $WORKING_DIR/gcc.build.log failOnError $? "Building libmpfr" echo done. From 229fbc96335d791973db02cd44c1e620d1527b24 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Tue, 27 Nov 2018 01:46:03 +0100 Subject: [PATCH 06/91] gcc native: build libmpc --- cross/pkgs/gcc/.gitignore | 2 +- cross/pkgs/gcc/build.sh | 22 +++++++++++++++++++++- cross/pkgs/gcc/patch/libmpc.patch | 11 +++++++++++ cross/pkgs/gcc/src/fetch.json | 11 ++++++++++- 4 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 cross/pkgs/gcc/patch/libmpc.patch diff --git a/cross/pkgs/gcc/.gitignore b/cross/pkgs/gcc/.gitignore index 9025a76..c55869c 100644 --- a/cross/pkgs/gcc/.gitignore +++ b/cross/pkgs/gcc/.gitignore @@ -1,3 +1,3 @@ -!src/fetch.json src/ +!src/fetch.json out/ diff --git a/cross/pkgs/gcc/build.sh b/cross/pkgs/gcc/build.sh index 76380f0..f1b382e 100755 --- a/cross/pkgs/gcc/build.sh +++ b/cross/pkgs/gcc/build.sh @@ -49,7 +49,27 @@ echo -n Building libmpfr... ./configure --host=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE --with-gmp=$JEHANNE/pkgs/libgmp/6.1.2/posix/ && cp ../../../../patch/MakeNothing.in doc/Makefile && make && - make DESTDIR=$JEHANNE/pkgs/libmpfr/4.0.1/ install + make DESTDIR=$JEHANNE/pkgs//4.0.1/ install ) >> $WORKING_DIR/gcc.build.log failOnError $? "Building libmpfr" echo done. + +# Copy to /posix (to emulate bind during cross compilation) +cp -fr $JEHANNE/pkgs/libmpfr/4.0.1/posix/* $JEHANNE/posix + +echo -n Building libmpc... +( + cd libmpc && + chmod u+w config.sub && + patch -p0 < $WORKING_DIR/patch/libmpc.patch && + chmod u-w config.sub && + ./configure --host=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE --with-gmp=$JEHANNE/pkgs/libgmp/6.1.2/posix/ --with-mpfr=$JEHANNE/pkgs/libmpfr/4.0.1/posix/ && + cp ../../../../patch/MakeNothing.in doc/Makefile && + make && + make DESTDIR=$JEHANNE/pkgs/libmpc/1.1.0/ install +) >> $WORKING_DIR/gcc.build.log +failOnError $? "Building libmpc" +echo done. + +# Copy to /posix (to emulate bind during cross compilation) +cp -fr $JEHANNE/pkgs/libmpc/4.0.1/posix/* $JEHANNE/posix diff --git a/cross/pkgs/gcc/patch/libmpc.patch b/cross/pkgs/gcc/patch/libmpc.patch new file mode 100644 index 0000000..b207673 --- /dev/null +++ b/cross/pkgs/gcc/patch/libmpc.patch @@ -0,0 +1,11 @@ +diff -Naru ../orig/config.sub ./config.sub +--- ../orig/config.sub 2018-11-27 00:30:59.807843647 +0100 ++++ ./config.sub 2018-11-27 00:32:49.224841688 +0100 +@@ -1393,6 +1393,7 @@ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ ++ | -jehanne* \ + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; diff --git a/cross/pkgs/gcc/src/fetch.json b/cross/pkgs/gcc/src/fetch.json index 077ee4d..dab3281 100644 --- a/cross/pkgs/gcc/src/fetch.json +++ b/cross/pkgs/gcc/src/fetch.json @@ -9,7 +9,6 @@ "Exclude": [ ] }, - "libmpfr" : { "Upstream":"https://www.mpfr.org/mpfr-current/mpfr-4.0.1.tar.bz2", "Digest": { @@ -19,6 +18,16 @@ "RemovePrefix": true, "Exclude": [ ] + }, + "libmpc" : { + "Upstream":"https://ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz", + "Digest": { + "sha256":"6985c538143c1208dcb1ac42cedad6ff52e267b47e5f970183a3e75125b43c2e" + }, + "Compress":"gzip", + "RemovePrefix": true, + "Exclude": [ + ] } } From d6d8336e8a7bdc8c8be4e600bbe41bcfae0b69c2 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Tue, 27 Nov 2018 18:53:32 +0100 Subject: [PATCH 07/91] gcc native: hopefully improvements (build.sh doesn't work yet) --- cross/pkgs/gcc/build.sh | 12 +++++------- cross/x86_64-jehanne-pkg-config | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/cross/pkgs/gcc/build.sh b/cross/pkgs/gcc/build.sh index f1b382e..3d368d2 100755 --- a/cross/pkgs/gcc/build.sh +++ b/cross/pkgs/gcc/build.sh @@ -11,14 +11,12 @@ function failOnError { # $1 -> exit status on a previous command # $2 -> task description if [ $1 -ne 0 ]; then - kill $dotter - wait $dotter 2>/dev/null echo "ERROR $2" echo echo BUILD LOG: echo - cat cross-toolchain.build.log + cat $WORKING_DIR/gcc.build.log exit $1 fi } @@ -30,7 +28,7 @@ failOnError $? "fetching sources" echo -n Building libgmp... ( - cd libgmp && + cd src/libgmp && patch -p0 < $WORKING_DIR/patch/libgmp.patch && ./configure --host=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE && make && @@ -44,12 +42,12 @@ cp -fr $JEHANNE/pkgs/libgmp/6.1.2/posix/* $JEHANNE/posix echo -n Building libmpfr... ( - cd libmpfr && + cd src/libmpfr && patch -p0 < $WORKING_DIR/patch/libmpfr.patch && ./configure --host=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE --with-gmp=$JEHANNE/pkgs/libgmp/6.1.2/posix/ && cp ../../../../patch/MakeNothing.in doc/Makefile && make && - make DESTDIR=$JEHANNE/pkgs//4.0.1/ install + make DESTDIR=$JEHANNE/pkgs/libmpfr/4.0.1/ install ) >> $WORKING_DIR/gcc.build.log failOnError $? "Building libmpfr" echo done. @@ -59,7 +57,7 @@ cp -fr $JEHANNE/pkgs/libmpfr/4.0.1/posix/* $JEHANNE/posix echo -n Building libmpc... ( - cd libmpc && + cd src/libmpc && chmod u+w config.sub && patch -p0 < $WORKING_DIR/patch/libmpc.patch && chmod u-w config.sub && diff --git a/cross/x86_64-jehanne-pkg-config b/cross/x86_64-jehanne-pkg-config index 6431f07..6e17814 100755 --- a/cross/x86_64-jehanne-pkg-config +++ b/cross/x86_64-jehanne-pkg-config @@ -4,7 +4,7 @@ # Fill these in appropriately: export PKG_CONFIG_SYSROOT_DIR=$JEHANNE -export PKG_CONFIG_LIBDIR=$JEHANNE/lib/pkgconfig +export PKG_CONFIG_LIBDIR=$JEHANNE/posix # TODO: If it works this should probably just be set to the empty string. export PKG_CONFIG_PATH=$PKG_CONFIG_LIBDIR From 1c428cd009489dad9c31ea2c0561b72b88263fe1 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Wed, 28 Nov 2018 11:47:24 +0100 Subject: [PATCH 08/91] gcc native: small fixes --- cross/pkgs/gcc/build.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cross/pkgs/gcc/build.sh b/cross/pkgs/gcc/build.sh index 3d368d2..aee6d11 100755 --- a/cross/pkgs/gcc/build.sh +++ b/cross/pkgs/gcc/build.sh @@ -23,6 +23,8 @@ function failOnError { date > $WORKING_DIR/gcc.build.log +git clean -xdf src + (cd src && fetch) >> $WORKING_DIR/gcc.build.log failOnError $? "fetching sources" @@ -38,7 +40,7 @@ failOnError $? "Building libgmp" echo done. # Copy to /posix (to emulate bind during cross compilation) -cp -fr $JEHANNE/pkgs/libgmp/6.1.2/posix/* $JEHANNE/posix +cp -pfr $JEHANNE/pkgs/libgmp/6.1.2/posix/* $JEHANNE/posix echo -n Building libmpfr... ( @@ -48,12 +50,12 @@ echo -n Building libmpfr... cp ../../../../patch/MakeNothing.in doc/Makefile && make && make DESTDIR=$JEHANNE/pkgs/libmpfr/4.0.1/ install -) >> $WORKING_DIR/gcc.build.log +) #>> $WORKING_DIR/gcc.build.log failOnError $? "Building libmpfr" echo done. # Copy to /posix (to emulate bind during cross compilation) -cp -fr $JEHANNE/pkgs/libmpfr/4.0.1/posix/* $JEHANNE/posix +cp -pfr $JEHANNE/pkgs/libmpfr/4.0.1/posix/* $JEHANNE/posix echo -n Building libmpc... ( @@ -70,4 +72,4 @@ failOnError $? "Building libmpc" echo done. # Copy to /posix (to emulate bind during cross compilation) -cp -fr $JEHANNE/pkgs/libmpc/4.0.1/posix/* $JEHANNE/posix +cp -pfr $JEHANNE/pkgs/libmpc/1.1.0/posix/* $JEHANNE/posix From f781514ecd78ff24ed7543e735520279a2784747 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Wed, 28 Nov 2018 18:32:39 +0100 Subject: [PATCH 09/91] gcc native: more build.sh --- cross/pkgs/gcc/build.sh | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/cross/pkgs/gcc/build.sh b/cross/pkgs/gcc/build.sh index aee6d11..19a67b0 100755 --- a/cross/pkgs/gcc/build.sh +++ b/cross/pkgs/gcc/build.sh @@ -28,7 +28,7 @@ git clean -xdf src (cd src && fetch) >> $WORKING_DIR/gcc.build.log failOnError $? "fetching sources" -echo -n Building libgmp... +echo -n Building libgmp... | tee -a $WORKING_DIR/gcc.build.log ( cd src/libgmp && patch -p0 < $WORKING_DIR/patch/libgmp.patch && @@ -42,7 +42,7 @@ echo done. # Copy to /posix (to emulate bind during cross compilation) cp -pfr $JEHANNE/pkgs/libgmp/6.1.2/posix/* $JEHANNE/posix -echo -n Building libmpfr... +echo -n Building libmpfr... | tee -a $WORKING_DIR/gcc.build.log ( cd src/libmpfr && patch -p0 < $WORKING_DIR/patch/libmpfr.patch && @@ -50,14 +50,31 @@ echo -n Building libmpfr... cp ../../../../patch/MakeNothing.in doc/Makefile && make && make DESTDIR=$JEHANNE/pkgs/libmpfr/4.0.1/ install -) #>> $WORKING_DIR/gcc.build.log +) >> $WORKING_DIR/gcc.build.log failOnError $? "Building libmpfr" echo done. # Copy to /posix (to emulate bind during cross compilation) cp -pfr $JEHANNE/pkgs/libmpfr/4.0.1/posix/* $JEHANNE/posix -echo -n Building libmpc... +echo -n Building libmpc... | tee -a $WORKING_DIR/gcc.build.log +( + cd src/libmpc && + chmod u+w config.sub && + patch -p0 < $WORKING_DIR/patch/libmpc.patch && + chmod u-w config.sub && + ./configure --host=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE --with-gmp=$JEHANNE/pkgs/libgmp/6.1.2/posix/ --with-mpfr=$JEHANNE/pkgs/libmpfr/4.0.1/posix/ && + cp ../../../../patch/MakeNothing.in doc/Makefile && + make && + make DESTDIR=$JEHANNE/pkgs/libmpc/1.1.0/ install +) >> $WORKING_DIR/gcc.build.log +failOnError $? "Building libmpc" +echo done. + +# Copy to /posix (to emulate bind during cross compilation) +cp -pfr $JEHANNE/pkgs/libmpc/1.1.0/posix/* $JEHANNE/posix + +echo -n Building binutils... | tee -a $WORKING_DIR/gcc.build.log ( cd src/libmpc && chmod u+w config.sub && From 705762061c46565641a0b3632e4602949218f5c6 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Wed, 28 Nov 2018 18:33:11 +0100 Subject: [PATCH 10/91] gcc native: gcc and binutils to fetch.json --- cross/pkgs/gcc/src/fetch.json | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/cross/pkgs/gcc/src/fetch.json b/cross/pkgs/gcc/src/fetch.json index dab3281..d0feedc 100644 --- a/cross/pkgs/gcc/src/fetch.json +++ b/cross/pkgs/gcc/src/fetch.json @@ -28,6 +28,26 @@ "RemovePrefix": true, "Exclude": [ ] + }, + "binutils": { + "Upstream":"http://ftp.gnu.org/gnu/binutils/binutils-2.31.tar.bz2", + "Digest": { + "sha256":"2c49536b1ca6b8900531b9e34f211a81caf9bf85b1a71f82b81ae32fcd8ffe19" + }, + "Compress":"bzip2", + "RemovePrefix": true, + "Exclude": [ + ] + }, + "gcc": { + "Upstream":"https://ftp.gnu.org/gnu/gcc/gcc-8.2.0/gcc-8.2.0.tar.gz", + "Digest": { + "sha256":"1b0f36be1045ff58cbb9c83743835367b860810f17f0195a4e093458b372020f" + }, + "Compress":"gzip", + "RemovePrefix": true, + "Exclude": [ + ] } - + } From aa0ff70ecb20a366c236e53fc45f84c167324f3e Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Thu, 29 Nov 2018 02:38:34 +0100 Subject: [PATCH 11/91] gcc native: more build.sh --- cross/pkgs/gcc/build.sh | 62 ++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/cross/pkgs/gcc/build.sh b/cross/pkgs/gcc/build.sh index 19a67b0..78730aa 100755 --- a/cross/pkgs/gcc/build.sh +++ b/cross/pkgs/gcc/build.sh @@ -11,7 +11,6 @@ function failOnError { # $1 -> exit status on a previous command # $2 -> task description if [ $1 -ne 0 ]; then - echo "ERROR $2" echo echo BUILD LOG: @@ -23,7 +22,9 @@ function failOnError { date > $WORKING_DIR/gcc.build.log -git clean -xdf src +# verify libtool is installed +libtool --version >> $WORKING_DIR/gcc.build.log +failOnError $? "libtool version" (cd src && fetch) >> $WORKING_DIR/gcc.build.log failOnError $? "fetching sources" @@ -31,26 +32,28 @@ failOnError $? "fetching sources" echo -n Building libgmp... | tee -a $WORKING_DIR/gcc.build.log ( cd src/libgmp && - patch -p0 < $WORKING_DIR/patch/libgmp.patch && + ( grep -q jehanne configfsf.sub || patch -p0 < $WORKING_DIR/patch/libgmp.patch ) && ./configure --host=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE && make && - make DESTDIR=$JEHANNE/pkgs/libgmp/6.1.2/ install -) >> $WORKING_DIR/gcc.build.log + make DESTDIR=$JEHANNE/pkgs/libgmp/6.1.2/ install && + libtool --mode=finish $JEHANNE/posix/lib +) >> $WORKING_DIR/gcc.build.log 2>&1 failOnError $? "Building libgmp" echo done. -# Copy to /posix (to emulate bind during cross compilation) +#2 Copy to /posix (to emulate bind during cross compilation) cp -pfr $JEHANNE/pkgs/libgmp/6.1.2/posix/* $JEHANNE/posix echo -n Building libmpfr... | tee -a $WORKING_DIR/gcc.build.log ( cd src/libmpfr && - patch -p0 < $WORKING_DIR/patch/libmpfr.patch && + ( grep -q jehanne config.sub || patch -p0 < $WORKING_DIR/patch/libmpfr.patch ) && ./configure --host=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE --with-gmp=$JEHANNE/pkgs/libgmp/6.1.2/posix/ && cp ../../../../patch/MakeNothing.in doc/Makefile && make && - make DESTDIR=$JEHANNE/pkgs/libmpfr/4.0.1/ install -) >> $WORKING_DIR/gcc.build.log + make DESTDIR=$JEHANNE/pkgs/libmpfr/4.0.1/ install && + libtool --mode=finish $JEHANNE/posix/lib +) >> $WORKING_DIR/gcc.build.log 2>&1 failOnError $? "Building libmpfr" echo done. @@ -60,33 +63,34 @@ cp -pfr $JEHANNE/pkgs/libmpfr/4.0.1/posix/* $JEHANNE/posix echo -n Building libmpc... | tee -a $WORKING_DIR/gcc.build.log ( cd src/libmpc && - chmod u+w config.sub && + ( grep -q jehanne config.sub || ( chmod u+w config.sub && patch -p0 < $WORKING_DIR/patch/libmpc.patch && - chmod u-w config.sub && + chmod u-w config.sub ) ) && ./configure --host=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE --with-gmp=$JEHANNE/pkgs/libgmp/6.1.2/posix/ --with-mpfr=$JEHANNE/pkgs/libmpfr/4.0.1/posix/ && cp ../../../../patch/MakeNothing.in doc/Makefile && make && - make DESTDIR=$JEHANNE/pkgs/libmpc/1.1.0/ install -) >> $WORKING_DIR/gcc.build.log + make DESTDIR=$JEHANNE/pkgs/libmpc/1.1.0/ install && + libtool --mode=finish $JEHANNE/posix/lib +) >> $WORKING_DIR/gcc.build.log 2>&1 failOnError $? "Building libmpc" echo done. # Copy to /posix (to emulate bind during cross compilation) cp -pfr $JEHANNE/pkgs/libmpc/1.1.0/posix/* $JEHANNE/posix -echo -n Building binutils... | tee -a $WORKING_DIR/gcc.build.log -( - cd src/libmpc && - chmod u+w config.sub && - patch -p0 < $WORKING_DIR/patch/libmpc.patch && - chmod u-w config.sub && - ./configure --host=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE --with-gmp=$JEHANNE/pkgs/libgmp/6.1.2/posix/ --with-mpfr=$JEHANNE/pkgs/libmpfr/4.0.1/posix/ && - cp ../../../../patch/MakeNothing.in doc/Makefile && - make && - make DESTDIR=$JEHANNE/pkgs/libmpc/1.1.0/ install -) >> $WORKING_DIR/gcc.build.log -failOnError $? "Building libmpc" -echo done. - -# Copy to /posix (to emulate bind during cross compilation) -cp -pfr $JEHANNE/pkgs/libmpc/1.1.0/posix/* $JEHANNE/posix +#echo -n Building binutils... | tee -a $WORKING_DIR/gcc.build.log +#( +# cd src/libmpc && +# chmod u+w config.sub && +# patch -p0 < $WORKING_DIR/patch/libmpc.patch && +# chmod u-w config.sub && +# ./configure --host=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE --with-gmp=$JEHANNE/pkgs/libgmp/6.1.2/posix/ --with-mpfr=$JEHANNE/pkgs/libmpfr/4.0.1/posix/ && +# cp ../../../../patch/MakeNothing.in doc/Makefile && +# make && +# make DESTDIR=$JEHANNE/pkgs/libmpc/1.1.0/ install +#) >> $WORKING_DIR/gcc.build.log +#failOnError $? "Building libmpc" +#echo done. +# +## Copy to /posix (to emulate bind during cross compilation) +#cp -pfr $JEHANNE/pkgs/libmpc/1.1.0/posix/* $JEHANNE/posix From 0fef60d69d0a19a44c4a7ac025953499de0ceb6b Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Thu, 29 Nov 2018 18:13:48 +0100 Subject: [PATCH 12/91] gcc native: draft binutils build in build.sh (not working) --- cross/pkgs/gcc/build.sh | 52 +++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/cross/pkgs/gcc/build.sh b/cross/pkgs/gcc/build.sh index 78730aa..84c533b 100755 --- a/cross/pkgs/gcc/build.sh +++ b/cross/pkgs/gcc/build.sh @@ -23,8 +23,8 @@ function failOnError { date > $WORKING_DIR/gcc.build.log # verify libtool is installed -libtool --version >> $WORKING_DIR/gcc.build.log -failOnError $? "libtool version" +libtool --version >> /dev/null +failOnError $? "libtool installation check" (cd src && fetch) >> $WORKING_DIR/gcc.build.log failOnError $? "fetching sources" @@ -78,19 +78,35 @@ echo done. # Copy to /posix (to emulate bind during cross compilation) cp -pfr $JEHANNE/pkgs/libmpc/1.1.0/posix/* $JEHANNE/posix -#echo -n Building binutils... | tee -a $WORKING_DIR/gcc.build.log -#( -# cd src/libmpc && -# chmod u+w config.sub && -# patch -p0 < $WORKING_DIR/patch/libmpc.patch && -# chmod u-w config.sub && -# ./configure --host=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE --with-gmp=$JEHANNE/pkgs/libgmp/6.1.2/posix/ --with-mpfr=$JEHANNE/pkgs/libmpfr/4.0.1/posix/ && -# cp ../../../../patch/MakeNothing.in doc/Makefile && -# make && -# make DESTDIR=$JEHANNE/pkgs/libmpc/1.1.0/ install -#) >> $WORKING_DIR/gcc.build.log -#failOnError $? "Building libmpc" -#echo done. -# -## Copy to /posix (to emulate bind during cross compilation) -#cp -pfr $JEHANNE/pkgs/libmpc/1.1.0/posix/* $JEHANNE/posix +echo -n Building binutils... | tee -a $WORKING_DIR/gcc.build.log +# Patch and build binutils +if [ "$BINUTILS_BUILD_DIR" = "" ]; then + export BINUTILS_BUILD_DIR=$WORKING_DIR/build-binutils +fi +( ( grep -q jehanne config.sub || ( + sed -i '/jehanne/b; /ELF_TARGET_ID/,/elf_backend_can_gc_sections/s/0x200000/0x1000 \/\/ jehanne hack/g' src/binutils/bfd/elf64-x86-64.c && + sed -i '/jehanne/b; s/| -tirtos/| -tirtos* | -jehanne/g' src/binutils/config.sub && + dynpatch 'binutils/bfd/config.bfd' '\# END OF targmatch.h' && + dynpatch 'binutils/gas/configure.tgt' ' i860-\*-\*)' && + ( grep -q jehanne src/binutils/ld/configure.tgt || patch -p1 < patch/binutils/ld/configure.tgt ) && + cp patch/binutils/ld/emulparams/elf_x86_64_jehanne.sh src/binutils/ld/emulparams/ && + cp patch/binutils/ld/emulparams/elf_i386_jehanne.sh src/binutils/ld/emulparams/ && + dynpatch 'binutils/ld/Makefile.am' 'eelf_x86_64.c: ' && + (grep 'eelf_i386_jehanne.c \\' src/binutils/ld/Makefile.am || sed -i 's/.*ALL_EMULATION_SOURCES = \\.*/&\n\teelf_i386_jehanne.c \\/' src/binutils/ld/Makefile.am) && + (grep 'eelf_x86_64_jehanne.c \\' src/binutils/ld/Makefile.am || sed -i 's/.*ALL_64_EMULATION_SOURCES = \\.*/&\n\teelf_x86_64_jehanne.c \\/' src/binutils/ld/Makefile.am) && + cd src/binutils/ld && automake && cd ../ ) ) && +cd $BINUTILS_BUILD_DIR && +$CROSS_DIR/src/binutils/configure --prefix=$JEHANNE/hacking/cross/toolchain --with-sysroot=$JEHANNE --target=x86_64-jehanne --enable-interwork --enable-multilib --disable-nls --disable-werror && +cp $CROSS_DIR/patch/MakeNothing.in $CROSS_DIR/src/binutils/bfd/doc/Makefile && +cp $CROSS_DIR/patch/MakeNothing.in $CROSS_DIR/src/binutils/bfd/po/Makefile && +cp $CROSS_DIR/patch/MakeNothing.in $CROSS_DIR/src/binutils/gas/doc/Makefile && +cp $CROSS_DIR/patch/MakeNothing.in $CROSS_DIR/src/binutils/binutils/doc/Makefile && +make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true && +make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true install +) >> $WORKING_DIR/gcc.build.log 2>&1 +failOnError $? "Building binutils" +fi +echo done. + +# Copy to /posix (to emulate bind during cross compilation) +cp -pfr $JEHANNE/pkgs/binutils/2.31/posix/* $JEHANNE/posix From 14f054b6f837e722e58207f34e206c02f806381f Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Thu, 28 Mar 2019 01:00:16 +0100 Subject: [PATCH 13/91] gcc native: more binutils build in build.sh --- cross/pkgs/gcc/build.sh | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/cross/pkgs/gcc/build.sh b/cross/pkgs/gcc/build.sh index 84c533b..9a4ee0a 100755 --- a/cross/pkgs/gcc/build.sh +++ b/cross/pkgs/gcc/build.sh @@ -20,6 +20,15 @@ function failOnError { fi } +function dynpatch { + # $1 -> path from $WORKING_DIR/src + # $2 -> string to search + ( cd $WORKING_DIR/src && + grep -q jehanne $1 || + sed -n -i -e "/$2/r ../patch/$1" -e '1x' -e '2,${x;p}' -e '${x;p}' $1 + ) +} + date > $WORKING_DIR/gcc.build.log # verify libtool is installed @@ -96,13 +105,13 @@ fi (grep 'eelf_x86_64_jehanne.c \\' src/binutils/ld/Makefile.am || sed -i 's/.*ALL_64_EMULATION_SOURCES = \\.*/&\n\teelf_x86_64_jehanne.c \\/' src/binutils/ld/Makefile.am) && cd src/binutils/ld && automake && cd ../ ) ) && cd $BINUTILS_BUILD_DIR && -$CROSS_DIR/src/binutils/configure --prefix=$JEHANNE/hacking/cross/toolchain --with-sysroot=$JEHANNE --target=x86_64-jehanne --enable-interwork --enable-multilib --disable-nls --disable-werror && -cp $CROSS_DIR/patch/MakeNothing.in $CROSS_DIR/src/binutils/bfd/doc/Makefile && -cp $CROSS_DIR/patch/MakeNothing.in $CROSS_DIR/src/binutils/bfd/po/Makefile && -cp $CROSS_DIR/patch/MakeNothing.in $CROSS_DIR/src/binutils/gas/doc/Makefile && -cp $CROSS_DIR/patch/MakeNothing.in $CROSS_DIR/src/binutils/binutils/doc/Makefile && +$WORKING_DIR/src/binutils/configure --prefix=/posix --with-sysroot=$JEHANNE --target=x86_64-jehanne --enable-interwork --enable-multilib --disable-nls --disable-werror && +cp $WORKING_DIR/patch/MakeNothing.in $WORKING_DIR/src/binutils/bfd/doc/Makefile && +cp $WORKING_DIR/patch/MakeNothing.in $WORKING_DIR/src/binutils/bfd/po/Makefile && +cp $WORKING_DIR/patch/MakeNothing.in $WORKING_DIR/src/binutils/gas/doc/Makefile && +cp $WORKING_DIR/patch/MakeNothing.in $WORKING_DIR/src/binutils/binutils/doc/Makefile && make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true && -make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true install +make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true DESTDIR=$JEHANNE/pkgs/binutils/2.31/ install ) >> $WORKING_DIR/gcc.build.log 2>&1 failOnError $? "Building binutils" fi From ba666b8764702c5ed8b73bf039e6fc1a7f300381 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Mon, 12 Aug 2019 01:43:07 +0200 Subject: [PATCH 14/91] newlib: update --- cross/pkgs/newlib/src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cross/pkgs/newlib/src b/cross/pkgs/newlib/src index 266d2c4..b674052 160000 --- a/cross/pkgs/newlib/src +++ b/cross/pkgs/newlib/src @@ -1 +1 @@ -Subproject commit 266d2c4d3456b39c1a989c9808499865bf6b1364 +Subproject commit b67405210112e709c0e790dcf57f3436c3d7835d From 61806bacc92564a1632f9961ac8f74e6a3c5dbf8 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Tue, 5 Nov 2019 00:19:53 +0100 Subject: [PATCH 15/91] port-gcc: more --- cross/pkgs/gcc/build.sh | 2 +- cross/pkgs/gcc/patch/binutils/bfd/config.bfd | 7 ++ .../pkgs/gcc/patch/binutils/gas/configure.tgt | 3 + cross/pkgs/gcc/patch/binutils/ld/Makefile.am | 8 ++ .../pkgs/gcc/patch/binutils/ld/configure.tgt | 25 ++++++ .../ld/emulparams/elf_i386_jehanne.sh | 4 + .../ld/emulparams/elf_x86_64_jehanne.sh | 4 + cross/pkgs/gcc/patch/gcc/config.sub | 3 + .../patch/gcc/contrib/download_prerequisites | 71 +++++++++++++++ .../gcc/patch/gcc/fixincludes/mkfixinc.sh | 1 + cross/pkgs/gcc/patch/gcc/gcc/config.gcc | 31 +++++++ cross/pkgs/gcc/patch/gcc/gcc/config/jehanne.h | 90 +++++++++++++++++++ cross/pkgs/gcc/patch/gcc/libgcc/config.host | 4 + .../pkgs/gcc/patch/gcc/libgcc/config.host.sed | 3 + .../gcc/patch/gcc/libstdc++-v3/crossconfig.m4 | 6 ++ 15 files changed, 261 insertions(+), 1 deletion(-) create mode 100644 cross/pkgs/gcc/patch/binutils/bfd/config.bfd create mode 100644 cross/pkgs/gcc/patch/binutils/gas/configure.tgt create mode 100644 cross/pkgs/gcc/patch/binutils/ld/Makefile.am create mode 100644 cross/pkgs/gcc/patch/binutils/ld/configure.tgt create mode 100644 cross/pkgs/gcc/patch/binutils/ld/emulparams/elf_i386_jehanne.sh create mode 100644 cross/pkgs/gcc/patch/binutils/ld/emulparams/elf_x86_64_jehanne.sh create mode 100644 cross/pkgs/gcc/patch/gcc/config.sub create mode 100644 cross/pkgs/gcc/patch/gcc/contrib/download_prerequisites create mode 100644 cross/pkgs/gcc/patch/gcc/fixincludes/mkfixinc.sh create mode 100644 cross/pkgs/gcc/patch/gcc/gcc/config.gcc create mode 100644 cross/pkgs/gcc/patch/gcc/gcc/config/jehanne.h create mode 100644 cross/pkgs/gcc/patch/gcc/libgcc/config.host create mode 100644 cross/pkgs/gcc/patch/gcc/libgcc/config.host.sed create mode 100644 cross/pkgs/gcc/patch/gcc/libstdc++-v3/crossconfig.m4 diff --git a/cross/pkgs/gcc/build.sh b/cross/pkgs/gcc/build.sh index 9a4ee0a..ef25615 100755 --- a/cross/pkgs/gcc/build.sh +++ b/cross/pkgs/gcc/build.sh @@ -92,7 +92,7 @@ echo -n Building binutils... | tee -a $WORKING_DIR/gcc.build.log if [ "$BINUTILS_BUILD_DIR" = "" ]; then export BINUTILS_BUILD_DIR=$WORKING_DIR/build-binutils fi -( ( grep -q jehanne config.sub || ( +( ( grep -q jehanne src/binutils/config.sub || ( sed -i '/jehanne/b; /ELF_TARGET_ID/,/elf_backend_can_gc_sections/s/0x200000/0x1000 \/\/ jehanne hack/g' src/binutils/bfd/elf64-x86-64.c && sed -i '/jehanne/b; s/| -tirtos/| -tirtos* | -jehanne/g' src/binutils/config.sub && dynpatch 'binutils/bfd/config.bfd' '\# END OF targmatch.h' && diff --git a/cross/pkgs/gcc/patch/binutils/bfd/config.bfd b/cross/pkgs/gcc/patch/binutils/bfd/config.bfd new file mode 100644 index 0000000..d707602 --- /dev/null +++ b/cross/pkgs/gcc/patch/binutils/bfd/config.bfd @@ -0,0 +1,7 @@ +#ifdef BFD64 + x86_64-*-jehanne*) + targ_defvec=x86_64_elf64_vec + targ_selvecs=i386_elf32_vec + want64=true + ;; +#endif diff --git a/cross/pkgs/gcc/patch/binutils/gas/configure.tgt b/cross/pkgs/gcc/patch/binutils/gas/configure.tgt new file mode 100644 index 0000000..238f7e8 --- /dev/null +++ b/cross/pkgs/gcc/patch/binutils/gas/configure.tgt @@ -0,0 +1,3 @@ + i386-*-jehanne*) fmt=elf em=gnu ;; + + diff --git a/cross/pkgs/gcc/patch/binutils/ld/Makefile.am b/cross/pkgs/gcc/patch/binutils/ld/Makefile.am new file mode 100644 index 0000000..35a321e --- /dev/null +++ b/cross/pkgs/gcc/patch/binutils/ld/Makefile.am @@ -0,0 +1,8 @@ +eelf_i386_jehanne.c: $(srcdir)/emulparams/elf_i386_jehanne.sh \ + $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + ${GENSCRIPTS} elf_i386_jehanne "$(tdir_elf_i386_jehanne)" + +eelf_x86_64_jehanne.c: $(srcdir)/emulparams/elf_x86_64_jehanne.sh \ + $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + ${GENSCRIPTS} elf_x86_64_jehanne "$(tdir_elf_x86_64_jehanne)" + diff --git a/cross/pkgs/gcc/patch/binutils/ld/configure.tgt b/cross/pkgs/gcc/patch/binutils/ld/configure.tgt new file mode 100644 index 0000000..27ef033 --- /dev/null +++ b/cross/pkgs/gcc/patch/binutils/ld/configure.tgt @@ -0,0 +1,25 @@ +diff --git a/src/binutils/ld/configure.tgt b/src/binutils/ld/configure.tgt +index fad8b2e..ba3ddc9 100644 +--- a/src/binutils/ld/configure.tgt ++++ b/src/binutils/ld/configure.tgt +@@ -370,6 +370,9 @@ targ_extra_emuls="elf_i386_nacl elf_x86_64_nacl armelf_nacl armelfb_nacl" + targ_extra_libpath=$targ_extra_emuls + tdir_elf_i386_nacl=`echo ${targ_alias} | sed -e 's/x86_64/i386/'` + ;; ++x86_64*-jehanne*) targ_emul=elf_x86_64_jehanne ++ targ_extra_emuls="elf_i386_jehanne elf_x86_64 elf_i386" ++ ;; + ia16-*-elf*) targ_emul=elf_i386 targ_extra_emuls=i386msdos ;; + ia64-*-elf*) targ_emul=elf64_ia64 ;; + ia64-*-freebsd* | ia64-*-kfreebsd*-gnu) +@@ -806,6 +809,10 @@ ia64-*-aix*) + NATIVE_LIB_DIRS='/usr/local/lib /usr/lib/ia64l64 /lib /usr/lib' + ;; + ++x86_64-*-jehanne*) ++ NATIVE_LIB_DIRS='/arch/amd64/lib' ++ ;; ++ + sparc*-*-solaris2*) + NATIVE_LIB_DIRS='/usr/local/lib /usr/ccs/lib /lib /usr/lib' + ;; diff --git a/cross/pkgs/gcc/patch/binutils/ld/emulparams/elf_i386_jehanne.sh b/cross/pkgs/gcc/patch/binutils/ld/emulparams/elf_i386_jehanne.sh new file mode 100644 index 0000000..54decda --- /dev/null +++ b/cross/pkgs/gcc/patch/binutils/ld/emulparams/elf_i386_jehanne.sh @@ -0,0 +1,4 @@ +. ${srcdir}/emulparams/elf_i386.sh +GENERATE_SHLIB_SCRIPT= +GENERATE_PIE_SCRIPT=yes +ENTRY=_main diff --git a/cross/pkgs/gcc/patch/binutils/ld/emulparams/elf_x86_64_jehanne.sh b/cross/pkgs/gcc/patch/binutils/ld/emulparams/elf_x86_64_jehanne.sh new file mode 100644 index 0000000..dd2b5c7 --- /dev/null +++ b/cross/pkgs/gcc/patch/binutils/ld/emulparams/elf_x86_64_jehanne.sh @@ -0,0 +1,4 @@ +. ${srcdir}/emulparams/elf_x86_64.sh +GENERATE_SHLIB_SCRIPT= +GENERATE_PIE_SCRIPT=yes +ENTRY=_main diff --git a/cross/pkgs/gcc/patch/gcc/config.sub b/cross/pkgs/gcc/patch/gcc/config.sub new file mode 100644 index 0000000..9555a9b --- /dev/null +++ b/cross/pkgs/gcc/patch/gcc/config.sub @@ -0,0 +1,3 @@ + -jehanne*) + os=-jehanne + ;; diff --git a/cross/pkgs/gcc/patch/gcc/contrib/download_prerequisites b/cross/pkgs/gcc/patch/gcc/contrib/download_prerequisites new file mode 100644 index 0000000..932dc36 --- /dev/null +++ b/cross/pkgs/gcc/patch/gcc/contrib/download_prerequisites @@ -0,0 +1,71 @@ +#! /bin/sh + +# Download some prerequisites needed by gcc. +# Run this from the top level of the gcc source tree and the gcc +# build will do the right thing. +# +# (C) 2010 Free Software Foundation +# +# This program 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, either version 3 of the License, or +# (at your option) any later version. +# +# This program 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 this program. If not, see http://www.gnu.org/licenses/. + +# If you want to build GCC with the Graphite loop optimizations, +# set GRAPHITE_LOOP_OPT=yes to download optional prerequisties +# ISL Library and CLooG. +GRAPHITE_LOOP_OPT=yes + +if [ ! -e gcc/BASE-VER ] ; then + echo "You must run this script in the top level GCC source directory." + exit 1 +fi + +# Necessary to build GCC. +MPFR=mpfr-2.4.2 +GMP=gmp-4.3.2 +MPC=mpc-0.8.1 + +if [ ! -d $MPFR ]; then + wget http://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/infrastructure/$MPFR.tar.bz2 || exit 1 + tar xjf $MPFR.tar.bz2 || exit 1 + ln -sf $MPFR mpfr || exit 1 +fi + +if [ ! -d $GMP ]; then + wget http://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/infrastructure/$GMP.tar.bz2 || exit 1 + tar xjf $GMP.tar.bz2 || exit 1 + ln -sf $GMP gmp || exit 1 +fi + +if [ ! -d $MPC ]; then + wget http://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/infrastructure/$MPC.tar.gz || exit 1 + tar xzf $MPC.tar.gz || exit 1 + ln -sf $MPC mpc || exit 1 +fi + +# Necessary to build GCC with the Graphite loop optimizations. +if [ "$GRAPHITE_LOOP_OPT" = "yes" ] ; then + ISL=isl-0.12.2 + CLOOG=cloog-0.18.1 + + if [ ! -d $ISL ]; then + wget http://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/infrastructure/$ISL.tar.bz2 || exit 1 + tar xjf $ISL.tar.bz2 || exit 1 + ln -sf $ISL isl || exit 1 + fi + + if [ ! -d $CLOOG ]; then + wget http://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/infrastructure/$CLOOG.tar.gz || exit 1 + tar xzf $CLOOG.tar.gz || exit 1 + ln -sf $CLOOG cloog || exit 1 + fi +fi diff --git a/cross/pkgs/gcc/patch/gcc/fixincludes/mkfixinc.sh b/cross/pkgs/gcc/patch/gcc/fixincludes/mkfixinc.sh new file mode 100644 index 0000000..dc0e343 --- /dev/null +++ b/cross/pkgs/gcc/patch/gcc/fixincludes/mkfixinc.sh @@ -0,0 +1 @@ + *-jehanne* | \ diff --git a/cross/pkgs/gcc/patch/gcc/gcc/config.gcc b/cross/pkgs/gcc/patch/gcc/gcc/config.gcc new file mode 100644 index 0000000..0ee95ab --- /dev/null +++ b/cross/pkgs/gcc/patch/gcc/gcc/config.gcc @@ -0,0 +1,31 @@ +diff --git a/src/gcc/gcc/config.gcc b/src/gcc/gcc/config.gcc +index f02ddbd..e5ebfe0 100644 +--- a/src/gcc/gcc/config.gcc ++++ b/src/gcc/gcc/config.gcc +@@ -862,6 +862,16 @@ case ${target} in + tmake_file="$tmake_file vms/t-vmsnative" + fi + ;; ++*-*-jehanne*) ++ gas=yes ++ gnu_ld=yes ++ default_use_cxa_atexit=yes ++ case $target in ++ x86_64-*) ++ native_system_header_dir="/arch/amd64/include" ++ ;; ++ esac ++ ;; + *-*-vxworks*) + tmake_file=t-vxworks + xm_defines=POSIX +@@ -1347,6 +1357,9 @@ x86_64-*-darwin*) + 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" ++ ;; + 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/pkgs/gcc/patch/gcc/gcc/config/jehanne.h b/cross/pkgs/gcc/patch/gcc/gcc/config/jehanne.h new file mode 100644 index 0000000..1977cfb --- /dev/null +++ b/cross/pkgs/gcc/patch/gcc/gcc/config/jehanne.h @@ -0,0 +1,90 @@ +/* + * This file is part of Jehanne. + * + * Copyright (C) 2016 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 . + */ + +#undef TARGET_JEHANNE +#define TARGET_JEHANNE 1 + +/* Default arguments you want when running x86_64-jehanne-gcc */ +#undef LIB_SPEC +#define LIB_SPEC "-lc" + +#undef STANDARD_STARTFILE_PREFIX +#define STANDARD_STARTFILE_PREFIX "/arch/amd64/lib/" + +#undef MD_STARTFILE_PREFIX +#define MD_STARTFILE_PREFIX "/arch/amd64/lib/" + +#undef GPLUSPLUS_INCLUDE_DIR +#define GPLUSPLUS_INCLUDE_DIR "/posix/g++" + +#undef GCC_INCLUDE_DIR +#define GCC_INCLUDE_DIR "/posix/gcc" + +/* Architecture specific header (u.h) goes here (from config.gcc) */ +#define ARCH_INCLUDE_DIR NATIVE_SYSTEM_HEADER_DIR + +/* The default include dir is /sys/include but... */ +#define PORTABLE_INCLUDE_DIR "/sys/include" + +#define POSIX_INCLUDE_DIR "/posix/include" + +/* ...we have to wrap libc.h and stdio.h with basic POSIX headers */ +#define BASIC_POSIX_INCLUDE_DIR "/sys/include/apw" + +#undef INCLUDE_DEFAULTS +#define INCLUDE_DEFAULTS \ + { \ + { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, 1, 0 }, \ + { GCC_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ + { POSIX_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ + { BASIC_POSIX_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ + { ARCH_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ + { PORTABLE_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ + { ".", 0, 0, 0, 1, 0 }, \ + { 0, 0, 0, 0, 0, 0 } \ + } + +/* Files that are linked before user code. + The %s tells gcc to look for these files in the library directory. */ +#undef STARTFILE_SPEC +#define STARTFILE_SPEC "crt0.o%s crti.o%s crtbegin.o%s" + +/* Files that are linked after user code. */ +#undef ENDFILE_SPEC +#define ENDFILE_SPEC "crtend.o%s crtn.o%s" + +/* Don't automatically add extern "C" { } around header files. */ +#undef NO_IMPLICIT_EXTERN_C +#define NO_IMPLICIT_EXTERN_C 1 + +/* Fix https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67132 */ +#undef WCHAR_TYPE +#define WCHAR_TYPE "unsigned int" +#undef WCHAR_TYPE_SIZE +#define WCHAR_TYPE_SIZE 32 + +#undef LINK_GCC_C_SEQUENCE_SPEC +#define LINK_GCC_C_SEQUENCE_SPEC "%G %L" + +/* Additional predefined macros. */ +#undef TARGET_OS_CPP_BUILTINS +#define TARGET_OS_CPP_BUILTINS() \ + do { \ + builtin_define ("__jehanne__"); \ + builtin_assert ("system=jehanne"); \ + } while(0); diff --git a/cross/pkgs/gcc/patch/gcc/libgcc/config.host b/cross/pkgs/gcc/patch/gcc/libgcc/config.host new file mode 100644 index 0000000..390276f --- /dev/null +++ b/cross/pkgs/gcc/patch/gcc/libgcc/config.host @@ -0,0 +1,4 @@ +x86_64-*-jehanne*) + extra_parts="$extra_parts crtbegin.o crtend.o" + tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic" + ;; diff --git a/cross/pkgs/gcc/patch/gcc/libgcc/config.host.sed b/cross/pkgs/gcc/patch/gcc/libgcc/config.host.sed new file mode 100644 index 0000000..6854d52 --- /dev/null +++ b/cross/pkgs/gcc/patch/gcc/libgcc/config.host.sed @@ -0,0 +1,3 @@ +/enable_execute_stack=enable-execute-stack-empty.c;/,/Configuration ${host} not supported/{ + /^case ${host} in$/r ../patch/gcc/libgcc/config.host +} diff --git a/cross/pkgs/gcc/patch/gcc/libstdc++-v3/crossconfig.m4 b/cross/pkgs/gcc/patch/gcc/libstdc++-v3/crossconfig.m4 new file mode 100644 index 0000000..a74ca37 --- /dev/null +++ b/cross/pkgs/gcc/patch/gcc/libstdc++-v3/crossconfig.m4 @@ -0,0 +1,6 @@ + *-jehanne*) + GLIBCXX_CHECK_COMPILER_FEATURES + GLIBCXX_CHECK_LINKER_FEATURES + GLIBCXX_CHECK_MATH_SUPPORT + GLIBCXX_CHECK_STDLIB_SUPPORT + ;; From fc3f76eb31ab6094399458abcaa69c58d8dd27db Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Tue, 5 Nov 2019 00:22:29 +0100 Subject: [PATCH 16/91] gcc native: build binutils --- cross/pkgs/gcc/build.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cross/pkgs/gcc/build.sh b/cross/pkgs/gcc/build.sh index ef25615..9e86395 100755 --- a/cross/pkgs/gcc/build.sh +++ b/cross/pkgs/gcc/build.sh @@ -94,9 +94,9 @@ if [ "$BINUTILS_BUILD_DIR" = "" ]; then fi ( ( grep -q jehanne src/binutils/config.sub || ( sed -i '/jehanne/b; /ELF_TARGET_ID/,/elf_backend_can_gc_sections/s/0x200000/0x1000 \/\/ jehanne hack/g' src/binutils/bfd/elf64-x86-64.c && - sed -i '/jehanne/b; s/| -tirtos/| -tirtos* | -jehanne/g' src/binutils/config.sub && + sed -i '/jehanne/b; s/| midnightbsd\*/| midnightbsd* | jehanne*/g' src/binutils/config.sub && dynpatch 'binutils/bfd/config.bfd' '\# END OF targmatch.h' && - dynpatch 'binutils/gas/configure.tgt' ' i860-\*-\*)' && + dynpatch 'binutils/gas/configure.tgt' ' i386-\*-darwin\*)' && ( grep -q jehanne src/binutils/ld/configure.tgt || patch -p1 < patch/binutils/ld/configure.tgt ) && cp patch/binutils/ld/emulparams/elf_x86_64_jehanne.sh src/binutils/ld/emulparams/ && cp patch/binutils/ld/emulparams/elf_i386_jehanne.sh src/binutils/ld/emulparams/ && @@ -104,12 +104,12 @@ fi (grep 'eelf_i386_jehanne.c \\' src/binutils/ld/Makefile.am || sed -i 's/.*ALL_EMULATION_SOURCES = \\.*/&\n\teelf_i386_jehanne.c \\/' src/binutils/ld/Makefile.am) && (grep 'eelf_x86_64_jehanne.c \\' src/binutils/ld/Makefile.am || sed -i 's/.*ALL_64_EMULATION_SOURCES = \\.*/&\n\teelf_x86_64_jehanne.c \\/' src/binutils/ld/Makefile.am) && cd src/binutils/ld && automake && cd ../ ) ) && -cd $BINUTILS_BUILD_DIR && +mkdir -p $BINUTILS_BUILD_DIR && cd $BINUTILS_BUILD_DIR && $WORKING_DIR/src/binutils/configure --prefix=/posix --with-sysroot=$JEHANNE --target=x86_64-jehanne --enable-interwork --enable-multilib --disable-nls --disable-werror && -cp $WORKING_DIR/patch/MakeNothing.in $WORKING_DIR/src/binutils/bfd/doc/Makefile && -cp $WORKING_DIR/patch/MakeNothing.in $WORKING_DIR/src/binutils/bfd/po/Makefile && -cp $WORKING_DIR/patch/MakeNothing.in $WORKING_DIR/src/binutils/gas/doc/Makefile && -cp $WORKING_DIR/patch/MakeNothing.in $WORKING_DIR/src/binutils/binutils/doc/Makefile && +cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/bfd/doc/Makefile && +cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/bfd/po/Makefile && +cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/gas/doc/Makefile && +cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/binutils/doc/Makefile && make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true && make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true DESTDIR=$JEHANNE/pkgs/binutils/2.31/ install ) >> $WORKING_DIR/gcc.build.log 2>&1 From b866bb47cfd4c2ce51037f61957b140247ce9e3a Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Tue, 5 Nov 2019 00:35:42 +0100 Subject: [PATCH 17/91] gcc native: fix mpfr version in mpfr --- cross/pkgs/gcc/src/fetch.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cross/pkgs/gcc/src/fetch.json b/cross/pkgs/gcc/src/fetch.json index d0feedc..05a30b8 100644 --- a/cross/pkgs/gcc/src/fetch.json +++ b/cross/pkgs/gcc/src/fetch.json @@ -10,7 +10,7 @@ ] }, "libmpfr" : { - "Upstream":"https://www.mpfr.org/mpfr-current/mpfr-4.0.1.tar.bz2", + "Upstream":"https://www.mpfr.org/mpfr-4.0.1/mpfr-4.0.1.tar.bz2", "Digest": { "sha256":"a4d97610ba8579d380b384b225187c250ef88cfe1d5e7226b89519374209b86b" }, From 62881baa8c19e47bfa467b6b991027051a214a0d Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Tue, 5 Nov 2019 00:51:04 +0100 Subject: [PATCH 18/91] gcc native: build.sh reindent --- cross/pkgs/gcc/build.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cross/pkgs/gcc/build.sh b/cross/pkgs/gcc/build.sh index 9e86395..1a8a50b 100755 --- a/cross/pkgs/gcc/build.sh +++ b/cross/pkgs/gcc/build.sh @@ -104,14 +104,14 @@ fi (grep 'eelf_i386_jehanne.c \\' src/binutils/ld/Makefile.am || sed -i 's/.*ALL_EMULATION_SOURCES = \\.*/&\n\teelf_i386_jehanne.c \\/' src/binutils/ld/Makefile.am) && (grep 'eelf_x86_64_jehanne.c \\' src/binutils/ld/Makefile.am || sed -i 's/.*ALL_64_EMULATION_SOURCES = \\.*/&\n\teelf_x86_64_jehanne.c \\/' src/binutils/ld/Makefile.am) && cd src/binutils/ld && automake && cd ../ ) ) && -mkdir -p $BINUTILS_BUILD_DIR && cd $BINUTILS_BUILD_DIR && -$WORKING_DIR/src/binutils/configure --prefix=/posix --with-sysroot=$JEHANNE --target=x86_64-jehanne --enable-interwork --enable-multilib --disable-nls --disable-werror && -cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/bfd/doc/Makefile && -cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/bfd/po/Makefile && -cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/gas/doc/Makefile && -cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/binutils/doc/Makefile && -make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true && -make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true DESTDIR=$JEHANNE/pkgs/binutils/2.31/ install + mkdir -p $BINUTILS_BUILD_DIR && cd $BINUTILS_BUILD_DIR && + $WORKING_DIR/src/binutils/configure --prefix=/posix --with-sysroot=$JEHANNE --target=x86_64-jehanne --enable-interwork --enable-multilib --disable-nls --disable-werror && + cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/bfd/doc/Makefile && + cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/bfd/po/Makefile && + cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/gas/doc/Makefile && + cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/binutils/doc/Makefile && + make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true && + make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true DESTDIR=$JEHANNE/pkgs/binutils/2.31/ install ) >> $WORKING_DIR/gcc.build.log 2>&1 failOnError $? "Building binutils" fi From 9a5e6673e82eb96d57e99bf8628c6bbb9ed0848b Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Wed, 6 Nov 2019 00:08:44 +0100 Subject: [PATCH 19/91] gcc native: patch/gcc/gcc/config.gcc --- cross/pkgs/gcc/patch/gcc/gcc/config.gcc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/cross/pkgs/gcc/patch/gcc/gcc/config.gcc b/cross/pkgs/gcc/patch/gcc/gcc/config.gcc index 0ee95ab..d4f19ab 100644 --- a/cross/pkgs/gcc/patch/gcc/gcc/config.gcc +++ b/cross/pkgs/gcc/patch/gcc/gcc/config.gcc @@ -2,9 +2,8 @@ diff --git a/src/gcc/gcc/config.gcc b/src/gcc/gcc/config.gcc index f02ddbd..e5ebfe0 100644 --- a/src/gcc/gcc/config.gcc +++ b/src/gcc/gcc/config.gcc -@@ -862,6 +862,16 @@ case ${target} in - tmake_file="$tmake_file vms/t-vmsnative" - fi +@@ -862,6 +862,16 @@ esac + tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC SINGLE_LIBC" ;; +*-*-jehanne*) + gas=yes @@ -16,9 +15,9 @@ index f02ddbd..e5ebfe0 100644 + ;; + esac + ;; - *-*-vxworks*) - tmake_file=t-vxworks - xm_defines=POSIX + *-*-rdos*) + use_gcc_stdint=wrap + ;; @@ -1347,6 +1357,9 @@ x86_64-*-darwin*) i[34567]86-*-elf*) tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/i386elf.h" From 8f6f592374a10d2d38bb8b6a12710f5815db6c31 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Wed, 6 Nov 2019 00:34:50 +0100 Subject: [PATCH 20/91] gcc native: upgrade to binutils-2.33.1 and gcc-9.2.0 --- cross/pkgs/gcc/build.sh | 45 +++++++++++++++++++++++++++++++++-- cross/pkgs/gcc/src/fetch.json | 8 +++---- 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/cross/pkgs/gcc/build.sh b/cross/pkgs/gcc/build.sh index 1a8a50b..443ccb8 100755 --- a/cross/pkgs/gcc/build.sh +++ b/cross/pkgs/gcc/build.sh @@ -92,6 +92,9 @@ echo -n Building binutils... | tee -a $WORKING_DIR/gcc.build.log if [ "$BINUTILS_BUILD_DIR" = "" ]; then export BINUTILS_BUILD_DIR=$WORKING_DIR/build-binutils fi +if [ ! -d $BINUTILS_BUILD_DIR ]; then + mkdir $BINUTILS_BUILD_DIR +fi ( ( grep -q jehanne src/binutils/config.sub || ( sed -i '/jehanne/b; /ELF_TARGET_ID/,/elf_backend_can_gc_sections/s/0x200000/0x1000 \/\/ jehanne hack/g' src/binutils/bfd/elf64-x86-64.c && sed -i '/jehanne/b; s/| midnightbsd\*/| midnightbsd* | jehanne*/g' src/binutils/config.sub && @@ -111,11 +114,49 @@ fi cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/gas/doc/Makefile && cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/binutils/doc/Makefile && make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true && - make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true DESTDIR=$JEHANNE/pkgs/binutils/2.31/ install + make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true DESTDIR=$JEHANNE/pkgs/binutils/2.33.1/ install ) >> $WORKING_DIR/gcc.build.log 2>&1 failOnError $? "Building binutils" fi echo done. # Copy to /posix (to emulate bind during cross compilation) -cp -pfr $JEHANNE/pkgs/binutils/2.31/posix/* $JEHANNE/posix +cp -pfr $JEHANNE/pkgs/binutils/2.33.1/posix/* $JEHANNE/posix + + +#echo -n Building gcc... | tee -a $WORKING_DIR/gcc.build.log +## Patch and build gcc +#if [ "$GCC_BUILD_DIR" = "" ]; then +# export GCC_BUILD_DIR=$WORKING_DIR/build-gcc +#fi +#if [ ! -d $GCC_BUILD_DIR ]; then +# mkdir $GCC_BUILD_DIR +#fi +#( +# pwd && +# ( grep -q jehanne src/gcc/gcc/config.gcc || patch -p1 < patch/gcc/gcc/config.gcc ) && +# cd src && +# cp ../patch/gcc/contrib/download_prerequisites gcc/contrib/download_prerequisites && +# ( cd gcc && ./contrib/download_prerequisites ) && +# dynpatch 'gcc/config.sub' '-none)' && +# cp ../patch/gcc/gcc/config/jehanne.h gcc/gcc/config && +# dynpatch 'gcc/libstdc++-v3/crossconfig.m4' ' \*)' && +# cd gcc/libstdc++-v3 && autoconf -i && cd ../../ && +# ( pwd && grep -q jehanne gcc/libgcc/config.host || +# sed -i -f ../patch/gcc/libgcc/config.host.sed gcc/libgcc/config.host +# ) && +# dynpatch 'gcc/fixincludes/mkfixinc.sh' 'i\?86-\*-cygwin\*' && +# cd $GCC_BUILD_DIR && +# $CROSS_DIR/src/gcc/configure --target=x86_64-jehanne --prefix=$JEHANNE/hacking/cross/toolchain --with-sysroot=$JEHANNE --enable-languages=c,c++ && +# make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true all-gcc all-target-libgcc && +# make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true install-gcc install-target-libgcc +## && +## make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true all-target-libstdc++-v3 && +## make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true install-target-libstdc++-v3 +#) >> cross-toolchain.build.log 2>&1 +#failOnError $? "building gcc" +# +## add sh +#ln -sf /bin/bash $JEHANNE/hacking/cross/toolchain/bin/x86_64-jehanne-sh + +echo "done." diff --git a/cross/pkgs/gcc/src/fetch.json b/cross/pkgs/gcc/src/fetch.json index 05a30b8..6ea8069 100644 --- a/cross/pkgs/gcc/src/fetch.json +++ b/cross/pkgs/gcc/src/fetch.json @@ -30,9 +30,9 @@ ] }, "binutils": { - "Upstream":"http://ftp.gnu.org/gnu/binutils/binutils-2.31.tar.bz2", + "Upstream":"http://ftp.gnu.org/gnu/binutils/binutils-2.33.1.tar.bz2", "Digest": { - "sha256":"2c49536b1ca6b8900531b9e34f211a81caf9bf85b1a71f82b81ae32fcd8ffe19" + "sha256":"0cb4843da15a65a953907c96bad658283f3c4419d6bcc56bf2789db16306adb2" }, "Compress":"bzip2", "RemovePrefix": true, @@ -40,9 +40,9 @@ ] }, "gcc": { - "Upstream":"https://ftp.gnu.org/gnu/gcc/gcc-8.2.0/gcc-8.2.0.tar.gz", + "Upstream":"https://ftp.gnu.org/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.gz", "Digest": { - "sha256":"1b0f36be1045ff58cbb9c83743835367b860810f17f0195a4e093458b372020f" + "sha256":"a931a750d6feadacbeecb321d73925cd5ebb6dfa7eff0802984af3aef63759f4" }, "Compress":"gzip", "RemovePrefix": true, From 23c117a97e22798a2637dc5b9c38f63389489143 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Fri, 8 Nov 2019 01:43:04 +0100 Subject: [PATCH 21/91] gcc native: almost there --- cross/pkgs/gcc/build.sh | 63 ++++++++-------- cross/pkgs/gcc/patch/gcc.patch | 71 +++++++++++++++++++ cross/pkgs/gcc/patch/gcc/config.sub | 3 - .../patch/gcc/contrib/download_prerequisites | 71 ------------------- .../gcc/patch/gcc/fixincludes/mkfixinc.sh | 1 - cross/pkgs/gcc/patch/gcc/gcc/config.gcc | 30 -------- cross/pkgs/gcc/patch/gcc/gcc/config/jehanne.h | 6 +- cross/pkgs/gcc/patch/gcc/libgcc/config.host | 4 -- .../pkgs/gcc/patch/gcc/libgcc/config.host.sed | 3 - .../gcc/patch/gcc/libstdc++-v3/crossconfig.m4 | 6 -- 10 files changed, 104 insertions(+), 154 deletions(-) create mode 100644 cross/pkgs/gcc/patch/gcc.patch delete mode 100644 cross/pkgs/gcc/patch/gcc/config.sub delete mode 100644 cross/pkgs/gcc/patch/gcc/contrib/download_prerequisites delete mode 100644 cross/pkgs/gcc/patch/gcc/fixincludes/mkfixinc.sh delete mode 100644 cross/pkgs/gcc/patch/gcc/gcc/config.gcc delete mode 100644 cross/pkgs/gcc/patch/gcc/libgcc/config.host delete mode 100644 cross/pkgs/gcc/patch/gcc/libgcc/config.host.sed delete mode 100644 cross/pkgs/gcc/patch/gcc/libstdc++-v3/crossconfig.m4 diff --git a/cross/pkgs/gcc/build.sh b/cross/pkgs/gcc/build.sh index 443ccb8..fdb1218 100755 --- a/cross/pkgs/gcc/build.sh +++ b/cross/pkgs/gcc/build.sh @@ -124,39 +124,40 @@ echo done. cp -pfr $JEHANNE/pkgs/binutils/2.33.1/posix/* $JEHANNE/posix -#echo -n Building gcc... | tee -a $WORKING_DIR/gcc.build.log -## Patch and build gcc -#if [ "$GCC_BUILD_DIR" = "" ]; then -# export GCC_BUILD_DIR=$WORKING_DIR/build-gcc -#fi -#if [ ! -d $GCC_BUILD_DIR ]; then -# mkdir $GCC_BUILD_DIR -#fi -#( -# pwd && -# ( grep -q jehanne src/gcc/gcc/config.gcc || patch -p1 < patch/gcc/gcc/config.gcc ) && -# cd src && -# cp ../patch/gcc/contrib/download_prerequisites gcc/contrib/download_prerequisites && -# ( cd gcc && ./contrib/download_prerequisites ) && -# dynpatch 'gcc/config.sub' '-none)' && -# cp ../patch/gcc/gcc/config/jehanne.h gcc/gcc/config && -# dynpatch 'gcc/libstdc++-v3/crossconfig.m4' ' \*)' && -# cd gcc/libstdc++-v3 && autoconf -i && cd ../../ && -# ( pwd && grep -q jehanne gcc/libgcc/config.host || -# sed -i -f ../patch/gcc/libgcc/config.host.sed gcc/libgcc/config.host -# ) && -# dynpatch 'gcc/fixincludes/mkfixinc.sh' 'i\?86-\*-cygwin\*' && -# cd $GCC_BUILD_DIR && -# $CROSS_DIR/src/gcc/configure --target=x86_64-jehanne --prefix=$JEHANNE/hacking/cross/toolchain --with-sysroot=$JEHANNE --enable-languages=c,c++ && -# make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true all-gcc all-target-libgcc && -# make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true install-gcc install-target-libgcc -## && -## make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true all-target-libstdc++-v3 && -## make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true install-target-libstdc++-v3 -#) >> cross-toolchain.build.log 2>&1 -#failOnError $? "building gcc" +echo -n Building gcc... | tee -a $WORKING_DIR/gcc.build.log +# Patch and build gcc +if [ "$GCC_BUILD_DIR" = "" ]; then + export GCC_BUILD_DIR=$WORKING_DIR/build-gcc +fi +if [ ! -d $GCC_BUILD_DIR ]; then + mkdir $GCC_BUILD_DIR +fi +( + pwd && + ( grep -q jehanne src/gcc/gcc/config.gcc || patch -p1 < patch/gcc.patch ) && + cp patch/gcc/gcc/config/jehanne.h src/gcc/gcc/config && + cd src && + ( cd gcc && ./contrib/download_prerequisites ) && + ( cd gcc/libstdc++-v3 && autoconf -i ) && + cd $GCC_BUILD_DIR && + $WORKING_DIR/src/gcc/configure --target=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE --enable-languages=c,c++ && + make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true all-gcc all-target-libgcc && + make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true DESTDIR=$JEHANNE/pkgs/gcc/9.2.0/ install-gcc install-target-libgcc +# && +# make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true all-target-libstdc++-v3 && +# make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true install-target-libstdc++-v3 +) >> $WORKING_DIR/gcc.build.log 2>&1 +failOnError $? "building gcc" # ## add sh #ln -sf /bin/bash $JEHANNE/hacking/cross/toolchain/bin/x86_64-jehanne-sh + +#cp src/gcc.bkp/gcc/config.gcc src/gcc/gcc/config.gcc +#cp src/gcc.bkp/config.sub src/gcc/config.sub +#cp src/gcc.bkp/fixincludes/mkfixinc.sh src/gcc/fixincludes/mkfixinc.sh +#cp src/gcc.bkp/libgcc/config.host src/gcc/libgcc/config.host + + + echo "done." diff --git a/cross/pkgs/gcc/patch/gcc.patch b/cross/pkgs/gcc/patch/gcc.patch new file mode 100644 index 0000000..ccf70e4 --- /dev/null +++ b/cross/pkgs/gcc/patch/gcc.patch @@ -0,0 +1,71 @@ +diff --git a/src/gcc/gcc/config.gcc b/src/gcc/gcc/config.gcc +index f02ddbd..e5ebfe0 100644 +--- a/src/gcc/gcc/config.gcc ++++ b/src/gcc/gcc/config.gcc +@@ -862,6 +862,16 @@ case ${target} in + tmake_file="$tmake_file vms/t-vmsnative" + fi + ;; ++*-*-jehanne*) ++ gas=yes ++ gnu_ld=yes ++ default_use_cxa_atexit=yes ++ case $target in ++ x86_64-*) ++ native_system_header_dir="/arch/amd64/include" ++ ;; ++ esac ++ ;; + *-*-vxworks*) + tmake_file=t-vxworks + xm_defines=POSIX +@@ -1347,6 +1357,9 @@ x86_64-*-darwin*) + 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" ++ ;; + 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/src/gcc/config.sub b/src/gcc/config.sub +index 75bb6a3..1905540 100755 +--- a/src/gcc/config.sub ++++ b/src/gcc/config.sub +@@ -1363,7 +1363,7 @@ case $os in + | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \ + | skyos* | haiku* | rdos* | toppers* | drops* | es* \ + | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ +- | midnightbsd* | amdhsa* | unleashed* | emscripten*) ++ | jehanne* | midnightbsd* | amdhsa* | unleashed* | emscripten*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + qnx*) +diff --git a/src/gcc/fixincludes/mkfixinc.sh b/src/gcc/fixincludes/mkfixinc.sh +index 0f96486..9f0ee74 100755 +--- a/src/gcc/fixincludes/mkfixinc.sh ++++ b/src/gcc/fixincludes/mkfixinc.sh +@@ -14,6 +14,7 @@ case $machine in + i?86-*-cygwin* | \ + i?86-*-mingw32* | \ + x86_64-*-mingw32* | \ ++ *-jehanne* | \ + powerpc-*-eabisim* | \ + powerpc-*-eabi* | \ + powerpc-*-rtems* | \ +diff --git a/src/gcc/libgcc/config.host b/src/gcc/libgcc/config.host +index 91abc84..a994e3a 100644 +--- a/src/gcc/libgcc/config.host ++++ b/src/gcc/libgcc/config.host +@@ -1414,6 +1414,10 @@ nvptx-*) + tmake_file="$tmake_file nvptx/t-nvptx" + extra_parts="crt0.o" + ;; ++x86_64-*-jehanne*) ++ extra_parts="$extra_parts crtbegin.o crtend.o" ++ tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic" ++ ;; + *) + echo "*** Configuration ${host} not supported" 1>&2 + exit 1 diff --git a/cross/pkgs/gcc/patch/gcc/config.sub b/cross/pkgs/gcc/patch/gcc/config.sub deleted file mode 100644 index 9555a9b..0000000 --- a/cross/pkgs/gcc/patch/gcc/config.sub +++ /dev/null @@ -1,3 +0,0 @@ - -jehanne*) - os=-jehanne - ;; diff --git a/cross/pkgs/gcc/patch/gcc/contrib/download_prerequisites b/cross/pkgs/gcc/patch/gcc/contrib/download_prerequisites deleted file mode 100644 index 932dc36..0000000 --- a/cross/pkgs/gcc/patch/gcc/contrib/download_prerequisites +++ /dev/null @@ -1,71 +0,0 @@ -#! /bin/sh - -# Download some prerequisites needed by gcc. -# Run this from the top level of the gcc source tree and the gcc -# build will do the right thing. -# -# (C) 2010 Free Software Foundation -# -# This program 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, either version 3 of the License, or -# (at your option) any later version. -# -# This program 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 this program. If not, see http://www.gnu.org/licenses/. - -# If you want to build GCC with the Graphite loop optimizations, -# set GRAPHITE_LOOP_OPT=yes to download optional prerequisties -# ISL Library and CLooG. -GRAPHITE_LOOP_OPT=yes - -if [ ! -e gcc/BASE-VER ] ; then - echo "You must run this script in the top level GCC source directory." - exit 1 -fi - -# Necessary to build GCC. -MPFR=mpfr-2.4.2 -GMP=gmp-4.3.2 -MPC=mpc-0.8.1 - -if [ ! -d $MPFR ]; then - wget http://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/infrastructure/$MPFR.tar.bz2 || exit 1 - tar xjf $MPFR.tar.bz2 || exit 1 - ln -sf $MPFR mpfr || exit 1 -fi - -if [ ! -d $GMP ]; then - wget http://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/infrastructure/$GMP.tar.bz2 || exit 1 - tar xjf $GMP.tar.bz2 || exit 1 - ln -sf $GMP gmp || exit 1 -fi - -if [ ! -d $MPC ]; then - wget http://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/infrastructure/$MPC.tar.gz || exit 1 - tar xzf $MPC.tar.gz || exit 1 - ln -sf $MPC mpc || exit 1 -fi - -# Necessary to build GCC with the Graphite loop optimizations. -if [ "$GRAPHITE_LOOP_OPT" = "yes" ] ; then - ISL=isl-0.12.2 - CLOOG=cloog-0.18.1 - - if [ ! -d $ISL ]; then - wget http://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/infrastructure/$ISL.tar.bz2 || exit 1 - tar xjf $ISL.tar.bz2 || exit 1 - ln -sf $ISL isl || exit 1 - fi - - if [ ! -d $CLOOG ]; then - wget http://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/infrastructure/$CLOOG.tar.gz || exit 1 - tar xzf $CLOOG.tar.gz || exit 1 - ln -sf $CLOOG cloog || exit 1 - fi -fi diff --git a/cross/pkgs/gcc/patch/gcc/fixincludes/mkfixinc.sh b/cross/pkgs/gcc/patch/gcc/fixincludes/mkfixinc.sh deleted file mode 100644 index dc0e343..0000000 --- a/cross/pkgs/gcc/patch/gcc/fixincludes/mkfixinc.sh +++ /dev/null @@ -1 +0,0 @@ - *-jehanne* | \ diff --git a/cross/pkgs/gcc/patch/gcc/gcc/config.gcc b/cross/pkgs/gcc/patch/gcc/gcc/config.gcc deleted file mode 100644 index d4f19ab..0000000 --- a/cross/pkgs/gcc/patch/gcc/gcc/config.gcc +++ /dev/null @@ -1,30 +0,0 @@ -diff --git a/src/gcc/gcc/config.gcc b/src/gcc/gcc/config.gcc -index f02ddbd..e5ebfe0 100644 ---- a/src/gcc/gcc/config.gcc -+++ b/src/gcc/gcc/config.gcc -@@ -862,6 +862,16 @@ esac - tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC SINGLE_LIBC" - ;; -+*-*-jehanne*) -+ gas=yes -+ gnu_ld=yes -+ default_use_cxa_atexit=yes -+ case $target in -+ x86_64-*) -+ native_system_header_dir="/arch/amd64/include" -+ ;; -+ esac -+ ;; - *-*-rdos*) - use_gcc_stdint=wrap - ;; -@@ -1347,6 +1357,9 @@ x86_64-*-darwin*) - 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" -+ ;; - 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/pkgs/gcc/patch/gcc/gcc/config/jehanne.h b/cross/pkgs/gcc/patch/gcc/gcc/config/jehanne.h index 1977cfb..7f99e6c 100644 --- a/cross/pkgs/gcc/patch/gcc/gcc/config/jehanne.h +++ b/cross/pkgs/gcc/patch/gcc/gcc/config/jehanne.h @@ -1,7 +1,7 @@ /* * This file is part of Jehanne. * - * Copyright (C) 2016 Giacomo Tesio + * Copyright (C) 2016-2019 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 @@ -68,10 +68,6 @@ #undef ENDFILE_SPEC #define ENDFILE_SPEC "crtend.o%s crtn.o%s" -/* Don't automatically add extern "C" { } around header files. */ -#undef NO_IMPLICIT_EXTERN_C -#define NO_IMPLICIT_EXTERN_C 1 - /* Fix https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67132 */ #undef WCHAR_TYPE #define WCHAR_TYPE "unsigned int" diff --git a/cross/pkgs/gcc/patch/gcc/libgcc/config.host b/cross/pkgs/gcc/patch/gcc/libgcc/config.host deleted file mode 100644 index 390276f..0000000 --- a/cross/pkgs/gcc/patch/gcc/libgcc/config.host +++ /dev/null @@ -1,4 +0,0 @@ -x86_64-*-jehanne*) - extra_parts="$extra_parts crtbegin.o crtend.o" - tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic" - ;; diff --git a/cross/pkgs/gcc/patch/gcc/libgcc/config.host.sed b/cross/pkgs/gcc/patch/gcc/libgcc/config.host.sed deleted file mode 100644 index 6854d52..0000000 --- a/cross/pkgs/gcc/patch/gcc/libgcc/config.host.sed +++ /dev/null @@ -1,3 +0,0 @@ -/enable_execute_stack=enable-execute-stack-empty.c;/,/Configuration ${host} not supported/{ - /^case ${host} in$/r ../patch/gcc/libgcc/config.host -} diff --git a/cross/pkgs/gcc/patch/gcc/libstdc++-v3/crossconfig.m4 b/cross/pkgs/gcc/patch/gcc/libstdc++-v3/crossconfig.m4 deleted file mode 100644 index a74ca37..0000000 --- a/cross/pkgs/gcc/patch/gcc/libstdc++-v3/crossconfig.m4 +++ /dev/null @@ -1,6 +0,0 @@ - *-jehanne*) - GLIBCXX_CHECK_COMPILER_FEATURES - GLIBCXX_CHECK_LINKER_FEATURES - GLIBCXX_CHECK_MATH_SUPPORT - GLIBCXX_CHECK_STDLIB_SUPPORT - ;; From 655f19e322281b97eb0bef8c3f40a5a56ee1bd01 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Mon, 11 Nov 2019 00:15:54 +0100 Subject: [PATCH 22/91] gcc native: unset $CPATH (set in ./hacking/devshell.sh); replace ftp with https in cross/pkgs/gcc/src/gcc/contrib/download_prerequisites --- cross/pkgs/gcc/build.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cross/pkgs/gcc/build.sh b/cross/pkgs/gcc/build.sh index fdb1218..c4507cc 100755 --- a/cross/pkgs/gcc/build.sh +++ b/cross/pkgs/gcc/build.sh @@ -6,6 +6,7 @@ export WORKING_DIR="$JEHANNE/hacking/cross/pkgs/gcc" # include x86_64-jehanne-pkg-config in PATH export PATH="$JEHANNE/hacking/cross/:$PATH" +unset CPATH #set in $JEHANNE/hacking/devshell.sh function failOnError { # $1 -> exit status on a previous command @@ -117,7 +118,7 @@ fi make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true DESTDIR=$JEHANNE/pkgs/binutils/2.33.1/ install ) >> $WORKING_DIR/gcc.build.log 2>&1 failOnError $? "Building binutils" -fi + echo done. # Copy to /posix (to emulate bind during cross compilation) @@ -136,6 +137,7 @@ fi pwd && ( grep -q jehanne src/gcc/gcc/config.gcc || patch -p1 < patch/gcc.patch ) && cp patch/gcc/gcc/config/jehanne.h src/gcc/gcc/config && + sed -i 's/ftp/https/g' src/gcc/contrib/download_prerequisites && cd src && ( cd gcc && ./contrib/download_prerequisites ) && ( cd gcc/libstdc++-v3 && autoconf -i ) && From 329683c7cf3eb99c58b6f773e9becf36a8c7a9e6 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Tue, 12 Nov 2019 00:23:23 +0100 Subject: [PATCH 23/91] gcc native: copy to /posix --- cross/pkgs/gcc/build.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cross/pkgs/gcc/build.sh b/cross/pkgs/gcc/build.sh index c4507cc..d722e81 100755 --- a/cross/pkgs/gcc/build.sh +++ b/cross/pkgs/gcc/build.sh @@ -150,6 +150,9 @@ fi # make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true install-target-libstdc++-v3 ) >> $WORKING_DIR/gcc.build.log 2>&1 failOnError $? "building gcc" + +cp -pfr $JEHANNE/pkgs/gcc/9.2.0/posix/* $JEHANNE/posix + # ## add sh #ln -sf /bin/bash $JEHANNE/hacking/cross/toolchain/bin/x86_64-jehanne-sh From 02d871e58d352e88560da641fa2553b17534f1a1 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Tue, 12 Nov 2019 00:12:09 +0100 Subject: [PATCH 24/91] gcc native: actually put --host=x86_64-jehanne; set LDFLAGS and LDLIBS --- cross/pkgs/gcc/build.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cross/pkgs/gcc/build.sh b/cross/pkgs/gcc/build.sh index d722e81..790c5c1 100755 --- a/cross/pkgs/gcc/build.sh +++ b/cross/pkgs/gcc/build.sh @@ -51,7 +51,7 @@ echo -n Building libgmp... | tee -a $WORKING_DIR/gcc.build.log failOnError $? "Building libgmp" echo done. -#2 Copy to /posix (to emulate bind during cross compilation) +# Copy to /posix (to emulate bind during cross compilation) cp -pfr $JEHANNE/pkgs/libgmp/6.1.2/posix/* $JEHANNE/posix echo -n Building libmpfr... | tee -a $WORKING_DIR/gcc.build.log @@ -89,6 +89,8 @@ echo done. cp -pfr $JEHANNE/pkgs/libmpc/1.1.0/posix/* $JEHANNE/posix echo -n Building binutils... | tee -a $WORKING_DIR/gcc.build.log +export LDFLAGS="-lposix -lc" +export LDLIBS="$JEHANNE/posix/lib/libc.a $JEHANNE/posix/lib/libm.a $JEHANNE/posix/lib/libg.a" # Patch and build binutils if [ "$BINUTILS_BUILD_DIR" = "" ]; then export BINUTILS_BUILD_DIR=$WORKING_DIR/build-binutils @@ -107,9 +109,9 @@ fi dynpatch 'binutils/ld/Makefile.am' 'eelf_x86_64.c: ' && (grep 'eelf_i386_jehanne.c \\' src/binutils/ld/Makefile.am || sed -i 's/.*ALL_EMULATION_SOURCES = \\.*/&\n\teelf_i386_jehanne.c \\/' src/binutils/ld/Makefile.am) && (grep 'eelf_x86_64_jehanne.c \\' src/binutils/ld/Makefile.am || sed -i 's/.*ALL_64_EMULATION_SOURCES = \\.*/&\n\teelf_x86_64_jehanne.c \\/' src/binutils/ld/Makefile.am) && - cd src/binutils/ld && automake && cd ../ ) ) && + cd src/binutils/ld && automake-1.15 && cd ../ ) ) && mkdir -p $BINUTILS_BUILD_DIR && cd $BINUTILS_BUILD_DIR && - $WORKING_DIR/src/binutils/configure --prefix=/posix --with-sysroot=$JEHANNE --target=x86_64-jehanne --enable-interwork --enable-multilib --disable-nls --disable-werror && + $WORKING_DIR/src/binutils/configure --host=x86_64-jehanne --prefix=/posix --with-sysroot=$JEHANNE --target=x86_64-jehanne --enable-interwork --enable-multilib --disable-nls --disable-werror && cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/bfd/doc/Makefile && cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/bfd/po/Makefile && cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/gas/doc/Makefile && @@ -142,7 +144,7 @@ fi ( cd gcc && ./contrib/download_prerequisites ) && ( cd gcc/libstdc++-v3 && autoconf -i ) && cd $GCC_BUILD_DIR && - $WORKING_DIR/src/gcc/configure --target=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE --enable-languages=c,c++ && + $WORKING_DIR/src/gcc/configure --host=x86_64-jehanne --target=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE --enable-languages=c,c++ && make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true all-gcc all-target-libgcc && make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true DESTDIR=$JEHANNE/pkgs/gcc/9.2.0/ install-gcc install-target-libgcc # && From 5c3f796756f0041c0e1fa2ea67f1935865d05578 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Wed, 13 Nov 2019 18:19:34 +0100 Subject: [PATCH 25/91] gcc native: mess with environment variables --- cross/pkgs/gcc/build.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cross/pkgs/gcc/build.sh b/cross/pkgs/gcc/build.sh index 790c5c1..e4514c6 100755 --- a/cross/pkgs/gcc/build.sh +++ b/cross/pkgs/gcc/build.sh @@ -89,8 +89,11 @@ echo done. cp -pfr $JEHANNE/pkgs/libmpc/1.1.0/posix/* $JEHANNE/posix echo -n Building binutils... | tee -a $WORKING_DIR/gcc.build.log -export LDFLAGS="-lposix -lc" -export LDLIBS="$JEHANNE/posix/lib/libc.a $JEHANNE/posix/lib/libm.a $JEHANNE/posix/lib/libg.a" + +export LDFLAGS="$JEHANNE/posix/lib/libc.a $JEHANNE/posix/lib/libm.a $JEHANNE/posix/lib/libg.a -lposix -lc" +export LIBS="$JEHANNE/posix/lib/libc.a $JEHANNE/posix/lib/libm.a $JEHANNE/posix/lib/libg.a -lposix -lc" +export CPATH=$JEHANNE/posix/include:$CPATH:$JEHANNE/arch/amd64/include/:$JEHANNE/sys/include/apw/:$JEHANNE/sys/include/ + # Patch and build binutils if [ "$BINUTILS_BUILD_DIR" = "" ]; then export BINUTILS_BUILD_DIR=$WORKING_DIR/build-binutils From aebce89c7c557ac485c5b75775f404681291009f Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Mon, 18 Nov 2019 00:49:15 +0100 Subject: [PATCH 26/91] gcc native: properly set CPATH and LIBS --- cross/patch/MakeNothing.in | 2 ++ cross/pkgs/gcc/build.sh | 13 ++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cross/patch/MakeNothing.in b/cross/patch/MakeNothing.in index 5f28461..025d5ca 100644 --- a/cross/patch/MakeNothing.in +++ b/cross/patch/MakeNothing.in @@ -1,3 +1,5 @@ +info: + echo "make info does nothing HERE" all: echo "make all does nothing HERE" install: diff --git a/cross/pkgs/gcc/build.sh b/cross/pkgs/gcc/build.sh index e4514c6..cc2a6b2 100755 --- a/cross/pkgs/gcc/build.sh +++ b/cross/pkgs/gcc/build.sh @@ -90,9 +90,8 @@ cp -pfr $JEHANNE/pkgs/libmpc/1.1.0/posix/* $JEHANNE/posix echo -n Building binutils... | tee -a $WORKING_DIR/gcc.build.log -export LDFLAGS="$JEHANNE/posix/lib/libc.a $JEHANNE/posix/lib/libm.a $JEHANNE/posix/lib/libg.a -lposix -lc" -export LIBS="$JEHANNE/posix/lib/libc.a $JEHANNE/posix/lib/libm.a $JEHANNE/posix/lib/libg.a -lposix -lc" -export CPATH=$JEHANNE/posix/include:$CPATH:$JEHANNE/arch/amd64/include/:$JEHANNE/sys/include/apw/:$JEHANNE/sys/include/ +export CPATH="$JEHANNE/posix/include:$JEHANNE/sys/include:$JEHANNE/hacking/cross/toolchain/lib/gcc/x86_64-jehanne/9.2.0/include:$JEHANNE/hacking/cross/toolchain/lib/gcc/x86_64-jehanne/9.2.0/include-fixed" +export LIBS="-L$JEHANNE/posix/lib $JEHANNE/posix/lib/libc.a $JEHANNE/arch/amd64/lib/libposix.a $JEHANNE/arch/amd64/lib/libc.a" # Patch and build binutils if [ "$BINUTILS_BUILD_DIR" = "" ]; then @@ -115,10 +114,10 @@ fi cd src/binutils/ld && automake-1.15 && cd ../ ) ) && mkdir -p $BINUTILS_BUILD_DIR && cd $BINUTILS_BUILD_DIR && $WORKING_DIR/src/binutils/configure --host=x86_64-jehanne --prefix=/posix --with-sysroot=$JEHANNE --target=x86_64-jehanne --enable-interwork --enable-multilib --disable-nls --disable-werror && - cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/bfd/doc/Makefile && - cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/bfd/po/Makefile && - cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/gas/doc/Makefile && - cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/binutils/doc/Makefile && + cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/bfd/doc/ && + cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/bfd/po/ && + cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/gas/doc/ && + cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/binutils/doc/ && make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true && make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true DESTDIR=$JEHANNE/pkgs/binutils/2.33.1/ install ) >> $WORKING_DIR/gcc.build.log 2>&1 From ee7317925adc888f746ddd78d5b179f15865d016 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Mon, 18 Nov 2019 01:17:53 +0100 Subject: [PATCH 27/91] gcc native: properly copy Makefile.in to doc dirs --- cross/pkgs/gcc/build.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cross/pkgs/gcc/build.sh b/cross/pkgs/gcc/build.sh index cc2a6b2..179466c 100755 --- a/cross/pkgs/gcc/build.sh +++ b/cross/pkgs/gcc/build.sh @@ -114,10 +114,10 @@ fi cd src/binutils/ld && automake-1.15 && cd ../ ) ) && mkdir -p $BINUTILS_BUILD_DIR && cd $BINUTILS_BUILD_DIR && $WORKING_DIR/src/binutils/configure --host=x86_64-jehanne --prefix=/posix --with-sysroot=$JEHANNE --target=x86_64-jehanne --enable-interwork --enable-multilib --disable-nls --disable-werror && - cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/bfd/doc/ && - cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/bfd/po/ && - cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/gas/doc/ && - cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/binutils/doc/ && + cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/bfd/doc/Makefile.in && + cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/bfd/po/Makefile.in && + cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/gas/doc/Makefile.in && + cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/binutils/doc/Makefile.in && make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true && make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true DESTDIR=$JEHANNE/pkgs/binutils/2.33.1/ install ) >> $WORKING_DIR/gcc.build.log 2>&1 From 633a039d4f00add4cd59773267f970860039d083 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Tue, 19 Nov 2019 01:48:52 +0100 Subject: [PATCH 28/91] devtools: usyscalls: cast pointers args to (void*) --- src/jehanne/cmd/usyscalls/usyscalls.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/jehanne/cmd/usyscalls/usyscalls.go b/src/jehanne/cmd/usyscalls/usyscalls.go index a27ff26..7d68d72 100644 --- a/src/jehanne/cmd/usyscalls/usyscalls.go +++ b/src/jehanne/cmd/usyscalls/usyscalls.go @@ -104,7 +104,6 @@ func argTypeName(t string) string{ return "p" } return " [?? " + t + "]" - } func argRegister(index int, t string) string{ @@ -144,6 +143,7 @@ func getHeaderData(calls []SyscallConf) *HeaderCode { wcall.AsmClobbers = "\"cc\", \"rcx\", \"r11\"" wcall.AsmArgs = fmt.Sprintf("\"0\"(%d)", wcall.Id) for i, a := range(call.Args){ + typeName := argTypeName(a) if i > 0 { wcall.FuncArgs += ", " wcall.MacroArgs += ", " @@ -153,7 +153,11 @@ func getHeaderData(calls []SyscallConf) *HeaderCode { } wcall.FuncArgs += fmt.Sprintf("%s a%d", a, i) wcall.MacroArgs += fmt.Sprintf("/* %s */ a%d", a, i) - wcall.VarValues = append(wcall.VarValues, fmt.Sprintf("_sysargs[%d].%s = (a%d); \\\n\t", i, argTypeName(a), i)) + if typeName == "p" { + wcall.VarValues = append(wcall.VarValues, fmt.Sprintf("_sysargs[%d].%s = ((void*)a%d); \\\n\t", i, typeName, i)) + } else { + wcall.VarValues = append(wcall.VarValues, fmt.Sprintf("_sysargs[%d].%s = (a%d); \\\n\t", i, typeName, i)) + } wcall.Vars = append(wcall.Vars, fmt.Sprintf("register %s __r%d asm(\"%s\") = _sysargs[%d].%s; \\\n\t", a, i, argRegister(i, a), i, argTypeName(a))) wcall.AsmArgs += fmt.Sprintf(", \"r\"(__r%d)", i) } From 292ecd4f1924bb582e011b665dd967cd635ec902 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Tue, 19 Nov 2019 01:51:23 +0100 Subject: [PATCH 29/91] gcc native: more binutils --- cross/pkgs/gcc/build.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cross/pkgs/gcc/build.sh b/cross/pkgs/gcc/build.sh index 179466c..eede606 100755 --- a/cross/pkgs/gcc/build.sh +++ b/cross/pkgs/gcc/build.sh @@ -59,7 +59,7 @@ echo -n Building libmpfr... | tee -a $WORKING_DIR/gcc.build.log cd src/libmpfr && ( grep -q jehanne config.sub || patch -p0 < $WORKING_DIR/patch/libmpfr.patch ) && ./configure --host=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE --with-gmp=$JEHANNE/pkgs/libgmp/6.1.2/posix/ && - cp ../../../../patch/MakeNothing.in doc/Makefile && + cp ../../../../patch/MakeNothing.in doc/Makefile.in && make && make DESTDIR=$JEHANNE/pkgs/libmpfr/4.0.1/ install && libtool --mode=finish $JEHANNE/posix/lib @@ -77,7 +77,7 @@ echo -n Building libmpc... | tee -a $WORKING_DIR/gcc.build.log patch -p0 < $WORKING_DIR/patch/libmpc.patch && chmod u-w config.sub ) ) && ./configure --host=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE --with-gmp=$JEHANNE/pkgs/libgmp/6.1.2/posix/ --with-mpfr=$JEHANNE/pkgs/libmpfr/4.0.1/posix/ && - cp ../../../../patch/MakeNothing.in doc/Makefile && + cp ../../../../patch/MakeNothing.in doc/Makefile.in && make && make DESTDIR=$JEHANNE/pkgs/libmpc/1.1.0/ install && libtool --mode=finish $JEHANNE/posix/lib @@ -90,7 +90,7 @@ cp -pfr $JEHANNE/pkgs/libmpc/1.1.0/posix/* $JEHANNE/posix echo -n Building binutils... | tee -a $WORKING_DIR/gcc.build.log -export CPATH="$JEHANNE/posix/include:$JEHANNE/sys/include:$JEHANNE/hacking/cross/toolchain/lib/gcc/x86_64-jehanne/9.2.0/include:$JEHANNE/hacking/cross/toolchain/lib/gcc/x86_64-jehanne/9.2.0/include-fixed" +export CPATH="$JEHANNE/posix/include:$JEHANNE/sys/include:$JEHANNE/hacking/cross/toolchain/lib/gcc/x86_64-jehanne/4.9.4/include:$JEHANNE/hacking/cross/toolchain/lib/gcc/x86_64-jehanne/4.9.4/include-fixed" export LIBS="-L$JEHANNE/posix/lib $JEHANNE/posix/lib/libc.a $JEHANNE/arch/amd64/lib/libposix.a $JEHANNE/arch/amd64/lib/libc.a" # Patch and build binutils @@ -101,6 +101,7 @@ if [ ! -d $BINUTILS_BUILD_DIR ]; then mkdir $BINUTILS_BUILD_DIR fi ( ( grep -q jehanne src/binutils/config.sub || ( +echo done sed -i '/jehanne/b; /ELF_TARGET_ID/,/elf_backend_can_gc_sections/s/0x200000/0x1000 \/\/ jehanne hack/g' src/binutils/bfd/elf64-x86-64.c && sed -i '/jehanne/b; s/| midnightbsd\*/| midnightbsd* | jehanne*/g' src/binutils/config.sub && dynpatch 'binutils/bfd/config.bfd' '\# END OF targmatch.h' && @@ -111,7 +112,8 @@ fi dynpatch 'binutils/ld/Makefile.am' 'eelf_x86_64.c: ' && (grep 'eelf_i386_jehanne.c \\' src/binutils/ld/Makefile.am || sed -i 's/.*ALL_EMULATION_SOURCES = \\.*/&\n\teelf_i386_jehanne.c \\/' src/binutils/ld/Makefile.am) && (grep 'eelf_x86_64_jehanne.c \\' src/binutils/ld/Makefile.am || sed -i 's/.*ALL_64_EMULATION_SOURCES = \\.*/&\n\teelf_x86_64_jehanne.c \\/' src/binutils/ld/Makefile.am) && - cd src/binutils/ld && automake-1.15 && cd ../ ) ) && + cd src/binutils/ld && automake-1.15 && cd ../ + ) ) && mkdir -p $BINUTILS_BUILD_DIR && cd $BINUTILS_BUILD_DIR && $WORKING_DIR/src/binutils/configure --host=x86_64-jehanne --prefix=/posix --with-sysroot=$JEHANNE --target=x86_64-jehanne --enable-interwork --enable-multilib --disable-nls --disable-werror && cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/bfd/doc/Makefile.in && From 3f3f02c9dd9fbebfc19acdcac030d9e603cfa3f4 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Tue, 19 Nov 2019 00:24:34 +0100 Subject: [PATCH 30/91] newlib: build.sh: copy output libraries to /posix and rename for easier linking --- cross/pkgs/newlib/build.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cross/pkgs/newlib/build.sh b/cross/pkgs/newlib/build.sh index 24c2fc8..6fc339d 100755 --- a/cross/pkgs/newlib/build.sh +++ b/cross/pkgs/newlib/build.sh @@ -88,6 +88,15 @@ export CFLAGS_FOR_TARGET="-g -gdwarf-2 -ggdb -O$NEWLIB_OPTIMIZATION -std=gnu11" ) >> $NEWLIB/newlib.build.log 2>&1 failOnError $? "building newlib" +# emultate bind for the cross compiler +cp -fr $JEHANNE/pkgs/newlib/x86_64-jehanne/* $JEHANNE/posix + +# rename libc to libnewlibc to avoid name clash with Jehanne libc +mv $JEHANNE/posix/lib/libc.a $JEHANNEposix/lib/libnewlibc.a +mv $JEHANNE/posix/lib/libm.a $JEHANNEposix/lib/libnewlibm.a +mv $JEHANNE/posix/lib/libg.a $JEHANNEposix/lib/libnewlibg.a + + kill $dotter wait $dotter 2>/dev/null From efa47411c676ff52cb2c78f94d25daf3c48df3cd Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Tue, 19 Nov 2019 00:23:08 +0100 Subject: [PATCH 31/91] gcc native: more binutils --- cross/pkgs/gcc/build.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cross/pkgs/gcc/build.sh b/cross/pkgs/gcc/build.sh index eede606..cafb84e 100755 --- a/cross/pkgs/gcc/build.sh +++ b/cross/pkgs/gcc/build.sh @@ -90,8 +90,9 @@ cp -pfr $JEHANNE/pkgs/libmpc/1.1.0/posix/* $JEHANNE/posix echo -n Building binutils... | tee -a $WORKING_DIR/gcc.build.log -export CPATH="$JEHANNE/posix/include:$JEHANNE/sys/include:$JEHANNE/hacking/cross/toolchain/lib/gcc/x86_64-jehanne/4.9.4/include:$JEHANNE/hacking/cross/toolchain/lib/gcc/x86_64-jehanne/4.9.4/include-fixed" -export LIBS="-L$JEHANNE/posix/lib $JEHANNE/posix/lib/libc.a $JEHANNE/arch/amd64/lib/libposix.a $JEHANNE/arch/amd64/lib/libc.a" +export CPATH="$JEHANNE/posix/include:$JEHANNE/sys/include:$JEHANNE/arch/amd64/include:$JEHANNE/hacking/cross/toolchain/lib/gcc/x86_64-jehanne/4.9.4/include:$JEHANNE/hacking/cross/toolchain/lib/gcc/x86_64-jehanne/4.9.4/include-fixed" +export LIBS="-L$JEHANNE/posix/lib -lnewlibc -lposix -lc" +export CC_FOR_BUILD='CPATH="" LIBS="" gcc' # Patch and build binutils if [ "$BINUTILS_BUILD_DIR" = "" ]; then @@ -115,13 +116,13 @@ echo done cd src/binutils/ld && automake-1.15 && cd ../ ) ) && mkdir -p $BINUTILS_BUILD_DIR && cd $BINUTILS_BUILD_DIR && - $WORKING_DIR/src/binutils/configure --host=x86_64-jehanne --prefix=/posix --with-sysroot=$JEHANNE --target=x86_64-jehanne --enable-interwork --enable-multilib --disable-nls --disable-werror && + $WORKING_DIR/src/binutils/configure --host=x86_64-jehanne --prefix=/posix --with-sysroot=$JEHANNE --target=x86_64-jehanne --enable-interwork --enable-multilib --enable-newlib-long-time_t --disable-nls --disable-werror && cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/bfd/doc/Makefile.in && cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/bfd/po/Makefile.in && cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/gas/doc/Makefile.in && cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/binutils/doc/Makefile.in && - make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true && - make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true DESTDIR=$JEHANNE/pkgs/binutils/2.33.1/ install + make && + make DESTDIR=$JEHANNE/pkgs/binutils/2.33.1/ install ) >> $WORKING_DIR/gcc.build.log 2>&1 failOnError $? "Building binutils" From 9114d3416485ad0a2b4a3f2d6fc9b548b38913ad Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Wed, 20 Nov 2019 00:25:43 +0100 Subject: [PATCH 32/91] newlib: fix libraries `mv` --- cross/pkgs/newlib/build.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cross/pkgs/newlib/build.sh b/cross/pkgs/newlib/build.sh index 6fc339d..1c3f0b2 100755 --- a/cross/pkgs/newlib/build.sh +++ b/cross/pkgs/newlib/build.sh @@ -92,9 +92,9 @@ failOnError $? "building newlib" cp -fr $JEHANNE/pkgs/newlib/x86_64-jehanne/* $JEHANNE/posix # rename libc to libnewlibc to avoid name clash with Jehanne libc -mv $JEHANNE/posix/lib/libc.a $JEHANNEposix/lib/libnewlibc.a -mv $JEHANNE/posix/lib/libm.a $JEHANNEposix/lib/libnewlibm.a -mv $JEHANNE/posix/lib/libg.a $JEHANNEposix/lib/libnewlibg.a +mv $JEHANNE/posix/lib/libc.a $JEHANNE/posix/lib/libnewlibc.a +mv $JEHANNE/posix/lib/libm.a $JEHANNE/posix/lib/libnewlibm.a +mv $JEHANNE/posix/lib/libg.a $JEHANNE/posix/lib/libnewlibg.a kill $dotter From 3842a03b36bdb031ebe21388e4593edef0fd1810 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Wed, 20 Nov 2019 00:26:41 +0100 Subject: [PATCH 33/91] gcc native: build.sh: mock makeinfo to avoid it as a dependency --- cross/pkgs/gcc/build.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cross/pkgs/gcc/build.sh b/cross/pkgs/gcc/build.sh index cafb84e..f4d5ec8 100755 --- a/cross/pkgs/gcc/build.sh +++ b/cross/pkgs/gcc/build.sh @@ -32,6 +32,10 @@ function dynpatch { date > $WORKING_DIR/gcc.build.log +# mock makeinfo (to avoid it as a dependency) +rm -f $JEHANNE/hacking/bin/makeinfo +ln -s `which echo` $JEHANNE/hacking/bin/makeinfo + # verify libtool is installed libtool --version >> /dev/null failOnError $? "libtool installation check" From 0c7d7e30647d0555cd7ca36693578617a907b6b8 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Fri, 22 Nov 2019 07:26:24 +0100 Subject: [PATCH 34/91] gcc native: move cross compiler outside source tree --- cross/init.sh | 220 ++++-------------- .../patch/autoconf/build-aux/git-version-gen | 2 - cross/patch/binutils/ld/configure.tgt | 14 +- cross/patch/gcc.patch | 71 ++++++ cross/patch/gcc/config.sub | 3 - .../patch/gcc/contrib/download_prerequisites | 71 ------ cross/patch/gcc/fixincludes/mkfixinc.sh | 1 - cross/patch/gcc/gcc/config.gcc | 31 --- cross/patch/gcc/gcc/config/jehanne.h | 6 +- cross/patch/gcc/libgcc/config.host | 4 - cross/patch/gcc/libgcc/config.host.sed | 3 - cross/patch/gcc/libstdc++-v3/crossconfig.m4 | 6 - cross/patch/libgmp.patch | 11 + cross/patch/libmpc.patch | 11 + cross/patch/libmpfr.patch | 11 + cross/src/.gitignore | 7 - cross/src/fetch.json | 39 ++-- 17 files changed, 178 insertions(+), 333 deletions(-) delete mode 100755 cross/patch/autoconf/build-aux/git-version-gen create mode 100644 cross/patch/gcc.patch delete mode 100644 cross/patch/gcc/config.sub delete mode 100644 cross/patch/gcc/contrib/download_prerequisites delete mode 100644 cross/patch/gcc/fixincludes/mkfixinc.sh delete mode 100644 cross/patch/gcc/gcc/config.gcc delete mode 100644 cross/patch/gcc/libgcc/config.host delete mode 100644 cross/patch/gcc/libgcc/config.host.sed delete mode 100644 cross/patch/gcc/libstdc++-v3/crossconfig.m4 create mode 100644 cross/patch/libgmp.patch create mode 100644 cross/patch/libmpc.patch create mode 100644 cross/patch/libmpfr.patch delete mode 100644 cross/src/.gitignore diff --git a/cross/init.sh b/cross/init.sh index 6291a4c..18cca60 100755 --- a/cross/init.sh +++ b/cross/init.sh @@ -2,7 +2,7 @@ # This file is part of Jehanne. # -# Copyright (C) 2016 Giacomo Tesio +# Copyright (C) 2016-2019 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 @@ -21,198 +21,80 @@ if [ "$JEHANNE" = "" ]; then exit 1 fi -# setup Jehanne's headers -usyscalls header $JEHANNE/sys/src/sysconf.json > $JEHANNE/arch/amd64/include/syscalls.h - -# -# WELLCOME TO HELL ! ! ! -# - -# If you want to understand _WHY_ Jehanne exists, you should try to -# create a GCC crosscompiler in Debian without requiring root access or Tex. -# And this despite the extreme quality of Debian GNU/Linux! - -# To create a Jehanne version of GCC, we need specific OUTDATED versions -# of Autotools that won't compile easily in a modern Linux distro. - -echo -n please wait. -( - # Inside parentheses, and therefore a subshell . . . - while [ 1 ] # Endless loop. - do - echo -n "." - sleep 3 - done -) & -dotter=$! -date > cross-toolchain.build.log +REPONAME=`basename $JEHANNE` +WORKING_DIR=`dirname $JEHANNE` +WORKING_DIR="$WORKING_DIR/$REPONAME.TOOLCHAIN" +CROSS_DIR="$JEHANNE/hacking/cross" +LOG="$WORKING_DIR/cross.build.log" function failOnError { # $1 -> exit status on a previous command # $2 -> task description if [ $1 -ne 0 ]; then - kill $dotter - wait $dotter 2>/dev/null - echo "ERROR $2" echo echo BUILD LOG: echo - cat cross-toolchain.build.log + cat $LOG exit $1 fi } -# fetch all sources -(cd src && fetch) >> cross-toolchain.build.log 2>&1 -failOnError $? "fetching sources" - -# build m4 1.4.14 -# - workaround a bug in lib/stdio.in.h, see http://lists.gnu.org/archive/html/bug-m4/2012-08/msg00008.html -# - workaround a bug in src/m4.h, see https://bugs.archlinux.org/task/19829 -# both bugs exists thanks to changes in external code -if [ ! -f tmp/bin/m4 ]; then -( - cd src/m4 && - sed -i '/_GL_WARN_ON_USE (gets/d' lib/stdio.in.h && - ( grep -q '#include ' src/m4.h || sed -i 's:.*\#include .*:&\n#include :g' src/m4.h ) && - ./configure --prefix=$JEHANNE/hacking/cross/tmp && - make && make install -) >> cross-toolchain.build.log 2>&1 -failOnError $? "building m4" -fi -# build autoconf 2.64 -# - hack git-version-gen to avoid the -dirty flag in version on make -# - autoreconf -# - disable doc build -# - disable man build -if [ ! -f tmp/bin/autoconf ]; then -( - cd src/autoconf && - cp ../../patch/autoconf/build-aux/git-version-gen build-aux/git-version-gen && - autoreconf && - ./configure --prefix=$JEHANNE/hacking/cross/tmp && - cp ../../patch/MakeNothing.in ../autoconf/doc/Makefile.in && - cp ../../patch/MakeNothing.in ../autoconf/man/Makefile.in && - make && make install -) >> cross-toolchain.build.log 2>&1 -failOnError $? "building autoconf" -fi -# build automake 1.11.1 -# - autoreconf to avoid conflicts with installed automake -# - automake; configure; make (that will fail) and then automake again -# to workaround this hell -# - disable doc build -# - disable disable tests build -if [ ! -f tmp/bin/automake ]; then -( - cd src/automake && - echo > doc/Makefile.am && - touch NEWS AUTHORS && autoreconf -i && - automake && - (./configure --prefix=$JEHANNE/hacking/cross/tmp && make; automake) && - ./configure --prefix=$JEHANNE/hacking/cross/tmp && - cp ../../patch/MakeNothing.in doc/Makefile.in && - cp ../../patch/MakeNothing.in tests/Makefile.in && - make && make install -) >> cross-toolchain.build.log 2>&1 -failOnError $? "building automake" -fi -# build libtool 2.4 -if [ ! -f tmp/bin/libtool ]; then -( - cd src/libtool && - ./configure --prefix=$JEHANNE/hacking/cross/tmp && - make && make install -) >> cross-toolchain.build.log 2>&1 -failOnError $? "building libtool" -fi - -# FINALLY! We have our OUTDATED autotools in tmp/bin -export PATH=$JEHANNE/hacking/cross/tmp/bin:$PATH -export CROSS_DIR=$JEHANNE/hacking/cross -if [ "$BUILD_DIRS_ROOT" = "" ]; then - export BUILD_DIRS_ROOT=$JEHANNE/hacking/cross/src -fi -if [ ! -d $BUILD_DIRS_ROOT ]; then - mkdir $BUILD_DIRS_ROOT -fi - function dynpatch { - # $1 -> path from cross/src + # $1 -> path from $WORKING_DIR/src # $2 -> string to search - ( cd $JEHANNE/hacking/cross/src && + ( cd $WORKING_DIR/src && grep -q jehanne $1 || - sed -n -i -e "/$2/r ../patch/$1" -e '1x' -e '2,${x;p}' -e '${x;p}' $1 + sed -n -i -e "/$2/r $CROSS_DIR/patch/$1" -e '1x' -e '2,${x;p}' -e '${x;p}' $1 ) } + +# setup Jehanne's headers +usyscalls header $JEHANNE/sys/src/sysconf.json > $JEHANNE/arch/amd64/include/syscalls.h + +mkdir -p $WORKING_DIR +date > $LOG + +# verify libtool is installed +libtool --version >> $LOG +failOnError $? "libtool installation check" + + +cp -fpr $JEHANNE/hacking/cross/src $WORKING_DIR +cd $WORKING_DIR/src +fetch >> $LOG +failOnError $? "fetching sources" + +mkdir -p $WORKING_DIR/build +mkdir -p $WORKING_DIR/cross + # Patch and build binutils -if [ "$BINUTILS_BUILD_DIR" = "" ]; then - export BINUTILS_BUILD_DIR=$BUILD_DIRS_ROOT/build-binutils -fi -if [ ! -d $BINUTILS_BUILD_DIR ]; then - mkdir $BINUTILS_BUILD_DIR -fi -if [ ! -f toolchain/bin/x86_64-jehanne-ar ]; then -( +export BINUTILS_BUILD_DIR=$WORKING_DIR/build/binutils +mkdir -p $BINUTILS_BUILD_DIR + +( ( grep -q jehanne $WORKING_DIR/src/binutils/config.sub || ( + cd $WORKING_DIR sed -i '/jehanne/b; /ELF_TARGET_ID/,/elf_backend_can_gc_sections/s/0x200000/0x1000 \/\/ jehanne hack/g' src/binutils/bfd/elf64-x86-64.c && - sed -i '/jehanne/b; s/| -tirtos/| -tirtos* | -jehanne/g' src/binutils/config.sub && + sed -i '/jehanne/b; s/| midnightbsd\*/| midnightbsd* | jehanne*/g' src/binutils/config.sub && dynpatch 'binutils/bfd/config.bfd' '\# END OF targmatch.h' && - dynpatch 'binutils/gas/configure.tgt' ' i860-\*-\*)' && - ( grep -q jehanne src/binutils/ld/configure.tgt || patch -p1 < patch/binutils/ld/configure.tgt ) && - cp patch/binutils/ld/emulparams/elf_x86_64_jehanne.sh src/binutils/ld/emulparams/ && - cp patch/binutils/ld/emulparams/elf_i386_jehanne.sh src/binutils/ld/emulparams/ && + dynpatch 'binutils/gas/configure.tgt' ' i386-\*-darwin\*)' && + ( grep -q jehanne src/binutils/ld/configure.tgt || patch -p1 < $CROSS_DIR/patch/binutils/ld/configure.tgt ) && + cp $CROSS_DIR/patch/binutils/ld/emulparams/elf_x86_64_jehanne.sh src/binutils/ld/emulparams/ && + cp $CROSS_DIR/patch/binutils/ld/emulparams/elf_i386_jehanne.sh src/binutils/ld/emulparams/ && dynpatch 'binutils/ld/Makefile.am' 'eelf_x86_64.c: ' && (grep 'eelf_i386_jehanne.c \\' src/binutils/ld/Makefile.am || sed -i 's/.*ALL_EMULATION_SOURCES = \\.*/&\n\teelf_i386_jehanne.c \\/' src/binutils/ld/Makefile.am) && (grep 'eelf_x86_64_jehanne.c \\' src/binutils/ld/Makefile.am || sed -i 's/.*ALL_64_EMULATION_SOURCES = \\.*/&\n\teelf_x86_64_jehanne.c \\/' src/binutils/ld/Makefile.am) && - cd src/binutils/ld && automake && cd ../ && + cd src/binutils/ld && automake-1.15 && cd ../ + ) ) && cd $BINUTILS_BUILD_DIR && - $CROSS_DIR/src/binutils/configure --prefix=$JEHANNE/hacking/cross/toolchain --with-sysroot=$JEHANNE --target=x86_64-jehanne --enable-interwork --enable-multilib --disable-nls --disable-werror && - cp $CROSS_DIR/patch/MakeNothing.in $CROSS_DIR/src/binutils/bfd/doc/Makefile && - cp $CROSS_DIR/patch/MakeNothing.in $CROSS_DIR/src/binutils/bfd/po/Makefile && - cp $CROSS_DIR/patch/MakeNothing.in $CROSS_DIR/src/binutils/gas/doc/Makefile && - cp $CROSS_DIR/patch/MakeNothing.in $CROSS_DIR/src/binutils/binutils/doc/Makefile && - make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true && - make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true install -) >> cross-toolchain.build.log 2>&1 -failOnError $? "building binutils" -fi + $WORKING_DIR/src/binutils/configure --target=x86_64-jehanne --prefix=/posix --with-sysroot=$JEHANNE --target=x86_64-jehanne --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 && + cp $CROSS_DIR/patch/MakeNothing.in $WORKING_DIR/src/binutils/binutils/doc/Makefile.in && + make && + make DESTDIR=$WORKING_DIR/cross install +) >> $LOG 2>&1 +failOnError $? "Building binutils" -# Patch and build gcc -if [ "$GCC_BUILD_DIR" = "" ]; then - export GCC_BUILD_DIR=$BUILD_DIRS_ROOT/build-gcc -fi -if [ ! -d $GCC_BUILD_DIR ]; then - mkdir $GCC_BUILD_DIR -fi -( - pwd && - ( grep -q jehanne src/gcc/gcc/config.gcc || patch -p1 < patch/gcc/gcc/config.gcc ) && - cd src && - cp ../patch/gcc/contrib/download_prerequisites gcc/contrib/download_prerequisites && - ( cd gcc && ./contrib/download_prerequisites ) && - dynpatch 'gcc/config.sub' '-none)' && - cp ../patch/gcc/gcc/config/jehanne.h gcc/gcc/config && - dynpatch 'gcc/libstdc++-v3/crossconfig.m4' ' \*)' && - cd gcc/libstdc++-v3 && autoconf -i && cd ../../ && - ( pwd && grep -q jehanne gcc/libgcc/config.host || - sed -i -f ../patch/gcc/libgcc/config.host.sed gcc/libgcc/config.host - ) && - dynpatch 'gcc/fixincludes/mkfixinc.sh' 'i\?86-\*-cygwin\*' && - cd $GCC_BUILD_DIR && - $CROSS_DIR/src/gcc/configure --target=x86_64-jehanne --prefix=$JEHANNE/hacking/cross/toolchain --with-sysroot=$JEHANNE --enable-languages=c,c++ && - make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true all-gcc all-target-libgcc && - make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true install-gcc install-target-libgcc -# && -# make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true all-target-libstdc++-v3 && -# make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true install-target-libstdc++-v3 -) >> cross-toolchain.build.log 2>&1 -failOnError $? "building gcc" - -# add sh -ln -sf /bin/bash $JEHANNE/hacking/cross/toolchain/bin/x86_64-jehanne-sh - -kill $dotter -wait $dotter 2>/dev/null -echo "done." diff --git a/cross/patch/autoconf/build-aux/git-version-gen b/cross/patch/autoconf/build-aux/git-version-gen deleted file mode 100755 index 26bab70..0000000 --- a/cross/patch/autoconf/build-aux/git-version-gen +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -echo "2.64" | tr -d '\012' diff --git a/cross/patch/binutils/ld/configure.tgt b/cross/patch/binutils/ld/configure.tgt index a87ce56..27ef033 100644 --- a/cross/patch/binutils/ld/configure.tgt +++ b/cross/patch/binutils/ld/configure.tgt @@ -1,18 +1,18 @@ diff --git a/src/binutils/ld/configure.tgt b/src/binutils/ld/configure.tgt -index 6b6bbf2..29b5f30 100644 +index fad8b2e..ba3ddc9 100644 --- a/src/binutils/ld/configure.tgt +++ b/src/binutils/ld/configure.tgt -@@ -383,6 +383,9 @@ x86_64-*-nacl*) targ_emul=elf32_x86_64_nacl - targ_extra_libpath=$targ_extra_emuls +@@ -370,6 +370,9 @@ targ_extra_emuls="elf_i386_nacl elf_x86_64_nacl armelf_nacl armelfb_nacl" + targ_extra_libpath=$targ_extra_emuls tdir_elf_i386_nacl=`echo ${targ_alias} | sed -e 's/x86_64/i386/'` ;; +x86_64*-jehanne*) targ_emul=elf_x86_64_jehanne + targ_extra_emuls="elf_i386_jehanne elf_x86_64 elf_i386" + ;; - i860-*-coff) targ_emul=coff_i860 ;; - i860-stardent-sysv4* | i860-stardent-elf*) - targ_emul=elf32_i860 -@@ -852,6 +855,10 @@ ia64-*-aix*) + ia16-*-elf*) targ_emul=elf_i386 targ_extra_emuls=i386msdos ;; + ia64-*-elf*) targ_emul=elf64_ia64 ;; + ia64-*-freebsd* | ia64-*-kfreebsd*-gnu) +@@ -806,6 +809,10 @@ ia64-*-aix*) NATIVE_LIB_DIRS='/usr/local/lib /usr/lib/ia64l64 /lib /usr/lib' ;; diff --git a/cross/patch/gcc.patch b/cross/patch/gcc.patch new file mode 100644 index 0000000..ccf70e4 --- /dev/null +++ b/cross/patch/gcc.patch @@ -0,0 +1,71 @@ +diff --git a/src/gcc/gcc/config.gcc b/src/gcc/gcc/config.gcc +index f02ddbd..e5ebfe0 100644 +--- a/src/gcc/gcc/config.gcc ++++ b/src/gcc/gcc/config.gcc +@@ -862,6 +862,16 @@ case ${target} in + tmake_file="$tmake_file vms/t-vmsnative" + fi + ;; ++*-*-jehanne*) ++ gas=yes ++ gnu_ld=yes ++ default_use_cxa_atexit=yes ++ case $target in ++ x86_64-*) ++ native_system_header_dir="/arch/amd64/include" ++ ;; ++ esac ++ ;; + *-*-vxworks*) + tmake_file=t-vxworks + xm_defines=POSIX +@@ -1347,6 +1357,9 @@ x86_64-*-darwin*) + 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" ++ ;; + 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/src/gcc/config.sub b/src/gcc/config.sub +index 75bb6a3..1905540 100755 +--- a/src/gcc/config.sub ++++ b/src/gcc/config.sub +@@ -1363,7 +1363,7 @@ case $os in + | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \ + | skyos* | haiku* | rdos* | toppers* | drops* | es* \ + | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ +- | midnightbsd* | amdhsa* | unleashed* | emscripten*) ++ | jehanne* | midnightbsd* | amdhsa* | unleashed* | emscripten*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + qnx*) +diff --git a/src/gcc/fixincludes/mkfixinc.sh b/src/gcc/fixincludes/mkfixinc.sh +index 0f96486..9f0ee74 100755 +--- a/src/gcc/fixincludes/mkfixinc.sh ++++ b/src/gcc/fixincludes/mkfixinc.sh +@@ -14,6 +14,7 @@ case $machine in + i?86-*-cygwin* | \ + i?86-*-mingw32* | \ + x86_64-*-mingw32* | \ ++ *-jehanne* | \ + powerpc-*-eabisim* | \ + powerpc-*-eabi* | \ + powerpc-*-rtems* | \ +diff --git a/src/gcc/libgcc/config.host b/src/gcc/libgcc/config.host +index 91abc84..a994e3a 100644 +--- a/src/gcc/libgcc/config.host ++++ b/src/gcc/libgcc/config.host +@@ -1414,6 +1414,10 @@ nvptx-*) + tmake_file="$tmake_file nvptx/t-nvptx" + extra_parts="crt0.o" + ;; ++x86_64-*-jehanne*) ++ extra_parts="$extra_parts crtbegin.o crtend.o" ++ tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic" ++ ;; + *) + echo "*** Configuration ${host} not supported" 1>&2 + exit 1 diff --git a/cross/patch/gcc/config.sub b/cross/patch/gcc/config.sub deleted file mode 100644 index 9555a9b..0000000 --- a/cross/patch/gcc/config.sub +++ /dev/null @@ -1,3 +0,0 @@ - -jehanne*) - os=-jehanne - ;; diff --git a/cross/patch/gcc/contrib/download_prerequisites b/cross/patch/gcc/contrib/download_prerequisites deleted file mode 100644 index 932dc36..0000000 --- a/cross/patch/gcc/contrib/download_prerequisites +++ /dev/null @@ -1,71 +0,0 @@ -#! /bin/sh - -# Download some prerequisites needed by gcc. -# Run this from the top level of the gcc source tree and the gcc -# build will do the right thing. -# -# (C) 2010 Free Software Foundation -# -# This program 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, either version 3 of the License, or -# (at your option) any later version. -# -# This program 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 this program. If not, see http://www.gnu.org/licenses/. - -# If you want to build GCC with the Graphite loop optimizations, -# set GRAPHITE_LOOP_OPT=yes to download optional prerequisties -# ISL Library and CLooG. -GRAPHITE_LOOP_OPT=yes - -if [ ! -e gcc/BASE-VER ] ; then - echo "You must run this script in the top level GCC source directory." - exit 1 -fi - -# Necessary to build GCC. -MPFR=mpfr-2.4.2 -GMP=gmp-4.3.2 -MPC=mpc-0.8.1 - -if [ ! -d $MPFR ]; then - wget http://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/infrastructure/$MPFR.tar.bz2 || exit 1 - tar xjf $MPFR.tar.bz2 || exit 1 - ln -sf $MPFR mpfr || exit 1 -fi - -if [ ! -d $GMP ]; then - wget http://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/infrastructure/$GMP.tar.bz2 || exit 1 - tar xjf $GMP.tar.bz2 || exit 1 - ln -sf $GMP gmp || exit 1 -fi - -if [ ! -d $MPC ]; then - wget http://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/infrastructure/$MPC.tar.gz || exit 1 - tar xzf $MPC.tar.gz || exit 1 - ln -sf $MPC mpc || exit 1 -fi - -# Necessary to build GCC with the Graphite loop optimizations. -if [ "$GRAPHITE_LOOP_OPT" = "yes" ] ; then - ISL=isl-0.12.2 - CLOOG=cloog-0.18.1 - - if [ ! -d $ISL ]; then - wget http://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/infrastructure/$ISL.tar.bz2 || exit 1 - tar xjf $ISL.tar.bz2 || exit 1 - ln -sf $ISL isl || exit 1 - fi - - if [ ! -d $CLOOG ]; then - wget http://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/infrastructure/$CLOOG.tar.gz || exit 1 - tar xzf $CLOOG.tar.gz || exit 1 - ln -sf $CLOOG cloog || exit 1 - fi -fi diff --git a/cross/patch/gcc/fixincludes/mkfixinc.sh b/cross/patch/gcc/fixincludes/mkfixinc.sh deleted file mode 100644 index dc0e343..0000000 --- a/cross/patch/gcc/fixincludes/mkfixinc.sh +++ /dev/null @@ -1 +0,0 @@ - *-jehanne* | \ diff --git a/cross/patch/gcc/gcc/config.gcc b/cross/patch/gcc/gcc/config.gcc deleted file mode 100644 index 0ee95ab..0000000 --- a/cross/patch/gcc/gcc/config.gcc +++ /dev/null @@ -1,31 +0,0 @@ -diff --git a/src/gcc/gcc/config.gcc b/src/gcc/gcc/config.gcc -index f02ddbd..e5ebfe0 100644 ---- a/src/gcc/gcc/config.gcc -+++ b/src/gcc/gcc/config.gcc -@@ -862,6 +862,16 @@ case ${target} in - tmake_file="$tmake_file vms/t-vmsnative" - fi - ;; -+*-*-jehanne*) -+ gas=yes -+ gnu_ld=yes -+ default_use_cxa_atexit=yes -+ case $target in -+ x86_64-*) -+ native_system_header_dir="/arch/amd64/include" -+ ;; -+ esac -+ ;; - *-*-vxworks*) - tmake_file=t-vxworks - xm_defines=POSIX -@@ -1347,6 +1357,9 @@ x86_64-*-darwin*) - 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" -+ ;; - 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.h b/cross/patch/gcc/gcc/config/jehanne.h index 1977cfb..7f99e6c 100644 --- a/cross/patch/gcc/gcc/config/jehanne.h +++ b/cross/patch/gcc/gcc/config/jehanne.h @@ -1,7 +1,7 @@ /* * This file is part of Jehanne. * - * Copyright (C) 2016 Giacomo Tesio + * Copyright (C) 2016-2019 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 @@ -68,10 +68,6 @@ #undef ENDFILE_SPEC #define ENDFILE_SPEC "crtend.o%s crtn.o%s" -/* Don't automatically add extern "C" { } around header files. */ -#undef NO_IMPLICIT_EXTERN_C -#define NO_IMPLICIT_EXTERN_C 1 - /* Fix https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67132 */ #undef WCHAR_TYPE #define WCHAR_TYPE "unsigned int" diff --git a/cross/patch/gcc/libgcc/config.host b/cross/patch/gcc/libgcc/config.host deleted file mode 100644 index 390276f..0000000 --- a/cross/patch/gcc/libgcc/config.host +++ /dev/null @@ -1,4 +0,0 @@ -x86_64-*-jehanne*) - extra_parts="$extra_parts crtbegin.o crtend.o" - tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic" - ;; diff --git a/cross/patch/gcc/libgcc/config.host.sed b/cross/patch/gcc/libgcc/config.host.sed deleted file mode 100644 index 6854d52..0000000 --- a/cross/patch/gcc/libgcc/config.host.sed +++ /dev/null @@ -1,3 +0,0 @@ -/enable_execute_stack=enable-execute-stack-empty.c;/,/Configuration ${host} not supported/{ - /^case ${host} in$/r ../patch/gcc/libgcc/config.host -} diff --git a/cross/patch/gcc/libstdc++-v3/crossconfig.m4 b/cross/patch/gcc/libstdc++-v3/crossconfig.m4 deleted file mode 100644 index a74ca37..0000000 --- a/cross/patch/gcc/libstdc++-v3/crossconfig.m4 +++ /dev/null @@ -1,6 +0,0 @@ - *-jehanne*) - GLIBCXX_CHECK_COMPILER_FEATURES - GLIBCXX_CHECK_LINKER_FEATURES - GLIBCXX_CHECK_MATH_SUPPORT - GLIBCXX_CHECK_STDLIB_SUPPORT - ;; diff --git a/cross/patch/libgmp.patch b/cross/patch/libgmp.patch new file mode 100644 index 0000000..7a33851 --- /dev/null +++ b/cross/patch/libgmp.patch @@ -0,0 +1,11 @@ +diff -Naru ../orig/configfsf.sub ./configfsf.sub +--- ../orig/configfsf.sub 2018-11-26 11:59:08.897396848 +0100 ++++ ./configfsf.sub 2018-11-26 12:20:10.079672849 +0100 +@@ -1399,6 +1399,7 @@ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ ++ | -jehanne* \ + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; diff --git a/cross/patch/libmpc.patch b/cross/patch/libmpc.patch new file mode 100644 index 0000000..b207673 --- /dev/null +++ b/cross/patch/libmpc.patch @@ -0,0 +1,11 @@ +diff -Naru ../orig/config.sub ./config.sub +--- ../orig/config.sub 2018-11-27 00:30:59.807843647 +0100 ++++ ./config.sub 2018-11-27 00:32:49.224841688 +0100 +@@ -1393,6 +1393,7 @@ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ ++ | -jehanne* \ + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; diff --git a/cross/patch/libmpfr.patch b/cross/patch/libmpfr.patch new file mode 100644 index 0000000..74f3e61 --- /dev/null +++ b/cross/patch/libmpfr.patch @@ -0,0 +1,11 @@ +diff -Naru ../orig/config.sub ./config.sub +--- ../orig/config.sub 2018-11-26 14:23:59.224388851 +0100 ++++ ./config.sub 2018-11-26 14:24:55.300412850 +0100 +@@ -1416,6 +1416,7 @@ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ ++ | -jehanne* \ + | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; diff --git a/cross/src/.gitignore b/cross/src/.gitignore deleted file mode 100644 index e3300fa..0000000 --- a/cross/src/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -gcc -binutils -autoconf -automake -libtool -m4 -build-* diff --git a/cross/src/fetch.json b/cross/src/fetch.json index 5e93a19..6ea8069 100644 --- a/cross/src/fetch.json +++ b/cross/src/fetch.json @@ -1,38 +1,28 @@ { - "autoconf" : { - "Upstream":"https://ftp.gnu.org/gnu/autoconf/autoconf-2.64.tar.bz2", + "libgmp" : { + "Upstream":"https://gmplib.org/download/gmp/gmp-6.1.2.tar.bz2", "Digest": { - "sha256":"872f4cadf12e7e7c8a2414e047fdff26b517c7f1a977d72433c124d0d3acaa85" + "sha256":"5275bb04f4863a13516b2f39392ac5e272f5e1bb8057b18aec1c9b79d73d8fb2" }, "Compress":"bzip2", "RemovePrefix": true, "Exclude": [ ] }, - "m4": { - "Upstream":"https://ftp.gnu.org/gnu/m4/m4-1.4.14.tar.bz2", + "libmpfr" : { + "Upstream":"https://www.mpfr.org/mpfr-4.0.1/mpfr-4.0.1.tar.bz2", "Digest": { - "sha256":"0885ffa93256353a96b1cf0bcbc4d639ed09953b687e6cc412c4048e656f4dd2" + "sha256":"a4d97610ba8579d380b384b225187c250ef88cfe1d5e7226b89519374209b86b" }, "Compress":"bzip2", "RemovePrefix": true, "Exclude": [ ] }, - "automake": { - "Upstream":"https://ftp.gnu.org/gnu/automake/automake-1.11.1.tar.bz2", + "libmpc" : { + "Upstream":"https://ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz", "Digest": { - "sha256":"5b159d3c0e0a1f87de71b68bcb9f1a1c49e9e71749c9b723f17e2e1e0295c7ae" - }, - "Compress":"bzip2", - "RemovePrefix": true, - "Exclude": [ - ] - }, - "libtool": { - "Upstream":"https://ftp.gnu.org/gnu/libtool/libtool-2.4.tar.gz", - "Digest": { - "sha256":"13df57ab63a94e196c5d6e95d64e53262834fe780d5e82c28f177f9f71ddf62e" + "sha256":"6985c538143c1208dcb1ac42cedad6ff52e267b47e5f970183a3e75125b43c2e" }, "Compress":"gzip", "RemovePrefix": true, @@ -40,9 +30,9 @@ ] }, "binutils": { - "Upstream":"https://ftp.gnu.org/gnu/binutils/binutils-2.26.tar.bz2", + "Upstream":"http://ftp.gnu.org/gnu/binutils/binutils-2.33.1.tar.bz2", "Digest": { - "sha256":"c2ace41809542f5237afc7e3b8f32bb92bc7bc53c6232a84463c423b0714ecd9" + "sha256":"0cb4843da15a65a953907c96bad658283f3c4419d6bcc56bf2789db16306adb2" }, "Compress":"bzip2", "RemovePrefix": true, @@ -50,13 +40,14 @@ ] }, "gcc": { - "Upstream":"https://ftp.gnu.org/gnu/gcc/gcc-4.9.4/gcc-4.9.4.tar.bz2", + "Upstream":"https://ftp.gnu.org/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.gz", "Digest": { - "sha256":"6c11d292cd01b294f9f84c9a59c230d80e9e4a47e5c6355f046bb36d4f358092" + "sha256":"a931a750d6feadacbeecb321d73925cd5ebb6dfa7eff0802984af3aef63759f4" }, - "Compress":"bzip2", + "Compress":"gzip", "RemovePrefix": true, "Exclude": [ ] } + } From 492f37764029ceba5df77aaa51172f5e600d3118 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Fri, 22 Nov 2019 00:13:45 +0100 Subject: [PATCH 35/91] gcc native: build cross GCC 9.2.0 outside of sysroot --- cross/init.sh | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/cross/init.sh b/cross/init.sh index 18cca60..fe41ba6 100755 --- a/cross/init.sh +++ b/cross/init.sh @@ -51,9 +51,9 @@ function dynpatch { # setup Jehanne's headers -usyscalls header $JEHANNE/sys/src/sysconf.json > $JEHANNE/arch/amd64/include/syscalls.h +#usyscalls header $JEHANNE/sys/src/sysconf.json > $JEHANNE/arch/amd64/include/syscalls.h -mkdir -p $WORKING_DIR +#mkdir -p $WORKING_DIR date > $LOG # verify libtool is installed @@ -67,14 +67,17 @@ fetch >> $LOG failOnError $? "fetching sources" mkdir -p $WORKING_DIR/build +rm -f $JEHANNE/hacking/bin/makeinfo +ln -s `which true` $JEHANNE/hacking/bin/makeinfo # don't depend on texinfo mkdir -p $WORKING_DIR/cross # Patch and build binutils +echo Building binutils... export BINUTILS_BUILD_DIR=$WORKING_DIR/build/binutils mkdir -p $BINUTILS_BUILD_DIR ( ( grep -q jehanne $WORKING_DIR/src/binutils/config.sub || ( - cd $WORKING_DIR + cd $WORKING_DIR && sed -i '/jehanne/b; /ELF_TARGET_ID/,/elf_backend_can_gc_sections/s/0x200000/0x1000 \/\/ jehanne hack/g' src/binutils/bfd/elf64-x86-64.c && sed -i '/jehanne/b; s/| midnightbsd\*/| midnightbsd* | jehanne*/g' src/binutils/config.sub && dynpatch 'binutils/bfd/config.bfd' '\# END OF targmatch.h' && @@ -97,4 +100,31 @@ mkdir -p $BINUTILS_BUILD_DIR make DESTDIR=$WORKING_DIR/cross install ) >> $LOG 2>&1 failOnError $? "Building binutils" +echo done. +echo -n Building gcc... | tee -a $WORKING_DIR/gcc.build.log +# Patch and build gcc +export GCC_BUILD_DIR=$WORKING_DIR/build/gcc +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 && + sed -i 's/ftp/https/g' src/gcc/contrib/download_prerequisites && + cd src && + ( cd gcc && ./contrib/download_prerequisites ) && +# ( cd gcc/libstdc++-v3 && autoconf -i ) && + cd $GCC_BUILD_DIR && + $WORKING_DIR/src/gcc/configure --target=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE --enable-languages=c,c++ --disable-multilib --disable-threads --disable-tls --disable-initfini-array --disable-bootstrap --disable-nls && + make all-gcc && + make DESTDIR=$WORKING_DIR/cross install-gcc +# make all-gcc all-target-libgcc && +# make DESTDIR=$JEHANNE/pkgs/gcc/9.2.0/ install-gcc install-target-libgcc +# && +# make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true all-target-libstdc++-v3 && +# make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true install-target-libstdc++-v3 +) >> $LOG 2>&1 +failOnError $? "building gcc" + +echo done. From 05c7ff454ed34191aa9ff1b544dcf6b9c725bcaa Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Fri, 22 Nov 2019 22:52:17 +0100 Subject: [PATCH 36/91] gcc native: moved cross compiler (GCC 9.2.0) out of system tree --- cross/init.sh | 11 ++++++----- devshell.sh | 9 +++++++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/cross/init.sh b/cross/init.sh index fe41ba6..8d5f436 100755 --- a/cross/init.sh +++ b/cross/init.sh @@ -51,9 +51,9 @@ function dynpatch { # setup Jehanne's headers -#usyscalls header $JEHANNE/sys/src/sysconf.json > $JEHANNE/arch/amd64/include/syscalls.h +usyscalls header $JEHANNE/sys/src/sysconf.json > $JEHANNE/arch/amd64/include/syscalls.h -#mkdir -p $WORKING_DIR +mkdir -p $WORKING_DIR date > $LOG # verify libtool is installed @@ -106,6 +106,7 @@ echo -n Building gcc... | tee -a $WORKING_DIR/gcc.build.log # Patch and build gcc export GCC_BUILD_DIR=$WORKING_DIR/build/gcc mkdir -p $GCC_BUILD_DIR +export CPATH="$WORKING_DIR/cross/posix/lib/gcc/x86_64-jehanne/9.2.0/include:$WORKING_DIR/cross/posix/lib/gcc/x86_64-jehanne/9.2.0/include-fixed" ( cd $WORKING_DIR && @@ -116,9 +117,9 @@ mkdir -p $GCC_BUILD_DIR ( cd gcc && ./contrib/download_prerequisites ) && # ( cd gcc/libstdc++-v3 && autoconf -i ) && cd $GCC_BUILD_DIR && - $WORKING_DIR/src/gcc/configure --target=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE --enable-languages=c,c++ --disable-multilib --disable-threads --disable-tls --disable-initfini-array --disable-bootstrap --disable-nls && - make all-gcc && - make DESTDIR=$WORKING_DIR/cross install-gcc + $WORKING_DIR/src/gcc/configure --target=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE --enable-languages=c,c++ --disable-multiarch --disable-multilib --disable-threads --disable-tls --disable-initfini-array --disable-bootstrap --disable-nls && + make all-gcc all-target-libgcc && + make DESTDIR=$WORKING_DIR/cross install-gcc install-target-libgcc # make all-gcc all-target-libgcc && # make DESTDIR=$JEHANNE/pkgs/gcc/9.2.0/ install-gcc install-target-libgcc # && diff --git a/devshell.sh b/devshell.sh index 703f04d..437aac2 100755 --- a/devshell.sh +++ b/devshell.sh @@ -5,9 +5,14 @@ # Copyright (C) 2016-2017 Giacomo Tesio export JEHANNE=`git rev-parse --show-toplevel` +REPONAME=`basename $JEHANNE` +JEHANNE_TOOLCHAIN=`dirname $JEHANNE` +JEHANNE_TOOLCHAIN="$JEHANNE_TOOLCHAIN/$REPONAME.TOOLCHAIN" + + export PATH="$JEHANNE/hacking/bin:$PATH" -export PATH="$JEHANNE/hacking/cross/toolchain/bin:$PATH" -export CPATH="$JEHANNE/hacking/cross/toolchain/lib/gcc/x86_64-jehanne/4.9.4/include:$JEHANNE/hacking/cross/toolchain/lib/gcc/x86_64-jehanne/4.9.4/include-fixed" +export PATH="$JEHANNE_TOOLCHAIN/cross/posix/bin:$PATH" +export CPATH="$JEHANNE_TOOLCHAIN/cross/posix/lib/gcc/x86_64-jehanne/9.2.0/include:$JEHANNE_TOOLCHAIN/cross/posix/lib/gcc/x86_64-jehanne/9.2.0/include-fixed" export ARCH=amd64 export TOOLPREFIX=x86_64-jehanne- From e794cf272b4b1d805ea5d9c695ea553f501b0020 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Sun, 24 Nov 2019 15:49:04 +0100 Subject: [PATCH 37/91] usyscalls: fix cast --- src/jehanne/cmd/usyscalls/usyscalls.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jehanne/cmd/usyscalls/usyscalls.go b/src/jehanne/cmd/usyscalls/usyscalls.go index 7d68d72..b3329ed 100644 --- a/src/jehanne/cmd/usyscalls/usyscalls.go +++ b/src/jehanne/cmd/usyscalls/usyscalls.go @@ -1,7 +1,7 @@ /* * This file is part of Jehanne. * - * Copyright (C) 2016 Giacomo Tesio + * Copyright (C) 2016-2019 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 @@ -154,7 +154,7 @@ func getHeaderData(calls []SyscallConf) *HeaderCode { wcall.FuncArgs += fmt.Sprintf("%s a%d", a, i) wcall.MacroArgs += fmt.Sprintf("/* %s */ a%d", a, i) if typeName == "p" { - wcall.VarValues = append(wcall.VarValues, fmt.Sprintf("_sysargs[%d].%s = ((void*)a%d); \\\n\t", i, typeName, i)) + wcall.VarValues = append(wcall.VarValues, fmt.Sprintf("_sysargs[%d].%s = ((volatile void*)(a%d)); \\\n\t", i, typeName, i)) } else { wcall.VarValues = append(wcall.VarValues, fmt.Sprintf("_sysargs[%d].%s = (a%d); \\\n\t", i, typeName, i)) } From 026c082f2a5581fb7e390a6a8c433276d2326478 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Sun, 24 Nov 2019 15:51:17 +0100 Subject: [PATCH 38/91] gcc: do not automatically include /posix --- cross/patch/gcc/gcc/config/jehanne.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/cross/patch/gcc/gcc/config/jehanne.h b/cross/patch/gcc/gcc/config/jehanne.h index 7f99e6c..fec6d6b 100644 --- a/cross/patch/gcc/gcc/config/jehanne.h +++ b/cross/patch/gcc/gcc/config/jehanne.h @@ -28,21 +28,19 @@ #undef MD_STARTFILE_PREFIX #define MD_STARTFILE_PREFIX "/arch/amd64/lib/" - +/* #undef GPLUSPLUS_INCLUDE_DIR #define GPLUSPLUS_INCLUDE_DIR "/posix/g++" #undef GCC_INCLUDE_DIR #define GCC_INCLUDE_DIR "/posix/gcc" - +*/ /* Architecture specific header (u.h) goes here (from config.gcc) */ #define ARCH_INCLUDE_DIR NATIVE_SYSTEM_HEADER_DIR /* The default include dir is /sys/include but... */ #define PORTABLE_INCLUDE_DIR "/sys/include" -#define POSIX_INCLUDE_DIR "/posix/include" - /* ...we have to wrap libc.h and stdio.h with basic POSIX headers */ #define BASIC_POSIX_INCLUDE_DIR "/sys/include/apw" @@ -50,12 +48,11 @@ #define INCLUDE_DEFAULTS \ { \ { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, 1, 0 }, \ - { GCC_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ - { POSIX_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ + { GCC_INCLUDE_DIR, "GCC", 0, 0, 1, 0 }, \ { BASIC_POSIX_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ - { ARCH_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ { PORTABLE_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ - { ".", 0, 0, 0, 1, 0 }, \ + { ARCH_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ + { ".", 0, 0, 0, 0, 0 }, \ { 0, 0, 0, 0, 0, 0 } \ } From 558d3985e9c50bff8a98be3bf4368459c5d4ea90 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Mon, 25 Nov 2019 12:50:41 +0100 Subject: [PATCH 39/91] cross gcc: no customizations in cross compiler configuration --- cross/init.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cross/init.sh b/cross/init.sh index 8d5f436..6219482 100755 --- a/cross/init.sh +++ b/cross/init.sh @@ -72,7 +72,7 @@ ln -s `which true` $JEHANNE/hacking/bin/makeinfo # don't depend on texinfo mkdir -p $WORKING_DIR/cross # Patch and build binutils -echo Building binutils... +echo -n Building binutils... export BINUTILS_BUILD_DIR=$WORKING_DIR/build/binutils mkdir -p $BINUTILS_BUILD_DIR @@ -88,7 +88,7 @@ mkdir -p $BINUTILS_BUILD_DIR dynpatch 'binutils/ld/Makefile.am' 'eelf_x86_64.c: ' && (grep 'eelf_i386_jehanne.c \\' src/binutils/ld/Makefile.am || sed -i 's/.*ALL_EMULATION_SOURCES = \\.*/&\n\teelf_i386_jehanne.c \\/' src/binutils/ld/Makefile.am) && (grep 'eelf_x86_64_jehanne.c \\' src/binutils/ld/Makefile.am || sed -i 's/.*ALL_64_EMULATION_SOURCES = \\.*/&\n\teelf_x86_64_jehanne.c \\/' src/binutils/ld/Makefile.am) && - cd src/binutils/ld && automake-1.15 && cd ../ + cd src/binutils/ld && automake-1.15 && cd ../ ) ) && cd $BINUTILS_BUILD_DIR && $WORKING_DIR/src/binutils/configure --target=x86_64-jehanne --prefix=/posix --with-sysroot=$JEHANNE --target=x86_64-jehanne --enable-interwork --enable-multilib --enable-newlib-long-time_t --disable-nls --disable-werror && @@ -96,7 +96,7 @@ mkdir -p $BINUTILS_BUILD_DIR 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 && cp $CROSS_DIR/patch/MakeNothing.in $WORKING_DIR/src/binutils/binutils/doc/Makefile.in && - make && + make && make DESTDIR=$WORKING_DIR/cross install ) >> $LOG 2>&1 failOnError $? "Building binutils" @@ -117,9 +117,11 @@ export CPATH="$WORKING_DIR/cross/posix/lib/gcc/x86_64-jehanne/9.2.0/include:$WOR ( cd gcc && ./contrib/download_prerequisites ) && # ( cd gcc/libstdc++-v3 && autoconf -i ) && cd $GCC_BUILD_DIR && - $WORKING_DIR/src/gcc/configure --target=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE --enable-languages=c,c++ --disable-multiarch --disable-multilib --disable-threads --disable-tls --disable-initfini-array --disable-bootstrap --disable-nls && + $WORKING_DIR/src/gcc/configure --target=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE --enable-languages=c,c++ && make all-gcc all-target-libgcc && - make DESTDIR=$WORKING_DIR/cross install-gcc install-target-libgcc + make DESTDIR=$WORKING_DIR/cross install-gcc install-target-libgcc # && +# make all-target-libstdc++-v3 && +# make DESTDIR=$WORKING_DIR/cross install-target-libstdc++-v3 # make all-gcc all-target-libgcc && # make DESTDIR=$JEHANNE/pkgs/gcc/9.2.0/ install-gcc install-target-libgcc # && From 15b4c0b6b9a17dcd9178c87d95c4da3a392f6287 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Wed, 27 Nov 2019 01:52:24 +0100 Subject: [PATCH 40/91] usyscall: purge syscall macros --- src/jehanne/cmd/usyscalls/usyscalls.go | 36 +++++--------------------- 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/src/jehanne/cmd/usyscalls/usyscalls.go b/src/jehanne/cmd/usyscalls/usyscalls.go index b3329ed..f912c80 100644 --- a/src/jehanne/cmd/usyscalls/usyscalls.go +++ b/src/jehanne/cmd/usyscalls/usyscalls.go @@ -31,7 +31,7 @@ import ( const gplHeader string = `/* * This file is part of Jehanne. * - * Copyright (C) 2016 Giacomo Tesio + * Copyright (C) 2016-2019 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 @@ -173,7 +173,7 @@ func getHeaderData(calls []SyscallConf) *HeaderCode { func generateSyscallTable(calls []SyscallConf){ code := getHeaderData(calls) tmpl, err := template.New("tab.c").Parse(` -{{ range .Wrappers }}"{{ .Name }}", (int(*)()) {{ .Name }}, +{{ range .Wrappers }}"{{ .Name }}", (int(*)()) sys_{{ .Name }}, {{ end }} `) err = tmpl.Execute(os.Stdout, code) @@ -189,9 +189,9 @@ func generateLibcCode(calls []SyscallConf){ #include {{ range .Wrappers }} -#pragma weak {{ .Name }} +#pragma weak sys_{{ .Name }} {{ .RetType }} -{{ .Name }}({{ .FuncArgs }}) +sys_{{ .Name }}({{ .FuncArgs }}) { register {{ .RetType }} __ret asm ("rax"); __asm__ __volatile__ ( @@ -224,34 +224,10 @@ typedef enum Syscalls {{ end }}} Syscalls; #ifndef KERNEL -{{ range .Wrappers }} -#define sys_{{ .Name }}({{ .MacroArgs }}) ({ \ - {{ range .VarValues }}{{.}}{{end}}{{ range .Vars }}{{.}}{{end}}register {{ .RetType }} __ret asm ("rax"); \ - __asm__ __volatile__ ( \ - "syscall" \ - : "=&r" (__ret) \ - : {{ .AsmArgs }} \ - : {{ .AsmClobbers }} \ - ); \ - __ret; }) + +{{ range .Wrappers }}extern {{ .RetType }} sys_{{ .Name }}({{ .FuncArgs }}); {{ end }} -#ifdef PORTABLE_SYSCALLS - -{{ range .Wrappers }}extern {{ .RetType }} {{ .Name }}({{ .FuncArgs }}); -{{ end }} -extern int32_t read(int, void*, int32_t); -extern int32_t write(int, const void*, int32_t); - -#else - -{{ range .Wrappers }}# define {{ .Name }}(...) sys_{{ .Name }}(__VA_ARGS__) -{{ end }} -#define read(fd, buf, size) pread(fd, buf, size, -1) -#define write(fd, buf, size) pwrite(fd, buf, size, -1) - -#endif - #endif `) err = tmpl.Execute(os.Stdout, code) From 86bf70b6e848da368f102c97f01b6588060bdbc6 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Thu, 28 Nov 2019 01:11:43 +0100 Subject: [PATCH 41/91] cross pkgs: use hosted compiler in newlib and mksh (still to properly install in /posix) --- cross/pkgs/mksh/build.sh | 4 ++-- cross/pkgs/newlib/build.sh | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cross/pkgs/mksh/build.sh b/cross/pkgs/mksh/build.sh index 783856e..c195f58 100755 --- a/cross/pkgs/mksh/build.sh +++ b/cross/pkgs/mksh/build.sh @@ -27,8 +27,8 @@ export MKSH=$CROSS_DIR/pkgs/mksh/ export MKSH_SRC=$MKSH/src/ export MKSH_BUILD=$MKSH/out/ export MKSHRC_PATH='~/lib/mkshrc' -export LIBS="$JEHANNE/posix/lib/libc.a $JEHANNE/posix/lib/libm.a $JEHANNE/posix/lib/libg.a -lposix -lc" -export CPPFLAGS="'-DMKSHRC_PATH=\"$MKSHRC_PATH\"' '-DARCH=\"$ARCH\"'" +export LIBS="-L$JEHANNE/posix/lib -lnewlibc -lnewlibm -lnewlibg -lposix" +export CPPFLAGS="-I$JEHANNE/posix/include '-DMKSHRC_PATH=\"$MKSHRC_PATH\"' '-DARCH=\"$ARCH\"'" export LD_PRELOAD= diff --git a/cross/pkgs/newlib/build.sh b/cross/pkgs/newlib/build.sh index 1c3f0b2..f204496 100755 --- a/cross/pkgs/newlib/build.sh +++ b/cross/pkgs/newlib/build.sh @@ -69,9 +69,7 @@ fi export CC=gcc -# NOTE: we use -O0 because apparently vsprintf functions do not -# work with -O2. -export CFLAGS_FOR_TARGET="-g -gdwarf-2 -ggdb -O$NEWLIB_OPTIMIZATION -std=gnu11" +export CFLAGS_FOR_TARGET="-g -gdwarf-2 -ggdb -O$NEWLIB_OPTIMIZATION -std=gnu11 -Lposix" ( rm -fr $NEWLIB_BUILD && @@ -89,9 +87,10 @@ export CFLAGS_FOR_TARGET="-g -gdwarf-2 -ggdb -O$NEWLIB_OPTIMIZATION -std=gnu11" failOnError $? "building newlib" # emultate bind for the cross compiler +mkdir -p $JEHANNE/posix cp -fr $JEHANNE/pkgs/newlib/x86_64-jehanne/* $JEHANNE/posix -# rename libc to libnewlibc to avoid name clash with Jehanne libc +# rename libc to libnewlibc to avoid name clash with Jehanne's libc mv $JEHANNE/posix/lib/libc.a $JEHANNE/posix/lib/libnewlibc.a mv $JEHANNE/posix/lib/libm.a $JEHANNE/posix/lib/libnewlibm.a mv $JEHANNE/posix/lib/libg.a $JEHANNE/posix/lib/libnewlibg.a From cd6c4368c840b86b3a9269e701bb20d475bb9a4d Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Thu, 28 Nov 2019 23:13:29 +0100 Subject: [PATCH 42/91] gcc native: add jehanne to libstdc++-v3/crossconfig.m4 --- cross/patch/gcc.patch | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cross/patch/gcc.patch b/cross/patch/gcc.patch index ccf70e4..eb38b7e 100644 --- a/cross/patch/gcc.patch +++ b/cross/patch/gcc.patch @@ -69,3 +69,20 @@ index 91abc84..a994e3a 100644 *) echo "*** Configuration ${host} not supported" 1>&2 exit 1 +diff --git a/src/gcc/libstdc++-v3/crossconfig.m4 b/src/gcc/libstdc++-v3/crossconfig.m4 +index 344eec0..cc6eafe 100644 +--- a/src/gcc/libstdc++-v3/crossconfig.m4 ++++ b/src/gcc/libstdc++-v3/crossconfig.m4 +@@ -186,6 +186,12 @@ case "${host}" in + ;; + esac + ;; ++ *-jehanne*) ++ GLIBCXX_CHECK_COMPILER_FEATURES ++ GLIBCXX_CHECK_LINKER_FEATURES ++ GLIBCXX_CHECK_MATH_SUPPORT ++ GLIBCXX_CHECK_STDLIB_SUPPORT ++ ;; + *-linux* | *-uclinux* | *-gnu* | *-kfreebsd*-gnu | *-cygwin* | *-solaris*) + GLIBCXX_CHECK_COMPILER_FEATURES + GLIBCXX_CHECK_LINKER_FEATURES From 563195126886c773c9bba018267e1d23f9f6b385 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Wed, 11 Dec 2019 21:46:43 +0100 Subject: [PATCH 43/91] gcc cross compiler: do not add . to include paths --- cross/patch/gcc/gcc/config/jehanne.h | 1 - 1 file changed, 1 deletion(-) diff --git a/cross/patch/gcc/gcc/config/jehanne.h b/cross/patch/gcc/gcc/config/jehanne.h index fec6d6b..49162ac 100644 --- a/cross/patch/gcc/gcc/config/jehanne.h +++ b/cross/patch/gcc/gcc/config/jehanne.h @@ -52,7 +52,6 @@ { BASIC_POSIX_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ { PORTABLE_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ { ARCH_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ - { ".", 0, 0, 0, 0, 0 }, \ { 0, 0, 0, 0, 0, 0 } \ } From 0ae284b23b2036a32178fa39e3fdb752a00349b1 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Thu, 12 Dec 2019 01:05:29 +0100 Subject: [PATCH 44/91] gcc cross compiler: copy GCC headers into $JEHANNE/posix; reconfigure patched gcc/libstdc++-v3 --- cross/init.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cross/init.sh b/cross/init.sh index 6219482..328754b 100755 --- a/cross/init.sh +++ b/cross/init.sh @@ -102,7 +102,7 @@ mkdir -p $BINUTILS_BUILD_DIR failOnError $? "Building binutils" echo done. -echo -n Building gcc... | tee -a $WORKING_DIR/gcc.build.log +echo -n Building gcc... | tee -a $LOG # Patch and build gcc export GCC_BUILD_DIR=$WORKING_DIR/build/gcc mkdir -p $GCC_BUILD_DIR @@ -115,7 +115,7 @@ export CPATH="$WORKING_DIR/cross/posix/lib/gcc/x86_64-jehanne/9.2.0/include:$WOR sed -i 's/ftp/https/g' src/gcc/contrib/download_prerequisites && cd src && ( cd gcc && ./contrib/download_prerequisites ) && -# ( cd gcc/libstdc++-v3 && autoconf -i ) && + ( cd gcc/libstdc++-v3 && autoconf -i ) && cd $GCC_BUILD_DIR && $WORKING_DIR/src/gcc/configure --target=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE --enable-languages=c,c++ && make all-gcc all-target-libgcc && @@ -129,5 +129,10 @@ export CPATH="$WORKING_DIR/cross/posix/lib/gcc/x86_64-jehanne/9.2.0/include:$WOR # make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true install-target-libstdc++-v3 ) >> $LOG 2>&1 failOnError $? "building gcc" - +echo done. + +echo -n Copying GCC includes into $JEHANNE/posix +mkdir -p $JEHANNE/posix/lib +cp -fpr $WORKING_DIR/cross/posix/lib/* $JEHANNE/posix/lib +cp -fpr $WORKING_DIR/cross/posix/lib/gcc/x86_64-jehanne/9.2.0/include-fixed/* $JEHANNE/posix/lib/gcc/x86_64-jehanne/9.2.0/include/ echo done. From 7490843fcc07ea5e7b4b86e5acd934de84ad5c57 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Fri, 13 Dec 2019 00:30:24 +0100 Subject: [PATCH 45/91] gcc cross compiler: remove CPATH and comments --- cross/init.sh | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/cross/init.sh b/cross/init.sh index 328754b..d4f9cc0 100755 --- a/cross/init.sh +++ b/cross/init.sh @@ -106,7 +106,6 @@ echo -n Building gcc... | tee -a $LOG # Patch and build gcc export GCC_BUILD_DIR=$WORKING_DIR/build/gcc mkdir -p $GCC_BUILD_DIR -export CPATH="$WORKING_DIR/cross/posix/lib/gcc/x86_64-jehanne/9.2.0/include:$WORKING_DIR/cross/posix/lib/gcc/x86_64-jehanne/9.2.0/include-fixed" ( cd $WORKING_DIR && @@ -119,19 +118,12 @@ export CPATH="$WORKING_DIR/cross/posix/lib/gcc/x86_64-jehanne/9.2.0/include:$WOR cd $GCC_BUILD_DIR && $WORKING_DIR/src/gcc/configure --target=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE --enable-languages=c,c++ && make all-gcc all-target-libgcc && - make DESTDIR=$WORKING_DIR/cross install-gcc install-target-libgcc # && -# make all-target-libstdc++-v3 && -# make DESTDIR=$WORKING_DIR/cross install-target-libstdc++-v3 -# make all-gcc all-target-libgcc && -# make DESTDIR=$JEHANNE/pkgs/gcc/9.2.0/ install-gcc install-target-libgcc -# && -# make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true all-target-libstdc++-v3 && -# make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true install-target-libstdc++-v3 + make DESTDIR=$WORKING_DIR/cross install-gcc install-target-libgcc ) >> $LOG 2>&1 failOnError $? "building gcc" echo done. -echo -n Copying GCC includes into $JEHANNE/posix +echo -n Copying GCC includes into $JEHANNE/posix... mkdir -p $JEHANNE/posix/lib cp -fpr $WORKING_DIR/cross/posix/lib/* $JEHANNE/posix/lib cp -fpr $WORKING_DIR/cross/posix/lib/gcc/x86_64-jehanne/9.2.0/include-fixed/* $JEHANNE/posix/lib/gcc/x86_64-jehanne/9.2.0/include/ From f3c2a947f76d1082db243feddd30003d97c9c921 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Fri, 13 Dec 2019 00:47:07 +0100 Subject: [PATCH 46/91] devshell.sh: do not define CPATH --- devshell.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devshell.sh b/devshell.sh index 437aac2..a1d1140 100755 --- a/devshell.sh +++ b/devshell.sh @@ -12,7 +12,7 @@ JEHANNE_TOOLCHAIN="$JEHANNE_TOOLCHAIN/$REPONAME.TOOLCHAIN" export PATH="$JEHANNE/hacking/bin:$PATH" export PATH="$JEHANNE_TOOLCHAIN/cross/posix/bin:$PATH" -export CPATH="$JEHANNE_TOOLCHAIN/cross/posix/lib/gcc/x86_64-jehanne/9.2.0/include:$JEHANNE_TOOLCHAIN/cross/posix/lib/gcc/x86_64-jehanne/9.2.0/include-fixed" +#export CPATH="$JEHANNE_TOOLCHAIN/cross/posix/lib/gcc/x86_64-jehanne/9.2.0/include:$JEHANNE_TOOLCHAIN/cross/posix/lib/gcc/x86_64-jehanne/9.2.0/include-fixed" export ARCH=amd64 export TOOLPREFIX=x86_64-jehanne- From f706eca22b77339195f782c744770ba7a40a581c Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Fri, 13 Dec 2019 01:12:08 +0100 Subject: [PATCH 47/91] gcc native: created cross/native.sh (and wrappers) to build libstdc++, binutils and gcc (still broken) --- cross/native.sh | 184 ++++++++++++++++++++++++++++++ cross/wrappers/x86_64-jehanne-g++ | 27 +++++ cross/wrappers/x86_64-jehanne-gcc | 27 +++++ cross/wrappers/x86_64-jehanne-ld | 26 +++++ 4 files changed, 264 insertions(+) create mode 100755 cross/native.sh create mode 100755 cross/wrappers/x86_64-jehanne-g++ create mode 100755 cross/wrappers/x86_64-jehanne-gcc create mode 100755 cross/wrappers/x86_64-jehanne-ld diff --git a/cross/native.sh b/cross/native.sh new file mode 100755 index 0000000..e769f1c --- /dev/null +++ b/cross/native.sh @@ -0,0 +1,184 @@ +#!/bin/bash + +echo "Cross compiling GCC and dependencies" + +REPONAME=`basename $JEHANNE` +WORKING_DIR=`dirname $JEHANNE` +WORKING_DIR="$WORKING_DIR/$REPONAME.TOOLCHAIN" +CROSS_DIR="$JEHANNE/hacking/cross" +LOG="$WORKING_DIR/native.build.log" + +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 + if [ $1 -ne 0 ]; then + echo "ERROR $2" + echo + echo BUILD LOG: + echo + cat $LOG + exit $1 + fi +} + +date > $LOG + +# mock makeinfo (to avoid it as a dependency) +rm -f $JEHANNE/hacking/bin/makeinfo +ln -s `which echo` $JEHANNE/hacking/bin/makeinfo + +# verify libtool is installed +libtool --version >> /dev/null +failOnError $? "libtool installation check" + +(cd $WORKING_DIR/src && fetch) >> $LOG +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 +( + rm -fr $WORKING_DIR/src/gcc/isl-0.18.tar.bz2 && + rm -fr $WORKING_DIR/src/gcc/isl-0.18 && + rm -fr $WORKING_DIR/src/gcc/isl && + rm -fr $WORKING_DIR/src/gcc/gmp-6.1.0.tar.bz2 && + rm -fr $WORKING_DIR/src/gcc/gmp-6.1.0 && + rm -fr $WORKING_DIR/src/gcc/gmp && + rm -fr $WORKING_DIR/src/gcc/mpfr-3.1.4.tar.bz2 && + rm -fr $WORKING_DIR/src/gcc/mpfr-3.1.4 && + rm -fr $WORKING_DIR/src/gcc/mpfr && + rm -fr $WORKING_DIR/src/gcc/mpc-1.0.3.tar.gz && + 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 + make && + make DESTDIR=$JEHANNE/pkgs/libstdc++-v3/9.2.0/ install +) >> $LOG 2>&1 +failOnError $? "building libstdc++-v3" +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 + +echo -n Building libgmp... | tee -a $LOG +( + cd $WORKING_DIR/src/libgmp && + ( grep -q jehanne configfsf.sub || patch -p0 < $CROSS_DIR/patch/libgmp.patch ) && + ./configure --host=x86_64-jehanne --disable-shared --prefix=/posix --with-sysroot=$JEHANNE && + make && + make DESTDIR=$JEHANNE/pkgs/libgmp/6.1.2/ install && + libtool --mode=finish $JEHANNE/posix/lib +) >> $LOG 2>&1 +failOnError $? "Building libgmp" +echo done. + +# Copy to /posix (to emulate bind during cross compilation) +cp -pfr $JEHANNE/pkgs/libgmp/6.1.2/posix/* $JEHANNE/posix +rm $JEHANNE/posix/lib/*.la + +echo -n Building libmpfr... | tee -a $LOG +( + cd $WORKING_DIR/src/libmpfr && + ( grep -q jehanne config.sub || patch -p0 < $CROSS_DIR/patch/libmpfr.patch ) && + ./configure --host=x86_64-jehanne --disable-shared --prefix=/posix --with-sysroot=$JEHANNE --with-gmp=$JEHANNE/posix/ && + cp $CROSS_DIR/patch/MakeNothing.in doc/Makefile.in && + make && + make DESTDIR=$JEHANNE/pkgs/libmpfr/4.0.1/ install && + libtool --mode=finish $JEHANNE/posix/lib +) >> $LOG 2>&1 +failOnError $? "Building libmpfr" +echo done. + +# Copy to /posix (to emulate bind during cross compilation) +cp -pfr $JEHANNE/pkgs/libmpfr/4.0.1/posix/* $JEHANNE/posix +rm $JEHANNE/posix/lib/*.la + +echo -n Building libmpc... | tee -a $LOG +( + cd $WORKING_DIR/src/libmpc && + ( grep -q jehanne config.sub || ( chmod u+w config.sub && + patch -p0 < $CROSS_DIR/patch/libmpc.patch && + chmod u-w config.sub ) ) && + ./configure --host=x86_64-jehanne --disable-shared --prefix=/posix --with-sysroot=$JEHANNE --with-gmp=$JEHANNE/posix/ --with-mpfr=$JEHANNE/posix/ && + cp $CROSS_DIR/patch/MakeNothing.in doc/Makefile.in && + make && + make DESTDIR=$JEHANNE/pkgs/libmpc/1.1.0/ install && + libtool --mode=finish $JEHANNE/posix/lib +) >> $LOG 2>&1 +failOnError $? "Building libmpc" +echo done. + +# Copy to /posix (to emulate bind during cross compilation) +cp -pfr $JEHANNE/pkgs/libmpc/1.1.0/posix/* $JEHANNE/posix +rm $JEHANNE/posix/lib/*.la + +echo -n Building binutils... | tee -a $LOG + + +# Patch and build binutils +if [ "$BINUTILS_BUILD_DIR" = "" ]; then + export BINUTILS_BUILD_DIR=$WORKING_DIR/build/binutils-native +fi +if [ ! -d $BINUTILS_BUILD_DIR ]; then + mkdir $BINUTILS_BUILD_DIR +fi +( + 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 && + 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 && + cp $CROSS_DIR/patch/MakeNothing.in $WORKING_DIR/src/binutils/binutils/doc/Makefile.in && + make && + make DESTDIR=$JEHANNE/pkgs/binutils/2.33.1/ install +) >> $LOG 2>&1 +failOnError $? "Building binutils" + +echo done. + +# Copy to /posix (to emulate bind during cross compilation) +cp -pfr $JEHANNE/pkgs/binutils/2.33.1/posix/* $JEHANNE/posix +rm $JEHANNE/posix/lib/*.la + +echo -n Building gcc... | tee -a $LOG +# Patch and build gcc +if [ "$GCC_BUILD_DIR" = "" ]; then + export GCC_BUILD_DIR=$WORKING_DIR/build/gcc-native +fi +if [ ! -d $GCC_BUILD_DIR ]; then + mkdir $GCC_BUILD_DIR +fi +( + 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 && + make all-gcc all-target-libgcc && + make DESTDIR=$JEHANNE/pkgs/gcc/9.2.0/ install-gcc install-target-libgcc +) >> $LOG 2>&1 +failOnError $? "building gcc" + +cp -pfr $JEHANNE/pkgs/gcc/9.2.0/posix/* $JEHANNE/posix + +# +## add sh +#ln -sf /bin/bash $JEHANNE/hacking/cross/toolchain/bin/x86_64-jehanne-sh + +echo "done." diff --git a/cross/wrappers/x86_64-jehanne-g++ b/cross/wrappers/x86_64-jehanne-g++ new file mode 100755 index 0000000..bfec936 --- /dev/null +++ b/cross/wrappers/x86_64-jehanne-g++ @@ -0,0 +1,27 @@ +#!/bin/sh + +ARGS="$@" + +REPONAME=`basename $JEHANNE` +WORKING_DIR=`dirname $JEHANNE` +WORKING_DIR="$WORKING_DIR/$REPONAME.TOOLCHAIN" + +if [ -z "$WRAPPER_LOG" ]; then + WRAPPER_LOG="$JEHANNE/hacking/cross/pkgs/gcc/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" + 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 +exec $WORKING_DIR/cross/posix/bin/x86_64-jehanne-g++ "$@" $TOINCLUDE $TOLINK +else + date --rfc-3339="ns" >> $WRAPPER_LOG + export >> $WRAPPER_LOG +echo $WORKING_DIR/cross/posix/bin/x86_64-jehanne-g++ "$@" >> $WRAPPER_LOG +exec $WORKING_DIR/cross/posix/bin/x86_64-jehanne-g++ "$@" +fi diff --git a/cross/wrappers/x86_64-jehanne-gcc b/cross/wrappers/x86_64-jehanne-gcc new file mode 100755 index 0000000..bcc09b7 --- /dev/null +++ b/cross/wrappers/x86_64-jehanne-gcc @@ -0,0 +1,27 @@ +#!/bin/sh + +ARGS="$@" + +REPONAME=`basename $JEHANNE` +WORKING_DIR=`dirname $JEHANNE` +WORKING_DIR="$WORKING_DIR/$REPONAME.TOOLCHAIN" + +if [ -z "$WRAPPER_LOG" ]; then + WRAPPER_LOG="$WORKING_DIR/wrappers.log" +fi +echo >> $WRAPPER_LOG +echo >> $WRAPPER_LOG + +if echo $ARGS|grep -e '\.c\b' -e '\b\-o\b' -e ' -o ' > /dev/null; then + TOINCLUDE="-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" + date --rfc-3339="ns" |tee -a $WRAPPER_LOG + export >> $WRAPPER_LOG +echo $WORKING_DIR/cross/posix/bin/x86_64-jehanne-gcc "$@" $TOINCLUDE $TOLINK >> $WRAPPER_LOG +exec $WORKING_DIR/cross/posix/bin/x86_64-jehanne-gcc "$@" $TOINCLUDE $TOLINK +else + date --rfc-3339="ns" >> $WRAPPER_LOG + export >> $WRAPPER_LOG +echo $WORKING_DIR/cross/posix/bin/x86_64-jehanne-gcc "$@" >> $WRAPPER_LOG +exec $WORKING_DIR/cross/posix/bin/x86_64-jehanne-gcc "$@" +fi diff --git a/cross/wrappers/x86_64-jehanne-ld b/cross/wrappers/x86_64-jehanne-ld new file mode 100755 index 0000000..d468d60 --- /dev/null +++ b/cross/wrappers/x86_64-jehanne-ld @@ -0,0 +1,26 @@ +#!/bin/sh + +ARGS="$@" + +REPONAME=`basename $JEHANNE` +WORKING_DIR=`dirname $JEHANNE` +WORKING_DIR="$WORKING_DIR/$REPONAME.TOOLCHAIN" + +if [ -z "$WRAPPER_LOG" ]; then + WRAPPER_LOG="$WORKING_DIR/wrappers.log" +fi +echo >> $WRAPPER_LOG +echo >> $WRAPPER_LOG + +if echo $ARGS|grep -e '\b\-o\b' -e ' -o ' > /dev/null; then + TOLINK="-L$JEHANNE/posix/lib -L$JEHANNE/arch/amd64/lib -lnewlibc -lposix -lc" + date --rfc-3339="ns" |tee -a $WRAPPER_LOG + export >> $WRAPPER_LOG +echo $WORKING_DIR/cross/posix/bin/x86_64-jehanne-ld "$@" $TOLINK >> $WRAPPER_LOG +exec $WORKING_DIR/cross/posix/bin/x86_64-jehanne-ld "$@" $TOLINK +else + date --rfc-3339="ns" >> $WRAPPER_LOG + export >> $WRAPPER_LOG +echo $WORKING_DIR/cross/posix/bin/x86_64-jehanne-ld "$@" >> $WRAPPER_LOG +exec $WORKING_DIR/cross/posix/bin/x86_64-jehanne-ld "$@" +fi From 629d1eef1c8e5b57e56f9be8ff2a343e3d1029f2 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Sun, 15 Dec 2019 23:35:01 +0100 Subject: [PATCH 48/91] gcc cross: configure --without-isl and --disable-nls --- cross/init.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cross/init.sh b/cross/init.sh index d4f9cc0..0b392ab 100755 --- a/cross/init.sh +++ b/cross/init.sh @@ -116,7 +116,7 @@ mkdir -p $GCC_BUILD_DIR ( cd gcc && ./contrib/download_prerequisites ) && ( cd gcc/libstdc++-v3 && autoconf -i ) && cd $GCC_BUILD_DIR && - $WORKING_DIR/src/gcc/configure --target=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE --enable-languages=c,c++ && + $WORKING_DIR/src/gcc/configure --target=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE --enable-languages=c,c++ --without-isl --disable-nls && make all-gcc all-target-libgcc && make DESTDIR=$WORKING_DIR/cross install-gcc install-target-libgcc ) >> $LOG 2>&1 From 66ea00e2632585371af89eb8f8aeba972cf109bc Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Sun, 15 Dec 2019 23:39:06 +0100 Subject: [PATCH 49/91] gcc native: first successful compilation (with a few trick) --- cross/native.sh | 20 +++++++++++++------- cross/wrappers/x86_64-jehanne-g++ | 6 +++--- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/cross/native.sh b/cross/native.sh index e769f1c..caa2c0f 100755 --- a/cross/native.sh +++ b/cross/native.sh @@ -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 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 diff --git a/cross/wrappers/x86_64-jehanne-g++ b/cross/wrappers/x86_64-jehanne-g++ index bfec936..5c408e8 100755 --- a/cross/wrappers/x86_64-jehanne-g++ +++ b/cross/wrappers/x86_64-jehanne-g++ @@ -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 From 200961ec7c8f92acb6f3104a0cd6bb22108f472a Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Mon, 16 Dec 2019 00:15:12 +0100 Subject: [PATCH 50/91] newlib: add -I to reach cross GCC's stddef.h; do not rename libm.a and libg.a --- cross/pkgs/newlib/build.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cross/pkgs/newlib/build.sh b/cross/pkgs/newlib/build.sh index f204496..75b1bbd 100755 --- a/cross/pkgs/newlib/build.sh +++ b/cross/pkgs/newlib/build.sh @@ -68,8 +68,7 @@ if [ "$NEWLIB_OPTIMIZATION" = "" ]; then fi export CC=gcc - -export CFLAGS_FOR_TARGET="-g -gdwarf-2 -ggdb -O$NEWLIB_OPTIMIZATION -std=gnu11 -Lposix" +export CFLAGS_FOR_TARGET="-g -gdwarf-2 -ggdb -O$NEWLIB_OPTIMIZATION -std=gnu11 -I$JEHANNE_TOOLCHAIN/cross/posix/lib/gcc/x86_64-jehanne/9.2.0/include -Lposix" ( rm -fr $NEWLIB_BUILD && @@ -78,7 +77,8 @@ export CFLAGS_FOR_TARGET="-g -gdwarf-2 -ggdb -O$NEWLIB_OPTIMIZATION -std=gnu11 - mkdir $NEWLIB_PREFIX && cd $NEWLIB_BUILD && $NEWLIB_SRC/configure --enable-newlib-mb --disable-newlib-fvwrite-in-streamio --prefix=/pkgs/newlib --target=x86_64-jehanne && - make all && make DESTDIR=$NEWLIB_PREFIX install && + make all && + make DESTDIR=$NEWLIB_PREFIX install && rm -fr $JEHANNE/sys/posix/newlib && rm -fr $JEHANNE/arch/amd64/lib/newlib && cp -fr $NEWLIB_PREFIX/pkgs/newlib/ $JEHANNE/pkgs/ && @@ -92,8 +92,6 @@ cp -fr $JEHANNE/pkgs/newlib/x86_64-jehanne/* $JEHANNE/posix # rename libc to libnewlibc to avoid name clash with Jehanne's libc mv $JEHANNE/posix/lib/libc.a $JEHANNE/posix/lib/libnewlibc.a -mv $JEHANNE/posix/lib/libm.a $JEHANNE/posix/lib/libnewlibm.a -mv $JEHANNE/posix/lib/libg.a $JEHANNE/posix/lib/libnewlibg.a kill $dotter From ba1541c35933030ce20354efbe7d4ce1f369f6b9 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Mon, 16 Dec 2019 01:02:15 +0100 Subject: [PATCH 51/91] gcc: remove APW from config/jehanne.h; adjust init.sh to include it on make --- cross/init.sh | 14 +++++++------- cross/patch/gcc/gcc/config/jehanne.h | 16 ++-------------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/cross/init.sh b/cross/init.sh index 0b392ab..fed3edf 100755 --- a/cross/init.sh +++ b/cross/init.sh @@ -116,15 +116,15 @@ mkdir -p $GCC_BUILD_DIR ( cd gcc && ./contrib/download_prerequisites ) && ( cd gcc/libstdc++-v3 && autoconf -i ) && cd $GCC_BUILD_DIR && - $WORKING_DIR/src/gcc/configure --target=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE --enable-languages=c,c++ --without-isl --disable-nls && - make all-gcc all-target-libgcc && + $WORKING_DIR/src/gcc/configure --target=x86_64-jehanne --prefix=/posix --with-sysroot=$JEHANNE --enable-languages=c,c++ --without-isl --disable-nls && + make CFLAGS_FOR_TARGET="-I$JEHANNE/sys/include/apw" all-gcc all-target-libgcc && make DESTDIR=$WORKING_DIR/cross install-gcc install-target-libgcc ) >> $LOG 2>&1 failOnError $? "building gcc" echo done. -echo -n Copying GCC includes into $JEHANNE/posix... -mkdir -p $JEHANNE/posix/lib -cp -fpr $WORKING_DIR/cross/posix/lib/* $JEHANNE/posix/lib -cp -fpr $WORKING_DIR/cross/posix/lib/gcc/x86_64-jehanne/9.2.0/include-fixed/* $JEHANNE/posix/lib/gcc/x86_64-jehanne/9.2.0/include/ -echo done. +## TODO: get a sense of this... shouldn't we do this after GCC compilation? +#echo -n Copying GCC includes into $JEHANNE/posix... +#mkdir -p $JEHANNE/posix/lib +#cp -fpr $WORKING_DIR/cross/posix/lib/* $JEHANNE/posix/lib +#echo done. diff --git a/cross/patch/gcc/gcc/config/jehanne.h b/cross/patch/gcc/gcc/config/jehanne.h index 49162ac..245351b 100644 --- a/cross/patch/gcc/gcc/config/jehanne.h +++ b/cross/patch/gcc/gcc/config/jehanne.h @@ -1,7 +1,7 @@ /* * This file is part of Jehanne. * - * Copyright (C) 2016-2019 Giacomo Tesio + * Copyright (C) 2016-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 @@ -28,28 +28,16 @@ #undef MD_STARTFILE_PREFIX #define MD_STARTFILE_PREFIX "/arch/amd64/lib/" -/* -#undef GPLUSPLUS_INCLUDE_DIR -#define GPLUSPLUS_INCLUDE_DIR "/posix/g++" -#undef GCC_INCLUDE_DIR -#define GCC_INCLUDE_DIR "/posix/gcc" -*/ /* Architecture specific header (u.h) goes here (from config.gcc) */ #define ARCH_INCLUDE_DIR NATIVE_SYSTEM_HEADER_DIR -/* The default include dir is /sys/include but... */ +/* The default include dir is /sys/include */ #define PORTABLE_INCLUDE_DIR "/sys/include" -/* ...we have to wrap libc.h and stdio.h with basic POSIX headers */ -#define BASIC_POSIX_INCLUDE_DIR "/sys/include/apw" - #undef INCLUDE_DEFAULTS #define INCLUDE_DEFAULTS \ { \ - { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, 1, 0 }, \ - { GCC_INCLUDE_DIR, "GCC", 0, 0, 1, 0 }, \ - { BASIC_POSIX_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ { PORTABLE_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ { ARCH_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ { 0, 0, 0, 0, 0, 0 } \ From 7dc9bd0671ea6e50d8a7c9a82ede0b9d94f40082 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Mon, 16 Dec 2019 01:21:36 +0100 Subject: [PATCH 52/91] devshell.sh: export JEHANNE_TOOLCHAIN --- devshell.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devshell.sh b/devshell.sh index a1d1140..4dc54fa 100755 --- a/devshell.sh +++ b/devshell.sh @@ -8,7 +8,7 @@ export JEHANNE=`git rev-parse --show-toplevel` REPONAME=`basename $JEHANNE` JEHANNE_TOOLCHAIN=`dirname $JEHANNE` JEHANNE_TOOLCHAIN="$JEHANNE_TOOLCHAIN/$REPONAME.TOOLCHAIN" - +export JEHANNE_TOOLCHAIN export PATH="$JEHANNE/hacking/bin:$PATH" export PATH="$JEHANNE_TOOLCHAIN/cross/posix/bin:$PATH" From f61a6114e7a7184a8fb3459b70492eb5999bb588 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Mon, 16 Dec 2019 01:40:41 +0100 Subject: [PATCH 53/91] gcc native: update includes --- cross/wrappers/x86_64-jehanne-g++ | 2 +- cross/wrappers/x86_64-jehanne-gcc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cross/wrappers/x86_64-jehanne-g++ b/cross/wrappers/x86_64-jehanne-g++ index 5c408e8..e933e47 100755 --- a/cross/wrappers/x86_64-jehanne-g++ +++ b/cross/wrappers/x86_64-jehanne-g++ @@ -13,7 +13,7 @@ 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 -I$JEHANNE/arch/amd64/include" + 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 -IJEHANNE/posix/x86_64-jehanne/include/c++/9.2.0/backward/ -I$JEHANNE/posix/lib/gcc/x86_64-jehanne/9.2.0/include -I$JEHANNE/posix/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 diff --git a/cross/wrappers/x86_64-jehanne-gcc b/cross/wrappers/x86_64-jehanne-gcc index bcc09b7..938d14f 100755 --- a/cross/wrappers/x86_64-jehanne-gcc +++ b/cross/wrappers/x86_64-jehanne-gcc @@ -13,7 +13,7 @@ echo >> $WRAPPER_LOG echo >> $WRAPPER_LOG if echo $ARGS|grep -e '\.c\b' -e '\b\-o\b' -e ' -o ' > /dev/null; then - TOINCLUDE="-I$JEHANNE/posix/include -I$JEHANNE/sys/include/apw -I$JEHANNE/sys/include -I$JEHANNE/arch/amd64/include" + TOINCLUDE="-I$JEHANNE/posix/include" TOLINK="-L$JEHANNE/posix/lib -L$JEHANNE/arch/amd64/lib -lnewlibc -lposix -lc" date --rfc-3339="ns" |tee -a $WRAPPER_LOG export >> $WRAPPER_LOG From a96022f9bd5149d68cbe937bd92b80c5c4e0187f Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Mon, 16 Dec 2019 00:25:24 +0100 Subject: [PATCH 54/91] wrappers/x86_64-jehanne-gcc: fix includes --- cross/wrappers/x86_64-jehanne-gcc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cross/wrappers/x86_64-jehanne-gcc b/cross/wrappers/x86_64-jehanne-gcc index 938d14f..73fa14e 100755 --- a/cross/wrappers/x86_64-jehanne-gcc +++ b/cross/wrappers/x86_64-jehanne-gcc @@ -13,7 +13,7 @@ echo >> $WRAPPER_LOG echo >> $WRAPPER_LOG if echo $ARGS|grep -e '\.c\b' -e '\b\-o\b' -e ' -o ' > /dev/null; then - TOINCLUDE="-I$JEHANNE/posix/include" + TOINCLUDE="-I$JEHANNE/posix/lib/gcc/x86_64-jehanne/9.2.0/include -I$JEHANNE/posix/include" TOLINK="-L$JEHANNE/posix/lib -L$JEHANNE/arch/amd64/lib -lnewlibc -lposix -lc" date --rfc-3339="ns" |tee -a $WRAPPER_LOG export >> $WRAPPER_LOG From 38eaa1ad99e07ec50df40bb2e59a8c22d27920ab Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Tue, 17 Dec 2019 00:20:04 +0100 Subject: [PATCH 55/91] gcc native: cleanup wrappers --- cross/wrappers/x86_64-jehanne-g++ | 4 ++-- cross/wrappers/x86_64-jehanne-gcc | 4 ++-- cross/wrappers/x86_64-jehanne-ld | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cross/wrappers/x86_64-jehanne-g++ b/cross/wrappers/x86_64-jehanne-g++ index e933e47..83101e1 100755 --- a/cross/wrappers/x86_64-jehanne-g++ +++ b/cross/wrappers/x86_64-jehanne-g++ @@ -13,8 +13,8 @@ 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 -IJEHANNE/posix/x86_64-jehanne/include/c++/9.2.0/backward/ -I$JEHANNE/posix/lib/gcc/x86_64-jehanne/9.2.0/include -I$JEHANNE/posix/include" - TOLINK="-L$JEHANNE/posix/lib -L$JEHANNE/arch/amd64/lib -lstdc++ -lm -lnewlibc -lposix -lc" + TOINCLUDE="-isystem$JEHANNE/posix/x86_64-jehanne/include/c++/9.2.0/ -isystem$JEHANNE/posix/x86_64-jehanne/include/c++/9.2.0/x86_64-jehanne -isystem$JEHANNE/posix/x86_64-jehanne/include/c++/9.2.0/backward -isystem$JEHANNE/posix/lib/gcc/x86_64-jehanne/9.2.0/include -isystem$JEHANNE/posix/include" + TOLINK="-L$JEHANNE/posix/lib -lstdc++ -lm -lnewlibc -lposix" 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 diff --git a/cross/wrappers/x86_64-jehanne-gcc b/cross/wrappers/x86_64-jehanne-gcc index 73fa14e..f00117f 100755 --- a/cross/wrappers/x86_64-jehanne-gcc +++ b/cross/wrappers/x86_64-jehanne-gcc @@ -13,8 +13,8 @@ echo >> $WRAPPER_LOG echo >> $WRAPPER_LOG if echo $ARGS|grep -e '\.c\b' -e '\b\-o\b' -e ' -o ' > /dev/null; then - TOINCLUDE="-I$JEHANNE/posix/lib/gcc/x86_64-jehanne/9.2.0/include -I$JEHANNE/posix/include" - TOLINK="-L$JEHANNE/posix/lib -L$JEHANNE/arch/amd64/lib -lnewlibc -lposix -lc" + TOINCLUDE="-isystem$JEHANNE/posix/lib/gcc/x86_64-jehanne/9.2.0/include -isystem$JEHANNE/posix/include" + TOLINK="-L$JEHANNE/posix/lib -lnewlibc -lposix" date --rfc-3339="ns" |tee -a $WRAPPER_LOG export >> $WRAPPER_LOG echo $WORKING_DIR/cross/posix/bin/x86_64-jehanne-gcc "$@" $TOINCLUDE $TOLINK >> $WRAPPER_LOG diff --git a/cross/wrappers/x86_64-jehanne-ld b/cross/wrappers/x86_64-jehanne-ld index d468d60..b2afe80 100755 --- a/cross/wrappers/x86_64-jehanne-ld +++ b/cross/wrappers/x86_64-jehanne-ld @@ -13,7 +13,7 @@ echo >> $WRAPPER_LOG echo >> $WRAPPER_LOG if echo $ARGS|grep -e '\b\-o\b' -e ' -o ' > /dev/null; then - TOLINK="-L$JEHANNE/posix/lib -L$JEHANNE/arch/amd64/lib -lnewlibc -lposix -lc" + TOLINK="-L$JEHANNE/posix/lib -lnewlibc -lposix -lc" date --rfc-3339="ns" |tee -a $WRAPPER_LOG export >> $WRAPPER_LOG echo $WORKING_DIR/cross/posix/bin/x86_64-jehanne-ld "$@" $TOLINK >> $WRAPPER_LOG From 4102d630586b4c4a5219f42d8e2b6eed6a38e8fe Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Tue, 17 Dec 2019 00:32:01 +0100 Subject: [PATCH 56/91] gcc native: no --with-newlib; no CFLAGS_FOR_TAGET; cleanup --- cross/native.sh | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/cross/native.sh b/cross/native.sh index caa2c0f..dcbf7ca 100755 --- a/cross/native.sh +++ b/cross/native.sh @@ -66,7 +66,7 @@ mkdir -p $GCC_BUILD_DIR 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 && make DESTDIR=$JEHANNE/pkgs/libstdc++-v3/9.2.0/ install ) >> $LOG 2>&1 failOnError $? "building libstdc++-v3" @@ -147,7 +147,7 @@ fi 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 && cp $CROSS_DIR/patch/MakeNothing.in $WORKING_DIR/src/binutils/binutils/doc/Makefile.in && - make && + make && make DESTDIR=$JEHANNE/pkgs/binutils/2.33.1/ install ) >> $LOG 2>&1 failOnError $? "Building binutils" @@ -167,10 +167,8 @@ 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-shared --disable-threads --disable-tls --disable-bootstrap --disable-libgomp --disable-werror --disable-nls && + $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 all-target-libgcc && make DESTDIR=$JEHANNE/pkgs/gcc/9.2.0/ install-gcc install-target-libgcc ) >> $LOG 2>&1 @@ -178,11 +176,6 @@ failOnError $? "building gcc" cp -pfr $JEHANNE/pkgs/gcc/9.2.0/posix/* $JEHANNE/posix -# NOTES work in progress -# in cstdlib replaced #include_next 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 From e7860adc5bfd1363bcbdc8ff700549d02f05415f Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Tue, 17 Dec 2019 23:56:55 +0100 Subject: [PATCH 57/91] gcc native: cleanup to native.sh script --- cross/native.sh | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/cross/native.sh b/cross/native.sh index dcbf7ca..1975269 100755 --- a/cross/native.sh +++ b/cross/native.sh @@ -2,9 +2,7 @@ echo "Cross compiling GCC and dependencies" -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/native.build.log" @@ -46,9 +44,9 @@ failOnError $? "fetching sources" echo -n Building libstdc++-v3... | tee -a $LOG # libstdc++-v3 is part of GCC but must be built after newlib. -export GCC_BUILD_DIR=$WORKING_DIR/build/gcc -mkdir -p $GCC_BUILD_DIR ( + export GCC_BUILD_DIR=$WORKING_DIR/build/gcc && + mkdir -p $GCC_BUILD_DIR && rm -fr $WORKING_DIR/src/gcc/isl-0.18.tar.bz2 && rm -fr $WORKING_DIR/src/gcc/isl-0.18 && rm -fr $WORKING_DIR/src/gcc/isl && @@ -160,13 +158,9 @@ rm $JEHANNE/posix/lib/*.la echo -n Building gcc... | tee -a $LOG # Patch and build gcc -if [ "$GCC_BUILD_DIR" = "" ]; then - export GCC_BUILD_DIR=$WORKING_DIR/build/gcc-native -fi -if [ ! -d $GCC_BUILD_DIR ]; then - mkdir $GCC_BUILD_DIR -fi ( + 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 all-target-libgcc && From 905f03e6aec9d660ddb6368107b09449586c2b8b Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Wed, 18 Dec 2019 00:07:50 +0100 Subject: [PATCH 58/91] gcc native: separate gcc and libgcc compilation --- cross/native.sh | 261 ++++++++++++++++++++++++------------------------ 1 file changed, 133 insertions(+), 128 deletions(-) diff --git a/cross/native.sh b/cross/native.sh index 1975269..42f8cb5 100755 --- a/cross/native.sh +++ b/cross/native.sh @@ -29,132 +29,132 @@ function failOnError { date > $LOG -# mock makeinfo (to avoid it as a dependency) -rm -f $JEHANNE/hacking/bin/makeinfo -ln -s `which echo` $JEHANNE/hacking/bin/makeinfo - -# verify libtool is installed -libtool --version >> /dev/null -failOnError $? "libtool installation check" - -(cd $WORKING_DIR/src && fetch) >> $LOG -failOnError $? "fetching sources" - - - -echo -n Building libstdc++-v3... | tee -a $LOG -# libstdc++-v3 is part of GCC but must be built after newlib. -( - export GCC_BUILD_DIR=$WORKING_DIR/build/gcc && - mkdir -p $GCC_BUILD_DIR && - rm -fr $WORKING_DIR/src/gcc/isl-0.18.tar.bz2 && - rm -fr $WORKING_DIR/src/gcc/isl-0.18 && - rm -fr $WORKING_DIR/src/gcc/isl && - rm -fr $WORKING_DIR/src/gcc/gmp-6.1.0.tar.bz2 && - rm -fr $WORKING_DIR/src/gcc/gmp-6.1.0 && - rm -fr $WORKING_DIR/src/gcc/gmp && - rm -fr $WORKING_DIR/src/gcc/mpfr-3.1.4.tar.bz2 && - rm -fr $WORKING_DIR/src/gcc/mpfr-3.1.4 && - rm -fr $WORKING_DIR/src/gcc/mpfr && - rm -fr $WORKING_DIR/src/gcc/mpc-1.0.3.tar.gz && - rm -fr $WORKING_DIR/src/gcc/mpc-1.0.3 && - rm -fr $WORKING_DIR/src/gcc/mpc && - cd $GCC_BUILD_DIR && - 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 -failOnError $? "building libstdc++-v3" -echo done. - -# Copy to /posix (to emulate bind during cross compilation) -cp -pfr $JEHANNE/pkgs/libstdc++-v3/9.2.0/posix/* $JEHANNE/posix -find $JEHANNE/posix/|grep '\.la$'|xargs rm - -echo -n Building libgmp... | tee -a $LOG -( - cd $WORKING_DIR/src/libgmp && - ( grep -q jehanne configfsf.sub || patch -p0 < $CROSS_DIR/patch/libgmp.patch ) && - ./configure --host=x86_64-jehanne --disable-shared --prefix=/posix --with-sysroot=$JEHANNE && - make && - make DESTDIR=$JEHANNE/pkgs/libgmp/6.1.2/ install && - libtool --mode=finish $JEHANNE/posix/lib -) >> $LOG 2>&1 -failOnError $? "Building libgmp" -echo done. - -# Copy to /posix (to emulate bind during cross compilation) -cp -pfr $JEHANNE/pkgs/libgmp/6.1.2/posix/* $JEHANNE/posix -rm $JEHANNE/posix/lib/*.la - -echo -n Building libmpfr... | tee -a $LOG -( - cd $WORKING_DIR/src/libmpfr && - ( grep -q jehanne config.sub || patch -p0 < $CROSS_DIR/patch/libmpfr.patch ) && - ./configure --host=x86_64-jehanne --disable-shared --prefix=/posix --with-sysroot=$JEHANNE --with-gmp=$JEHANNE/posix/ && - cp $CROSS_DIR/patch/MakeNothing.in doc/Makefile.in && - make && - make DESTDIR=$JEHANNE/pkgs/libmpfr/4.0.1/ install && - libtool --mode=finish $JEHANNE/posix/lib -) >> $LOG 2>&1 -failOnError $? "Building libmpfr" -echo done. - -# Copy to /posix (to emulate bind during cross compilation) -cp -pfr $JEHANNE/pkgs/libmpfr/4.0.1/posix/* $JEHANNE/posix -rm $JEHANNE/posix/lib/*.la - -echo -n Building libmpc... | tee -a $LOG -( - cd $WORKING_DIR/src/libmpc && - ( grep -q jehanne config.sub || ( chmod u+w config.sub && - patch -p0 < $CROSS_DIR/patch/libmpc.patch && - chmod u-w config.sub ) ) && - ./configure --host=x86_64-jehanne --disable-shared --prefix=/posix --with-sysroot=$JEHANNE --with-gmp=$JEHANNE/posix/ --with-mpfr=$JEHANNE/posix/ && - cp $CROSS_DIR/patch/MakeNothing.in doc/Makefile.in && - make && - make DESTDIR=$JEHANNE/pkgs/libmpc/1.1.0/ install && - libtool --mode=finish $JEHANNE/posix/lib -) >> $LOG 2>&1 -failOnError $? "Building libmpc" -echo done. - -# Copy to /posix (to emulate bind during cross compilation) -cp -pfr $JEHANNE/pkgs/libmpc/1.1.0/posix/* $JEHANNE/posix -rm $JEHANNE/posix/lib/*.la - -echo -n Building binutils... | tee -a $LOG - - -# Patch and build binutils -if [ "$BINUTILS_BUILD_DIR" = "" ]; then - export BINUTILS_BUILD_DIR=$WORKING_DIR/build/binutils-native -fi -if [ ! -d $BINUTILS_BUILD_DIR ]; then - mkdir $BINUTILS_BUILD_DIR -fi -( - 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 && - 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 && - cp $CROSS_DIR/patch/MakeNothing.in $WORKING_DIR/src/binutils/binutils/doc/Makefile.in && - make && - make DESTDIR=$JEHANNE/pkgs/binutils/2.33.1/ install -) >> $LOG 2>&1 -failOnError $? "Building binutils" - -echo done. - -# Copy to /posix (to emulate bind during cross compilation) -cp -pfr $JEHANNE/pkgs/binutils/2.33.1/posix/* $JEHANNE/posix -rm $JEHANNE/posix/lib/*.la +## mock makeinfo (to avoid it as a dependency) +#rm -f $JEHANNE/hacking/bin/makeinfo +#ln -s `which echo` $JEHANNE/hacking/bin/makeinfo +# +## verify libtool is installed +#libtool --version >> /dev/null +#failOnError $? "libtool installation check" +# +#(cd $WORKING_DIR/src && fetch) >> $LOG +#failOnError $? "fetching sources" +# +# +# +#echo -n Building libstdc++-v3... | tee -a $LOG +## libstdc++-v3 is part of GCC but must be built after newlib. +#( +# export GCC_BUILD_DIR=$WORKING_DIR/build/gcc && +# mkdir -p $GCC_BUILD_DIR && +# rm -fr $WORKING_DIR/src/gcc/isl-0.18.tar.bz2 && +# rm -fr $WORKING_DIR/src/gcc/isl-0.18 && +# rm -fr $WORKING_DIR/src/gcc/isl && +# rm -fr $WORKING_DIR/src/gcc/gmp-6.1.0.tar.bz2 && +# rm -fr $WORKING_DIR/src/gcc/gmp-6.1.0 && +# rm -fr $WORKING_DIR/src/gcc/gmp && +# rm -fr $WORKING_DIR/src/gcc/mpfr-3.1.4.tar.bz2 && +# rm -fr $WORKING_DIR/src/gcc/mpfr-3.1.4 && +# rm -fr $WORKING_DIR/src/gcc/mpfr && +# rm -fr $WORKING_DIR/src/gcc/mpc-1.0.3.tar.gz && +# rm -fr $WORKING_DIR/src/gcc/mpc-1.0.3 && +# rm -fr $WORKING_DIR/src/gcc/mpc && +# cd $GCC_BUILD_DIR && +# 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 +#failOnError $? "building libstdc++-v3" +#echo done. +# +## Copy to /posix (to emulate bind during cross compilation) +#cp -pfr $JEHANNE/pkgs/libstdc++-v3/9.2.0/posix/* $JEHANNE/posix +#find $JEHANNE/posix/|grep '\.la$'|xargs rm +# +#echo -n Building libgmp... | tee -a $LOG +#( +# cd $WORKING_DIR/src/libgmp && +# ( grep -q jehanne configfsf.sub || patch -p0 < $CROSS_DIR/patch/libgmp.patch ) && +# ./configure --host=x86_64-jehanne --disable-shared --prefix=/posix --with-sysroot=$JEHANNE && +# make && +# make DESTDIR=$JEHANNE/pkgs/libgmp/6.1.2/ install && +# libtool --mode=finish $JEHANNE/posix/lib +#) >> $LOG 2>&1 +#failOnError $? "Building libgmp" +#echo done. +# +## Copy to /posix (to emulate bind during cross compilation) +#cp -pfr $JEHANNE/pkgs/libgmp/6.1.2/posix/* $JEHANNE/posix +#rm $JEHANNE/posix/lib/*.la +# +#echo -n Building libmpfr... | tee -a $LOG +#( +# cd $WORKING_DIR/src/libmpfr && +# ( grep -q jehanne config.sub || patch -p0 < $CROSS_DIR/patch/libmpfr.patch ) && +# ./configure --host=x86_64-jehanne --disable-shared --prefix=/posix --with-sysroot=$JEHANNE --with-gmp=$JEHANNE/posix/ && +# cp $CROSS_DIR/patch/MakeNothing.in doc/Makefile.in && +# make && +# make DESTDIR=$JEHANNE/pkgs/libmpfr/4.0.1/ install && +# libtool --mode=finish $JEHANNE/posix/lib +#) >> $LOG 2>&1 +#failOnError $? "Building libmpfr" +#echo done. +# +## Copy to /posix (to emulate bind during cross compilation) +#cp -pfr $JEHANNE/pkgs/libmpfr/4.0.1/posix/* $JEHANNE/posix +#rm $JEHANNE/posix/lib/*.la +# +#echo -n Building libmpc... | tee -a $LOG +#( +# cd $WORKING_DIR/src/libmpc && +# ( grep -q jehanne config.sub || ( chmod u+w config.sub && +# patch -p0 < $CROSS_DIR/patch/libmpc.patch && +# chmod u-w config.sub ) ) && +# ./configure --host=x86_64-jehanne --disable-shared --prefix=/posix --with-sysroot=$JEHANNE --with-gmp=$JEHANNE/posix/ --with-mpfr=$JEHANNE/posix/ && +# cp $CROSS_DIR/patch/MakeNothing.in doc/Makefile.in && +# make && +# make DESTDIR=$JEHANNE/pkgs/libmpc/1.1.0/ install && +# libtool --mode=finish $JEHANNE/posix/lib +#) >> $LOG 2>&1 +#failOnError $? "Building libmpc" +#echo done. +# +## Copy to /posix (to emulate bind during cross compilation) +#cp -pfr $JEHANNE/pkgs/libmpc/1.1.0/posix/* $JEHANNE/posix +#rm $JEHANNE/posix/lib/*.la +# +#echo -n Building binutils... | tee -a $LOG +# +# +## Patch and build binutils +#if [ "$BINUTILS_BUILD_DIR" = "" ]; then +# export BINUTILS_BUILD_DIR=$WORKING_DIR/build/binutils-native +#fi +#if [ ! -d $BINUTILS_BUILD_DIR ]; then +# mkdir $BINUTILS_BUILD_DIR +#fi +#( +# 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 && +# 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 && +# cp $CROSS_DIR/patch/MakeNothing.in $WORKING_DIR/src/binutils/binutils/doc/Makefile.in && +# make && +# make DESTDIR=$JEHANNE/pkgs/binutils/2.33.1/ install +#) >> $LOG 2>&1 +#failOnError $? "Building binutils" +# +#echo done. +# +## Copy to /posix (to emulate bind during cross compilation) +#cp -pfr $JEHANNE/pkgs/binutils/2.33.1/posix/* $JEHANNE/posix +#rm $JEHANNE/posix/lib/*.la echo -n Building gcc... | tee -a $LOG # Patch and build gcc @@ -163,8 +163,13 @@ echo -n Building gcc... | tee -a $LOG 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 all-target-libgcc && - make DESTDIR=$JEHANNE/pkgs/gcc/9.2.0/ install-gcc install-target-libgcc + 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" From 57cedd378601a466b4a347198a884fb78275aa0b Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Wed, 18 Dec 2019 18:15:17 +0100 Subject: [PATCH 59/91] gcc native: initialize newlib (dedicated environment and SIGCHLD management) --- cross/init.sh | 8 +++---- cross/native.sh | 34 ++++++++++++++++------------ cross/patch/gcc.patch | 10 ++++---- cross/patch/gcc/gcc/config/jehanne.c | 31 +++++++++++++++++++++++++ cross/patch/gcc/gcc/config/t-jehanne | 19 ++++++++++++++++ 5 files changed, 80 insertions(+), 22 deletions(-) create mode 100644 cross/patch/gcc/gcc/config/jehanne.c create mode 100644 cross/patch/gcc/gcc/config/t-jehanne 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) From e600e2c57f6b91a6f66ec348b2352164bb72f50c Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Thu, 19 Dec 2019 00:21:47 +0100 Subject: [PATCH 60/91] gcc native: further corrections --- cross/native.sh | 5 +++-- cross/patch/gcc.patch | 5 ++--- cross/wrappers/x86_64-jehanne-g++ | 2 +- cross/wrappers/x86_64-jehanne-gcc | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cross/native.sh b/cross/native.sh index cffd608..80182d2 100755 --- a/cross/native.sh +++ b/cross/native.sh @@ -162,11 +162,12 @@ echo -n Building gcc... | tee -a $LOG $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 \ + --disable-multiarch --with-multilib-list= \ --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 all-gcc && + make 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 && diff --git a/cross/patch/gcc.patch b/cross/patch/gcc.patch index ee21081..de1f9d8 100644 --- a/cross/patch/gcc.patch +++ b/cross/patch/gcc.patch @@ -2,15 +2,14 @@ diff --git a/src/gcc/gcc/config.gcc b/src/gcc/gcc/config.gcc index ddd3b8f..702aa59 100644 --- a/src/gcc/gcc/config.gcc +++ b/src/gcc/gcc/config.gcc -@@ -947,6 +947,18 @@ case ${target} in +@@ -947,6 +947,17 @@ 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" ++ extra_objs="jehanne.o" + default_use_cxa_atexit=yes + case $target in + x86_64-*) diff --git a/cross/wrappers/x86_64-jehanne-g++ b/cross/wrappers/x86_64-jehanne-g++ index 83101e1..7718e36 100755 --- a/cross/wrappers/x86_64-jehanne-g++ +++ b/cross/wrappers/x86_64-jehanne-g++ @@ -13,7 +13,7 @@ echo >> $WRAPPER_LOG echo >> $WRAPPER_LOG if echo $ARGS|grep -e '\.cpp\b' -e '\b\-o\b' -e ' -o ' > /dev/null; then - TOINCLUDE="-isystem$JEHANNE/posix/x86_64-jehanne/include/c++/9.2.0/ -isystem$JEHANNE/posix/x86_64-jehanne/include/c++/9.2.0/x86_64-jehanne -isystem$JEHANNE/posix/x86_64-jehanne/include/c++/9.2.0/backward -isystem$JEHANNE/posix/lib/gcc/x86_64-jehanne/9.2.0/include -isystem$JEHANNE/posix/include" + TOINCLUDE="-isystem$JEHANNE_TOOLCHAIN/cross/posix/x86_64-jehanne/include/c++/9.2.0/ -isystem$JEHANNE/posix/x86_64-jehanne/include/c++/9.2.0/x86_64-jehanne -isystem$JEHANNE/posix/x86_64-jehanne/include/c++/9.2.0/backward -isystem$JEHANNE/posix/lib/gcc/x86_64-jehanne/9.2.0/include -isystem$JEHANNE/posix/include" TOLINK="-L$JEHANNE/posix/lib -lstdc++ -lm -lnewlibc -lposix" date --rfc-3339="ns" |tee -a $WRAPPER_LOG export >> $WRAPPER_LOG diff --git a/cross/wrappers/x86_64-jehanne-gcc b/cross/wrappers/x86_64-jehanne-gcc index f00117f..c8ec575 100755 --- a/cross/wrappers/x86_64-jehanne-gcc +++ b/cross/wrappers/x86_64-jehanne-gcc @@ -13,7 +13,7 @@ echo >> $WRAPPER_LOG echo >> $WRAPPER_LOG if echo $ARGS|grep -e '\.c\b' -e '\b\-o\b' -e ' -o ' > /dev/null; then - TOINCLUDE="-isystem$JEHANNE/posix/lib/gcc/x86_64-jehanne/9.2.0/include -isystem$JEHANNE/posix/include" + TOINCLUDE="-isystem$JEHANNE_TOOLCHAIN/cross/posix/lib/gcc/x86_64-jehanne/9.2.0/include -isystem$JEHANNE/posix/include" TOLINK="-L$JEHANNE/posix/lib -lnewlibc -lposix" date --rfc-3339="ns" |tee -a $WRAPPER_LOG export >> $WRAPPER_LOG From d0ba1de89048e7ebe364366c585c466d401ae6f0 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Thu, 19 Dec 2019 00:24:37 +0100 Subject: [PATCH 61/91] gcc native: wrapper fix --- cross/wrappers/x86_64-jehanne-g++ | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cross/wrappers/x86_64-jehanne-g++ b/cross/wrappers/x86_64-jehanne-g++ index 7718e36..678f6ca 100755 --- a/cross/wrappers/x86_64-jehanne-g++ +++ b/cross/wrappers/x86_64-jehanne-g++ @@ -13,7 +13,7 @@ echo >> $WRAPPER_LOG echo >> $WRAPPER_LOG if echo $ARGS|grep -e '\.cpp\b' -e '\b\-o\b' -e ' -o ' > /dev/null; then - TOINCLUDE="-isystem$JEHANNE_TOOLCHAIN/cross/posix/x86_64-jehanne/include/c++/9.2.0/ -isystem$JEHANNE/posix/x86_64-jehanne/include/c++/9.2.0/x86_64-jehanne -isystem$JEHANNE/posix/x86_64-jehanne/include/c++/9.2.0/backward -isystem$JEHANNE/posix/lib/gcc/x86_64-jehanne/9.2.0/include -isystem$JEHANNE/posix/include" + TOINCLUDE="-isystem$JEHANNE/posix/x86_64-jehanne/include/c++/9.2.0/ -isystem$JEHANNE/posix/x86_64-jehanne/include/c++/9.2.0/x86_64-jehanne -isystem$JEHANNE/posix/x86_64-jehanne/include/c++/9.2.0/backward -isystem$JEHANNE_TOOLCHAIN/cross/posix/lib/gcc/x86_64-jehanne/9.2.0/include -isystem$JEHANNE/posix/include" TOLINK="-L$JEHANNE/posix/lib -lstdc++ -lm -lnewlibc -lposix" date --rfc-3339="ns" |tee -a $WRAPPER_LOG export >> $WRAPPER_LOG From 5d13eaeed95697b16bafa1b8ed6ec00695fa6b7f Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Thu, 19 Dec 2019 00:11:25 +0100 Subject: [PATCH 62/91] gcc native: separate builds of gcc and libgcc --- cross/native.sh | 292 +++++++++++++++++++++--------------------- cross/patch/gcc.patch | 2 +- 2 files changed, 149 insertions(+), 145 deletions(-) diff --git a/cross/native.sh b/cross/native.sh index 80182d2..f178765 100755 --- a/cross/native.sh +++ b/cross/native.sh @@ -2,9 +2,9 @@ echo "Cross compiling GCC and dependencies" -WORKING_DIR=$JEHANNE_TOOLCHAIN +JEHANNE_TOOLCHAIN=$JEHANNE_TOOLCHAIN CROSS_DIR="$JEHANNE/hacking/cross" -LOG="$WORKING_DIR/native.build.log" +LOG="$JEHANNE_TOOLCHAIN/native.build.log" export LD_PRELOAD= @@ -26,157 +26,161 @@ function failOnError { date > $LOG -## mock makeinfo (to avoid it as a dependency) -#rm -f $JEHANNE/hacking/bin/makeinfo -#ln -s `which echo` $JEHANNE/hacking/bin/makeinfo -# -## verify libtool is installed -#libtool --version >> /dev/null -#failOnError $? "libtool installation check" -# -#(cd $WORKING_DIR/src && fetch) >> $LOG -#failOnError $? "fetching sources" -# -# -# -#echo -n Building libstdc++-v3... | tee -a $LOG -## libstdc++-v3 is part of GCC but must be built after newlib. -#( -# export GCC_BUILD_DIR=$WORKING_DIR/build/gcc && -# mkdir -p $GCC_BUILD_DIR && -# rm -fr $WORKING_DIR/src/gcc/isl-0.18.tar.bz2 && -# rm -fr $WORKING_DIR/src/gcc/isl-0.18 && -# rm -fr $WORKING_DIR/src/gcc/isl && -# rm -fr $WORKING_DIR/src/gcc/gmp-6.1.0.tar.bz2 && -# rm -fr $WORKING_DIR/src/gcc/gmp-6.1.0 && -# rm -fr $WORKING_DIR/src/gcc/gmp && -# rm -fr $WORKING_DIR/src/gcc/mpfr-3.1.4.tar.bz2 && -# rm -fr $WORKING_DIR/src/gcc/mpfr-3.1.4 && -# rm -fr $WORKING_DIR/src/gcc/mpfr && -# rm -fr $WORKING_DIR/src/gcc/mpc-1.0.3.tar.gz && -# rm -fr $WORKING_DIR/src/gcc/mpc-1.0.3 && -# rm -fr $WORKING_DIR/src/gcc/mpc && -# cd $GCC_BUILD_DIR && -# 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 -#failOnError $? "building libstdc++-v3" -#echo done. -# -## Copy to /posix (to emulate bind during cross compilation) -#cp -pfr $JEHANNE/pkgs/libstdc++-v3/9.2.0/posix/* $JEHANNE/posix -#find $JEHANNE/posix/|grep '\.la$'|xargs rm -# -#echo -n Building libgmp... | tee -a $LOG -#( -# cd $WORKING_DIR/src/libgmp && -# ( grep -q jehanne configfsf.sub || patch -p0 < $CROSS_DIR/patch/libgmp.patch ) && -# ./configure --host=x86_64-jehanne --disable-shared --prefix=/posix --with-sysroot=$JEHANNE && -# make && -# make DESTDIR=$JEHANNE/pkgs/libgmp/6.1.2/ install && -# libtool --mode=finish $JEHANNE/posix/lib -#) >> $LOG 2>&1 -#failOnError $? "Building libgmp" -#echo done. -# -## Copy to /posix (to emulate bind during cross compilation) -#cp -pfr $JEHANNE/pkgs/libgmp/6.1.2/posix/* $JEHANNE/posix -#rm $JEHANNE/posix/lib/*.la -# -#echo -n Building libmpfr... | tee -a $LOG -#( -# cd $WORKING_DIR/src/libmpfr && -# ( grep -q jehanne config.sub || patch -p0 < $CROSS_DIR/patch/libmpfr.patch ) && -# ./configure --host=x86_64-jehanne --disable-shared --prefix=/posix --with-sysroot=$JEHANNE --with-gmp=$JEHANNE/posix/ && -# cp $CROSS_DIR/patch/MakeNothing.in doc/Makefile.in && -# make && -# make DESTDIR=$JEHANNE/pkgs/libmpfr/4.0.1/ install && -# libtool --mode=finish $JEHANNE/posix/lib -#) >> $LOG 2>&1 -#failOnError $? "Building libmpfr" -#echo done. -# -## Copy to /posix (to emulate bind during cross compilation) -#cp -pfr $JEHANNE/pkgs/libmpfr/4.0.1/posix/* $JEHANNE/posix -#rm $JEHANNE/posix/lib/*.la -# -#echo -n Building libmpc... | tee -a $LOG -#( -# cd $WORKING_DIR/src/libmpc && -# ( grep -q jehanne config.sub || ( chmod u+w config.sub && -# patch -p0 < $CROSS_DIR/patch/libmpc.patch && -# chmod u-w config.sub ) ) && -# ./configure --host=x86_64-jehanne --disable-shared --prefix=/posix --with-sysroot=$JEHANNE --with-gmp=$JEHANNE/posix/ --with-mpfr=$JEHANNE/posix/ && -# cp $CROSS_DIR/patch/MakeNothing.in doc/Makefile.in && -# make && -# make DESTDIR=$JEHANNE/pkgs/libmpc/1.1.0/ install && -# libtool --mode=finish $JEHANNE/posix/lib -#) >> $LOG 2>&1 -#failOnError $? "Building libmpc" -#echo done. -# -## Copy to /posix (to emulate bind during cross compilation) -#cp -pfr $JEHANNE/pkgs/libmpc/1.1.0/posix/* $JEHANNE/posix -#rm $JEHANNE/posix/lib/*.la -# -#echo -n Building binutils... | tee -a $LOG -# -# -## Patch and build binutils -#if [ "$BINUTILS_BUILD_DIR" = "" ]; then -# export BINUTILS_BUILD_DIR=$WORKING_DIR/build/binutils-native -#fi -#if [ ! -d $BINUTILS_BUILD_DIR ]; then -# mkdir $BINUTILS_BUILD_DIR -#fi -#( -# 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 --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 && -# cp $CROSS_DIR/patch/MakeNothing.in $WORKING_DIR/src/binutils/binutils/doc/Makefile.in && -# make && -# make DESTDIR=$JEHANNE/pkgs/binutils/2.33.1/ install -#) >> $LOG 2>&1 -#failOnError $? "Building binutils" -# -#echo done. -# -## Copy to /posix (to emulate bind during cross compilation) -#cp -pfr $JEHANNE/pkgs/binutils/2.33.1/posix/* $JEHANNE/posix -#rm $JEHANNE/posix/lib/*.la +# mock makeinfo (to avoid it as a dependency) +rm -f $JEHANNE/hacking/bin/makeinfo +ln -s `which echo` $JEHANNE/hacking/bin/makeinfo -echo -n Building gcc... | tee -a $LOG -# Patch and build gcc +# verify libtool is installed +libtool --version >> /dev/null +failOnError $? "libtool installation check" + +(cd $JEHANNE_TOOLCHAIN/src && fetch) >> $LOG +failOnError $? "fetching sources" + + + +echo -n Building libstdc++-v3... | tee -a $LOG +# libstdc++-v3 is part of GCC but must be built after newlib. ( - export GCC_BUILD_DIR=$WORKING_DIR/build/gcc-native && + export GCC_BUILD_DIR=$JEHANNE_TOOLCHAIN/build/gcc && + mkdir -p $GCC_BUILD_DIR && + rm -fr $JEHANNE_TOOLCHAIN/src/gcc/isl-0.18.tar.bz2 && + rm -fr $JEHANNE_TOOLCHAIN/src/gcc/isl-0.18 && + rm -fr $JEHANNE_TOOLCHAIN/src/gcc/isl && + rm -fr $JEHANNE_TOOLCHAIN/src/gcc/gmp-6.1.0.tar.bz2 && + rm -fr $JEHANNE_TOOLCHAIN/src/gcc/gmp-6.1.0 && + rm -fr $JEHANNE_TOOLCHAIN/src/gcc/gmp && + rm -fr $JEHANNE_TOOLCHAIN/src/gcc/mpfr-3.1.4.tar.bz2 && + rm -fr $JEHANNE_TOOLCHAIN/src/gcc/mpfr-3.1.4 && + rm -fr $JEHANNE_TOOLCHAIN/src/gcc/mpfr && + rm -fr $JEHANNE_TOOLCHAIN/src/gcc/mpc-1.0.3.tar.gz && + rm -fr $JEHANNE_TOOLCHAIN/src/gcc/mpc-1.0.3 && + rm -fr $JEHANNE_TOOLCHAIN/src/gcc/mpc && + cd $GCC_BUILD_DIR && + mkdir -p $GCC_BUILD_DIR/x86_64-jehanne/libstdc++-v3 && + cd $GCC_BUILD_DIR/x86_64-jehanne/libstdc++-v3 && + rm -f config.cache && + $JEHANNE_TOOLCHAIN/src/gcc/libstdc++-v3/configure --srcdir=$JEHANNE_TOOLCHAIN/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 +failOnError $? "building libstdc++-v3" +echo done. + +# Copy to /posix (to emulate bind during cross compilation) +cp -pfr $JEHANNE/pkgs/libstdc++-v3/9.2.0/posix/* $JEHANNE/posix +find $JEHANNE/posix/|grep '\.la$'|xargs rm + +echo -n Building libgmp... | tee -a $LOG +( + cd $JEHANNE_TOOLCHAIN/src/libgmp && + ( grep -q jehanne configfsf.sub || patch -p0 < $CROSS_DIR/patch/libgmp.patch ) && + ./configure --host=x86_64-jehanne --disable-shared --prefix=/posix --with-sysroot=$JEHANNE && + make && + make DESTDIR=$JEHANNE/pkgs/libgmp/6.1.2/ install && + libtool --mode=finish $JEHANNE/posix/lib +) >> $LOG 2>&1 +failOnError $? "Building libgmp" +echo done. + +# Copy to /posix (to emulate bind during cross compilation) +cp -pfr $JEHANNE/pkgs/libgmp/6.1.2/posix/* $JEHANNE/posix +rm $JEHANNE/posix/lib/*.la + +echo -n Building libmpfr... | tee -a $LOG +( + cd $JEHANNE_TOOLCHAIN/src/libmpfr && + ( grep -q jehanne config.sub || patch -p0 < $CROSS_DIR/patch/libmpfr.patch ) && + ./configure --host=x86_64-jehanne --disable-shared --prefix=/posix --with-sysroot=$JEHANNE --with-gmp=$JEHANNE/posix/ && + cp $CROSS_DIR/patch/MakeNothing.in doc/Makefile.in && + make && + make DESTDIR=$JEHANNE/pkgs/libmpfr/4.0.1/ install && + libtool --mode=finish $JEHANNE/posix/lib +) >> $LOG 2>&1 +failOnError $? "Building libmpfr" +echo done. + +# Copy to /posix (to emulate bind during cross compilation) +cp -pfr $JEHANNE/pkgs/libmpfr/4.0.1/posix/* $JEHANNE/posix +rm $JEHANNE/posix/lib/*.la + +echo -n Building libmpc... | tee -a $LOG +( + cd $JEHANNE_TOOLCHAIN/src/libmpc && + ( grep -q jehanne config.sub || ( chmod u+w config.sub && + patch -p0 < $CROSS_DIR/patch/libmpc.patch && + chmod u-w config.sub ) ) && + ./configure --host=x86_64-jehanne --disable-shared --prefix=/posix --with-sysroot=$JEHANNE --with-gmp=$JEHANNE/posix/ --with-mpfr=$JEHANNE/posix/ && + cp $CROSS_DIR/patch/MakeNothing.in doc/Makefile.in && + make && + make DESTDIR=$JEHANNE/pkgs/libmpc/1.1.0/ install && + libtool --mode=finish $JEHANNE/posix/lib +) >> $LOG 2>&1 +failOnError $? "Building libmpc" +echo done. + +# Copy to /posix (to emulate bind during cross compilation) +cp -pfr $JEHANNE/pkgs/libmpc/1.1.0/posix/* $JEHANNE/posix +rm $JEHANNE/posix/lib/*.la + +echo -n Building binutils... | tee -a $LOG + + +# Patch and build binutils +if [ "$BINUTILS_BUILD_DIR" = "" ]; then + export BINUTILS_BUILD_DIR=$JEHANNE_TOOLCHAIN/build/binutils-native +fi +if [ ! -d $BINUTILS_BUILD_DIR ]; then + mkdir $BINUTILS_BUILD_DIR +fi +( + 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 && + $JEHANNE_TOOLCHAIN/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 $JEHANNE_TOOLCHAIN/src/binutils/bfd/doc/Makefile.in && + cp $CROSS_DIR/patch/MakeNothing.in $JEHANNE_TOOLCHAIN/src/binutils/bfd/po/Makefile.in && + cp $CROSS_DIR/patch/MakeNothing.in $JEHANNE_TOOLCHAIN/src/binutils/gas/doc/Makefile.in && + cp $CROSS_DIR/patch/MakeNothing.in $JEHANNE_TOOLCHAIN/src/binutils/binutils/doc/Makefile.in && + make && + make DESTDIR=$JEHANNE/pkgs/binutils/2.33.1/ install +) >> $LOG 2>&1 +failOnError $? "Building binutils" + +echo done. + +# Copy to /posix (to emulate bind during cross compilation) +cp -pfr $JEHANNE/pkgs/binutils/2.33.1/posix/* $JEHANNE/posix +rm $JEHANNE/posix/lib/*.la + +echo -n Building gcc (and libgcc)... | tee -a $LOG +( + export GCC_BUILD_DIR=$JEHANNE_TOOLCHAIN/build/gcc-native && mkdir -p $GCC_BUILD_DIR && cd $GCC_BUILD_DIR && - $WORKING_DIR/src/gcc/configure --host=x86_64-jehanne \ - --prefix=/posix --with-sysroot=/ --with-build-sysroot=$JEHANNE \ + $JEHANNE_TOOLCHAIN/src/gcc/configure --host=x86_64-jehanne \ --enable-languages=c,c++ \ - --disable-multiarch --with-multilib-list= \ + --prefix=/posix --with-sysroot=/ --with-build-sysroot=$JEHANNE \ --without-isl --with-gmp=$JEHANNE/posix --with-mpfr=$JEHANNE/posix --with-mpc=$JEHANNE/posix \ + --disable-multiarch --disable-multilib \ --disable-shared --disable-threads --disable-tls \ --disable-libgomp --disable-werror --disable-nls && make all-gcc && - make 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 + 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 && + $JEHANNE_TOOLCHAIN/src/gcc/libgcc/configure --srcdir=$JEHANNE_TOOLCHAIN/src/gcc/libgcc \ + --enable-languages=c,c++,lto \ + --prefix=/posix --with-sysroot=/ --with-build-sysroot=$JEHANNE \ + --without-isl --with-gmp=$JEHANNE/posix --with-mpfr=$JEHANNE/posix --with-mpc=$JEHANNE/posix \ + --disable-multiarch --disable-multilib \ + --disable-shared --disable-threads --disable-tls \ + --disable-libgomp --disable-werror --disable-nls \ + --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 de1f9d8..1b63c2f 100644 --- a/cross/patch/gcc.patch +++ b/cross/patch/gcc.patch @@ -9,7 +9,7 @@ index ddd3b8f..702aa59 100644 +*-*-jehanne*) + gas=yes + gnu_ld=yes -+ extra_objs="jehanne.o" ++ extra_objs="${extra_objs} jehanne.o" + default_use_cxa_atexit=yes + case $target in + x86_64-*) From da44acc091d1179faca022ace02c84e634af4fb7 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Mon, 23 Dec 2019 18:06:59 +0100 Subject: [PATCH 63/91] mksh: use cross/wrappers --- cross/pkgs/mksh/build.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cross/pkgs/mksh/build.sh b/cross/pkgs/mksh/build.sh index c195f58..068d153 100755 --- a/cross/pkgs/mksh/build.sh +++ b/cross/pkgs/mksh/build.sh @@ -27,9 +27,10 @@ export MKSH=$CROSS_DIR/pkgs/mksh/ export MKSH_SRC=$MKSH/src/ export MKSH_BUILD=$MKSH/out/ export MKSHRC_PATH='~/lib/mkshrc' -export LIBS="-L$JEHANNE/posix/lib -lnewlibc -lnewlibm -lnewlibg -lposix" -export CPPFLAGS="-I$JEHANNE/posix/include '-DMKSHRC_PATH=\"$MKSHRC_PATH\"' '-DARCH=\"$ARCH\"'" +export LIBS=" -lm -lg" +export CPPFLAGS="'-DMKSHRC_PATH=\"$MKSHRC_PATH\"' '-DARCH=\"$ARCH\"'" +export PATH="$JEHANNE/hacking/cross/wrappers:$PATH" export LD_PRELOAD= echo -n Building mksh. From 5697f4bc7ffe5150f15043e5435543fbcb97aad5 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Fri, 27 Dec 2019 17:34:05 +0100 Subject: [PATCH 64/91] gcc native: explicit --build --- cross/native.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cross/native.sh b/cross/native.sh index f178765..64689a3 100755 --- a/cross/native.sh +++ b/cross/native.sh @@ -153,12 +153,13 @@ echo done. cp -pfr $JEHANNE/pkgs/binutils/2.33.1/posix/* $JEHANNE/posix rm $JEHANNE/posix/lib/*.la -echo -n Building gcc (and libgcc)... | tee -a $LOG +echo -n "Building gcc (and libgcc)..." | tee -a $LOG ( export GCC_BUILD_DIR=$JEHANNE_TOOLCHAIN/build/gcc-native && mkdir -p $GCC_BUILD_DIR && cd $GCC_BUILD_DIR && - $JEHANNE_TOOLCHAIN/src/gcc/configure --host=x86_64-jehanne \ + $JEHANNE_TOOLCHAIN/src/gcc/configure \ + --build=x86_64-pc-linux-gnu --host=x86_64-jehanne --target=x86_64-jehanne \ --enable-languages=c,c++ \ --prefix=/posix --with-sysroot=/ --with-build-sysroot=$JEHANNE \ --without-isl --with-gmp=$JEHANNE/posix --with-mpfr=$JEHANNE/posix --with-mpc=$JEHANNE/posix \ From 90272aea5ad9104d26974676af57642672d44578 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Fri, 27 Dec 2019 17:34:51 +0100 Subject: [PATCH 65/91] newlib: fix includes in CFLAGS_FOR_TARGET --- cross/pkgs/newlib/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cross/pkgs/newlib/build.sh b/cross/pkgs/newlib/build.sh index 75b1bbd..82aabd8 100755 --- a/cross/pkgs/newlib/build.sh +++ b/cross/pkgs/newlib/build.sh @@ -68,7 +68,7 @@ if [ "$NEWLIB_OPTIMIZATION" = "" ]; then fi export CC=gcc -export CFLAGS_FOR_TARGET="-g -gdwarf-2 -ggdb -O$NEWLIB_OPTIMIZATION -std=gnu11 -I$JEHANNE_TOOLCHAIN/cross/posix/lib/gcc/x86_64-jehanne/9.2.0/include -Lposix" +export CFLAGS_FOR_TARGET="-g -gdwarf-2 -ggdb -O$NEWLIB_OPTIMIZATION -std=gnu11 -isystem$JEHANNE_TOOLCHAIN/cross/posix/lib/gcc/x86_64-jehanne/9.2.0/include -lposix" ( rm -fr $NEWLIB_BUILD && From 18f33da3ddf2d9da70aad04de67bdcc8f0270975 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Fri, 27 Dec 2019 17:53:12 +0100 Subject: [PATCH 66/91] gcc native: wrap __application_newlib_init inside `extern "C" { }` --- cross/patch/gcc/gcc/config/jehanne.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cross/patch/gcc/gcc/config/jehanne.c b/cross/patch/gcc/gcc/config/jehanne.c index 9573a88..95ea4f9 100644 --- a/cross/patch/gcc/gcc/config/jehanne.c +++ b/cross/patch/gcc/gcc/config/jehanne.c @@ -21,9 +21,11 @@ extern "C" { #include #include +void __application_newlib_init(int argc, char *argv[]); + } -void +__attribute__((__used__)) void __application_newlib_init(int argc, char *argv[]) { sys_rfork(RFFDG | RFREND | RFNOTEG); From 540a07726fb140fbac28877ab53b9b222e46e5c4 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Fri, 27 Dec 2019 18:04:11 +0100 Subject: [PATCH 67/91] gcc native: include jehanne.o in extra_gcc_objs (do we need this?) --- cross/patch/gcc.patch | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cross/patch/gcc.patch b/cross/patch/gcc.patch index 1b63c2f..f4aa37a 100644 --- a/cross/patch/gcc.patch +++ b/cross/patch/gcc.patch @@ -2,7 +2,7 @@ diff --git a/src/gcc/gcc/config.gcc b/src/gcc/gcc/config.gcc index ddd3b8f..702aa59 100644 --- a/src/gcc/gcc/config.gcc +++ b/src/gcc/gcc/config.gcc -@@ -947,6 +947,17 @@ case ${target} in +@@ -947,6 +947,18 @@ case ${target} in tmake_file="$tmake_file vms/t-vmsnative" fi ;; @@ -10,6 +10,7 @@ index ddd3b8f..702aa59 100644 + gas=yes + gnu_ld=yes + extra_objs="${extra_objs} jehanne.o" ++ extra_gcc_objs="${extra_gcc_objs} jehanne.o" + default_use_cxa_atexit=yes + case $target in + x86_64-*) From aff240b000c20d27624bab6bd5bcff1e059a493d Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Fri, 27 Dec 2019 19:50:31 +0100 Subject: [PATCH 68/91] gcc native: add t-jehanne Makefile include --- cross/patch/gcc.patch | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cross/patch/gcc.patch b/cross/patch/gcc.patch index 1b63c2f..1ce1004 100644 --- a/cross/patch/gcc.patch +++ b/cross/patch/gcc.patch @@ -2,13 +2,14 @@ diff --git a/src/gcc/gcc/config.gcc b/src/gcc/gcc/config.gcc index ddd3b8f..702aa59 100644 --- a/src/gcc/gcc/config.gcc +++ b/src/gcc/gcc/config.gcc -@@ -947,6 +947,17 @@ case ${target} in +@@ -947,6 +947,18 @@ case ${target} in tmake_file="$tmake_file vms/t-vmsnative" fi ;; +*-*-jehanne*) + gas=yes + gnu_ld=yes ++ tmake_file=t-jehanne + extra_objs="${extra_objs} jehanne.o" + default_use_cxa_atexit=yes + case $target in From ef4aafa403ff0f986e9011d59ae67e9d82aa1c5a Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Fri, 27 Dec 2019 19:51:42 +0100 Subject: [PATCH 69/91] newlib: cleanup --- cross/pkgs/newlib/build.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cross/pkgs/newlib/build.sh b/cross/pkgs/newlib/build.sh index 75b1bbd..60ea678 100755 --- a/cross/pkgs/newlib/build.sh +++ b/cross/pkgs/newlib/build.sh @@ -21,10 +21,6 @@ if [ "$JEHANNE" = "" ]; then exit 1 fi -# To create a Jehanne version of newlib, we need specific OUTDATED versions -# of Autotools that won't compile easily in a modern Linux distro. -export PATH=$JEHANNE/hacking/cross/tmp/bin:$PATH - export CROSS_DIR=$JEHANNE/hacking/cross export NEWLIB=$CROSS_DIR/pkgs/newlib/ export NEWLIB_SRC=$NEWLIB/src/ From c51740758320989cd40645a78a0302216a8363ae Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Tue, 7 Jan 2020 23:28:29 +0100 Subject: [PATCH 70/91] gcc native: add jehanne.o to executables (to check) --- cross/wrappers/x86_64-jehanne-g++ | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cross/wrappers/x86_64-jehanne-g++ b/cross/wrappers/x86_64-jehanne-g++ index 678f6ca..4413855 100755 --- a/cross/wrappers/x86_64-jehanne-g++ +++ b/cross/wrappers/x86_64-jehanne-g++ @@ -15,6 +15,10 @@ echo >> $WRAPPER_LOG if echo $ARGS|grep -e '\.cpp\b' -e '\b\-o\b' -e ' -o ' > /dev/null; then TOINCLUDE="-isystem$JEHANNE/posix/x86_64-jehanne/include/c++/9.2.0/ -isystem$JEHANNE/posix/x86_64-jehanne/include/c++/9.2.0/x86_64-jehanne -isystem$JEHANNE/posix/x86_64-jehanne/include/c++/9.2.0/backward -isystem$JEHANNE_TOOLCHAIN/cross/posix/lib/gcc/x86_64-jehanne/9.2.0/include -isystem$JEHANNE/posix/include" TOLINK="-L$JEHANNE/posix/lib -lstdc++ -lm -lnewlibc -lposix" + if echo $ARGS|grep -e ' -o cc1' -e ' -o xg[c+][c+]' -e ' -o cpp ' -e ' -o lto1' > /dev/null; then + TOLINK="jehanne.o $TOLINK" + #CXXFLAGS_FOR_WRAPPER="-Wl,--require-defined=__application_newlib_init" + fi 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 From e645cbc104c82077418e9dcae134e65aaadc2b25 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Mon, 13 Jan 2020 13:09:53 +0100 Subject: [PATCH 71/91] gcc: LIB_SPEC includes -ljehanne instead of -lc --- cross/patch/gcc/gcc/config/jehanne.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cross/patch/gcc/gcc/config/jehanne.h b/cross/patch/gcc/gcc/config/jehanne.h index 245351b..e760c28 100644 --- a/cross/patch/gcc/gcc/config/jehanne.h +++ b/cross/patch/gcc/gcc/config/jehanne.h @@ -21,7 +21,7 @@ /* Default arguments you want when running x86_64-jehanne-gcc */ #undef LIB_SPEC -#define LIB_SPEC "-lc" +#define LIB_SPEC "-ljehanne" #undef STANDARD_STARTFILE_PREFIX #define STANDARD_STARTFILE_PREFIX "/arch/amd64/lib/" From fdc6a49fac4f0b51a3608eb0708f4be142b19ab7 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Thu, 16 Jan 2020 00:46:16 +0100 Subject: [PATCH 72/91] newlib: do not rename libc.a anymore --- cross/pkgs/newlib/build.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cross/pkgs/newlib/build.sh b/cross/pkgs/newlib/build.sh index 95f6562..88d0c77 100755 --- a/cross/pkgs/newlib/build.sh +++ b/cross/pkgs/newlib/build.sh @@ -86,10 +86,6 @@ failOnError $? "building newlib" mkdir -p $JEHANNE/posix cp -fr $JEHANNE/pkgs/newlib/x86_64-jehanne/* $JEHANNE/posix -# rename libc to libnewlibc to avoid name clash with Jehanne's libc -mv $JEHANNE/posix/lib/libc.a $JEHANNE/posix/lib/libnewlibc.a - - kill $dotter wait $dotter 2>/dev/null From 1addd6d56b3fa85a0c8261d43ed4235a4f4be322 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Fri, 17 Jan 2020 00:21:05 +0100 Subject: [PATCH 73/91] gcc cross: cleanup init.sh --- cross/init.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/cross/init.sh b/cross/init.sh index 2f81324..62646fb 100755 --- a/cross/init.sh +++ b/cross/init.sh @@ -122,9 +122,3 @@ mkdir -p $GCC_BUILD_DIR ) >> $LOG 2>&1 failOnError $? "building gcc" echo done. - -## TODO: get a sense of this... shouldn't we do this after GCC compilation? -#echo -n Copying GCC includes into $JEHANNE/posix... -#mkdir -p $JEHANNE/posix/lib -#cp -fpr $WORKING_DIR/cross/posix/lib/* $JEHANNE/posix/lib -#echo done. From f25c95e76f96a3a528127fb1cf8e53175b505a27 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Fri, 17 Jan 2020 00:46:59 +0100 Subject: [PATCH 74/91] gcc native: cleanup libgcc compilation --- cross/native.sh | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/cross/native.sh b/cross/native.sh index 64689a3..bc88447 100755 --- a/cross/native.sh +++ b/cross/native.sh @@ -168,27 +168,11 @@ echo -n "Building gcc (and libgcc)..." | tee -a $LOG --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 && - $JEHANNE_TOOLCHAIN/src/gcc/libgcc/configure --srcdir=$JEHANNE_TOOLCHAIN/src/gcc/libgcc \ - --enable-languages=c,c++,lto \ - --prefix=/posix --with-sysroot=/ --with-build-sysroot=$JEHANNE \ - --without-isl --with-gmp=$JEHANNE/posix --with-mpfr=$JEHANNE/posix --with-mpc=$JEHANNE/posix \ - --disable-multiarch --disable-multilib \ - --disable-shared --disable-threads --disable-tls \ - --disable-libgomp --disable-werror --disable-nls \ - --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 + make all-target-libgcc && + make DESTDIR=$JEHANNE/pkgs/gcc/9.2.0/ install-target-libgcc ) >> $LOG 2>&1 failOnError $? "building gcc" cp -pfr $JEHANNE/pkgs/gcc/9.2.0/posix/* $JEHANNE/posix -# -## add sh -#ln -sf /bin/bash $JEHANNE/hacking/cross/toolchain/bin/x86_64-jehanne-sh - echo "done." From 6bcca46d9f7bec81c974df37d57056406471eaba Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Fri, 17 Jan 2020 01:11:55 +0100 Subject: [PATCH 75/91] gcc native: no __application_newlib_init (apparently there is no need for SIGCHLD) --- cross/patch/gcc.patch | 5 +---- cross/patch/gcc/gcc/config/jehanne.c | 33 ---------------------------- cross/patch/gcc/gcc/config/t-jehanne | 19 ---------------- 3 files changed, 1 insertion(+), 56 deletions(-) delete mode 100644 cross/patch/gcc/gcc/config/jehanne.c delete mode 100644 cross/patch/gcc/gcc/config/t-jehanne diff --git a/cross/patch/gcc.patch b/cross/patch/gcc.patch index 82c1847..1c53d6d 100644 --- a/cross/patch/gcc.patch +++ b/cross/patch/gcc.patch @@ -2,16 +2,13 @@ diff --git a/src/gcc/gcc/config.gcc b/src/gcc/gcc/config.gcc index ddd3b8f..702aa59 100644 --- a/src/gcc/gcc/config.gcc +++ b/src/gcc/gcc/config.gcc -@@ -947,6 +947,18 @@ case ${target} in +@@ -947,6 +947,16 @@ case ${target} in tmake_file="$tmake_file vms/t-vmsnative" fi ;; +*-*-jehanne*) + gas=yes + gnu_ld=yes -+ tmake_file=t-jehanne -+ extra_objs="${extra_objs} jehanne.o" -+ extra_gcc_objs="${extra_gcc_objs} jehanne.o" + default_use_cxa_atexit=yes + case $target in + x86_64-*) diff --git a/cross/patch/gcc/gcc/config/jehanne.c b/cross/patch/gcc/gcc/config/jehanne.c deleted file mode 100644 index 95ea4f9..0000000 --- a/cross/patch/gcc/gcc/config/jehanne.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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[]); - -} - -__attribute__((__used__)) 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 deleted file mode 100644 index f239bbf..0000000 --- a/cross/patch/gcc/gcc/config/t-jehanne +++ /dev/null @@ -1,19 +0,0 @@ -# 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) From 5734d5963963a9bb65e14ea3d1b815fa2c11c749 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Fri, 17 Jan 2020 01:21:40 +0100 Subject: [PATCH 76/91] newlib: merge LibPOSIX into libc.a (and libg.a) so that you just need to specify -lc --- cross/pkgs/newlib/build.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/cross/pkgs/newlib/build.sh b/cross/pkgs/newlib/build.sh index 88d0c77..01c5bef 100755 --- a/cross/pkgs/newlib/build.sh +++ b/cross/pkgs/newlib/build.sh @@ -59,6 +59,17 @@ function failOnError { fi } +function mergeLibPOSIX { + TARGET_LIB=$1 + echo "Merging $JEHANNE/arch/$ARCH/lib/libposix.a into $TARGET_LIB." && + x86_64-jehanne-ar -M <> $NEWLIB/newlib.build.log 2>&1 failOnError $? "building newlib" + + # emultate bind for the cross compiler mkdir -p $JEHANNE/posix cp -fr $JEHANNE/pkgs/newlib/x86_64-jehanne/* $JEHANNE/posix From 73fab2e6bef6cf3afc39d113aff3139d3d2a5f9f Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Fri, 17 Jan 2020 01:39:21 +0100 Subject: [PATCH 77/91] gcc native: cleanup cross-compiler wrappers (needed to specify -lc and stuffs) --- cross/wrappers/x86_64-jehanne-g++ | 6 +----- cross/wrappers/x86_64-jehanne-gcc | 2 +- cross/wrappers/x86_64-jehanne-ld | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/cross/wrappers/x86_64-jehanne-g++ b/cross/wrappers/x86_64-jehanne-g++ index 4413855..56044c8 100755 --- a/cross/wrappers/x86_64-jehanne-g++ +++ b/cross/wrappers/x86_64-jehanne-g++ @@ -14,11 +14,7 @@ echo >> $WRAPPER_LOG if echo $ARGS|grep -e '\.cpp\b' -e '\b\-o\b' -e ' -o ' > /dev/null; then TOINCLUDE="-isystem$JEHANNE/posix/x86_64-jehanne/include/c++/9.2.0/ -isystem$JEHANNE/posix/x86_64-jehanne/include/c++/9.2.0/x86_64-jehanne -isystem$JEHANNE/posix/x86_64-jehanne/include/c++/9.2.0/backward -isystem$JEHANNE_TOOLCHAIN/cross/posix/lib/gcc/x86_64-jehanne/9.2.0/include -isystem$JEHANNE/posix/include" - TOLINK="-L$JEHANNE/posix/lib -lstdc++ -lm -lnewlibc -lposix" - if echo $ARGS|grep -e ' -o cc1' -e ' -o xg[c+][c+]' -e ' -o cpp ' -e ' -o lto1' > /dev/null; then - TOLINK="jehanne.o $TOLINK" - #CXXFLAGS_FOR_WRAPPER="-Wl,--require-defined=__application_newlib_init" - fi + TOLINK="-L$JEHANNE/posix/lib -lstdc++ -lm -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 diff --git a/cross/wrappers/x86_64-jehanne-gcc b/cross/wrappers/x86_64-jehanne-gcc index c8ec575..fdc1cd0 100755 --- a/cross/wrappers/x86_64-jehanne-gcc +++ b/cross/wrappers/x86_64-jehanne-gcc @@ -14,7 +14,7 @@ echo >> $WRAPPER_LOG if echo $ARGS|grep -e '\.c\b' -e '\b\-o\b' -e ' -o ' > /dev/null; then TOINCLUDE="-isystem$JEHANNE_TOOLCHAIN/cross/posix/lib/gcc/x86_64-jehanne/9.2.0/include -isystem$JEHANNE/posix/include" - TOLINK="-L$JEHANNE/posix/lib -lnewlibc -lposix" + TOLINK="-L$JEHANNE/posix/lib -lc" date --rfc-3339="ns" |tee -a $WRAPPER_LOG export >> $WRAPPER_LOG echo $WORKING_DIR/cross/posix/bin/x86_64-jehanne-gcc "$@" $TOINCLUDE $TOLINK >> $WRAPPER_LOG diff --git a/cross/wrappers/x86_64-jehanne-ld b/cross/wrappers/x86_64-jehanne-ld index b2afe80..d3c50fb 100755 --- a/cross/wrappers/x86_64-jehanne-ld +++ b/cross/wrappers/x86_64-jehanne-ld @@ -13,7 +13,7 @@ echo >> $WRAPPER_LOG echo >> $WRAPPER_LOG if echo $ARGS|grep -e '\b\-o\b' -e ' -o ' > /dev/null; then - TOLINK="-L$JEHANNE/posix/lib -lnewlibc -lposix -lc" + TOLINK="-L$JEHANNE/posix/lib -lc" date --rfc-3339="ns" |tee -a $WRAPPER_LOG export >> $WRAPPER_LOG echo $WORKING_DIR/cross/posix/bin/x86_64-jehanne-ld "$@" $TOLINK >> $WRAPPER_LOG From be4f2df6149c5267dc8f2f7c9124944de194ddee Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Fri, 17 Jan 2020 02:03:11 +0100 Subject: [PATCH 78/91] runOver9P.sh: add reminder for debugging `ufs` --- runOver9P.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/runOver9P.sh b/runOver9P.sh index 90e170c..fd38b62 100755 --- a/runOver9P.sh +++ b/runOver9P.sh @@ -14,6 +14,7 @@ fi trap : 2 $JEHANNE/hacking/bin/ufs -root=$JEHANNE & +# To debug ufs add: -d 5 > $JEHANNE/../ufs.log 2>&1 ufspid=$! export machineflag=pc From 66a4602b6fb9573337288a1ff70005fcd938de66 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Fri, 17 Jan 2020 02:29:13 +0100 Subject: [PATCH 79/91] newlib: update subrepo --- cross/pkgs/newlib/src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cross/pkgs/newlib/src b/cross/pkgs/newlib/src index fef0609..d9c194a 160000 --- a/cross/pkgs/newlib/src +++ b/cross/pkgs/newlib/src @@ -1 +1 @@ -Subproject commit fef060960822ab3d59c1b3d4125c7f33ace8217a +Subproject commit d9c194a0b04a2a66803f7a22bae7069e24642065 From 86c03ba7e6b1fab1bbccd6aad1e72e1bf0a94317 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Fri, 17 Jan 2020 02:43:04 +0100 Subject: [PATCH 80/91] mksh: update subrepo --- cross/pkgs/mksh/src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cross/pkgs/mksh/src b/cross/pkgs/mksh/src index dddf369..4e2ce81 160000 --- a/cross/pkgs/mksh/src +++ b/cross/pkgs/mksh/src @@ -1 +1 @@ -Subproject commit dddf3694e9566a7e304c3c91e8fc5cd5900d551f +Subproject commit 4e2ce8120cfed998cb5e77fa56d91b94c5a08822 From ed6ae298345b341d4fe6bab0d9342381f365c920 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Sat, 18 Jan 2020 15:17:46 +0100 Subject: [PATCH 81/91] native.sh: fix $LIBS for binutils --- cross/native.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cross/native.sh b/cross/native.sh index bc88447..6ccc035 100755 --- a/cross/native.sh +++ b/cross/native.sh @@ -134,7 +134,7 @@ if [ ! -d $BINUTILS_BUILD_DIR ]; then mkdir $BINUTILS_BUILD_DIR fi ( - export LIBS="-L$JEHANNE/posix/lib -L$JEHANNE/arch/amd64/lib -lmpc -lmpfr -lgmp -lnewlibc -lposix -lc" && + export LIBS="-L$JEHANNE/posix/lib -L$JEHANNE/arch/amd64/lib -lmpc -lmpfr -lgmp" && export CC_FOR_BUILD='CPATH="" LIBS="" gcc' && mkdir -p $BINUTILS_BUILD_DIR && cd $BINUTILS_BUILD_DIR && $JEHANNE_TOOLCHAIN/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 && From 18da65783bbd6897e03d241ec7af3fac57aa82a6 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Thu, 27 Aug 2020 12:49:33 +0200 Subject: [PATCH 82/91] gcc native: add cross compilation of GCC to pkgs build (to setup proper POSIX headers in /posix) --- cross/pkgs/build.json | 6 +- cross/pkgs/gcc/build.sh | 203 +++++++++++++++++++++------------------- 2 files changed, 114 insertions(+), 95 deletions(-) diff --git a/cross/pkgs/build.json b/cross/pkgs/build.json index dc009b1..eee6a5b 100644 --- a/cross/pkgs/build.json +++ b/cross/pkgs/build.json @@ -1,8 +1,12 @@ { "CrossCompiledPackages": { + "Env": [ + "CROSS_PKGS_BUILD=1" + ], "Pre": [ "./newlib/build.sh", - "./mksh/build.sh" + "./mksh/build.sh", + "./gcc/build.sh" ] } } diff --git a/cross/pkgs/gcc/build.sh b/cross/pkgs/gcc/build.sh index f4d5ec8..8d34770 100755 --- a/cross/pkgs/gcc/build.sh +++ b/cross/pkgs/gcc/build.sh @@ -1,12 +1,31 @@ #!/bin/bash +CROSS_DIR="$JEHANNE/hacking/cross" +LOG="$CROSS_DIR/pkgs/gcc/native-toolchain.build.log" + +if [ "$CROSS_PKGS_BUILD" = "1" ]; then +if [ -d $JEHANNE/pkgs/gcc/9.2.0/ ]; then + + echo "Skip cross compilation of GCC to not slowdown whole system build." + echo "GCC was already detected at $JEHANNE/pkgs/gcc/9.2.0/" + echo + echo "If you really want to cross compile GCC, run" + echo + echo " $CROSS_DIR/pkgs/gcc/build.sh" + echo + exit + +fi +fi + echo "Cross compiling GCC and dependencies" -export WORKING_DIR="$JEHANNE/hacking/cross/pkgs/gcc" +JEHANNE_TOOLCHAIN=$JEHANNE_TOOLCHAIN -# include x86_64-jehanne-pkg-config in PATH -export PATH="$JEHANNE/hacking/cross/:$PATH" -unset CPATH #set in $JEHANNE/hacking/devshell.sh +export LD_PRELOAD= + +OPATH=$PATH +export PATH="$CROSS_DIR/wrappers:$PATH" function failOnError { # $1 -> exit status on a previous command @@ -16,21 +35,12 @@ function failOnError { echo echo BUILD LOG: echo - cat $WORKING_DIR/gcc.build.log + cat $LOG exit $1 fi } -function dynpatch { - # $1 -> path from $WORKING_DIR/src - # $2 -> string to search - ( cd $WORKING_DIR/src && - grep -q jehanne $1 || - sed -n -i -e "/$2/r ../patch/$1" -e '1x' -e '2,${x;p}' -e '${x;p}' $1 - ) -} - -date > $WORKING_DIR/gcc.build.log +date > $LOG # mock makeinfo (to avoid it as a dependency) rm -f $JEHANNE/hacking/bin/makeinfo @@ -40,140 +50,145 @@ ln -s `which echo` $JEHANNE/hacking/bin/makeinfo libtool --version >> /dev/null failOnError $? "libtool installation check" -(cd src && fetch) >> $WORKING_DIR/gcc.build.log +(cd $JEHANNE_TOOLCHAIN/src && fetch) >> $LOG failOnError $? "fetching sources" -echo -n Building libgmp... | tee -a $WORKING_DIR/gcc.build.log + + +echo -n Building libstdc++-v3... | tee -a $LOG +# libstdc++-v3 is part of GCC but must be built after newlib. ( - cd src/libgmp && - ( grep -q jehanne configfsf.sub || patch -p0 < $WORKING_DIR/patch/libgmp.patch ) && - ./configure --host=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE && + export GCC_BUILD_DIR=$JEHANNE_TOOLCHAIN/build/gcc && + mkdir -p $GCC_BUILD_DIR && + rm -fr $JEHANNE_TOOLCHAIN/src/gcc/isl-0.18.tar.bz2 && + rm -fr $JEHANNE_TOOLCHAIN/src/gcc/isl-0.18 && + rm -fr $JEHANNE_TOOLCHAIN/src/gcc/isl && + rm -fr $JEHANNE_TOOLCHAIN/src/gcc/gmp-6.1.0.tar.bz2 && + rm -fr $JEHANNE_TOOLCHAIN/src/gcc/gmp-6.1.0 && + rm -fr $JEHANNE_TOOLCHAIN/src/gcc/gmp && + rm -fr $JEHANNE_TOOLCHAIN/src/gcc/mpfr-3.1.4.tar.bz2 && + rm -fr $JEHANNE_TOOLCHAIN/src/gcc/mpfr-3.1.4 && + rm -fr $JEHANNE_TOOLCHAIN/src/gcc/mpfr && + rm -fr $JEHANNE_TOOLCHAIN/src/gcc/mpc-1.0.3.tar.gz && + rm -fr $JEHANNE_TOOLCHAIN/src/gcc/mpc-1.0.3 && + rm -fr $JEHANNE_TOOLCHAIN/src/gcc/mpc && + cd $GCC_BUILD_DIR && + mkdir -p $GCC_BUILD_DIR/x86_64-jehanne/libstdc++-v3 && + cd $GCC_BUILD_DIR/x86_64-jehanne/libstdc++-v3 && + rm -f config.cache && + $JEHANNE_TOOLCHAIN/src/gcc/libstdc++-v3/configure --srcdir=$JEHANNE_TOOLCHAIN/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 +failOnError $? "building libstdc++-v3" +echo done. + +# Copy to /posix (to emulate bind during cross compilation) +cp -pfr $JEHANNE/pkgs/libstdc++-v3/9.2.0/posix/* $JEHANNE/posix +find $JEHANNE/posix/|grep '\.la$'|xargs rm + +echo -n Building libgmp... | tee -a $LOG +( + cd $JEHANNE_TOOLCHAIN/src/libgmp && + ( grep -q jehanne configfsf.sub || patch -p0 < $CROSS_DIR/patch/libgmp.patch ) && + ./configure --host=x86_64-jehanne --disable-shared --prefix=/posix --with-sysroot=$JEHANNE && make && make DESTDIR=$JEHANNE/pkgs/libgmp/6.1.2/ install && libtool --mode=finish $JEHANNE/posix/lib -) >> $WORKING_DIR/gcc.build.log 2>&1 +) >> $LOG 2>&1 failOnError $? "Building libgmp" echo done. # Copy to /posix (to emulate bind during cross compilation) cp -pfr $JEHANNE/pkgs/libgmp/6.1.2/posix/* $JEHANNE/posix +rm $JEHANNE/posix/lib/*.la -echo -n Building libmpfr... | tee -a $WORKING_DIR/gcc.build.log +echo -n Building libmpfr... | tee -a $LOG ( - cd src/libmpfr && - ( grep -q jehanne config.sub || patch -p0 < $WORKING_DIR/patch/libmpfr.patch ) && - ./configure --host=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE --with-gmp=$JEHANNE/pkgs/libgmp/6.1.2/posix/ && - cp ../../../../patch/MakeNothing.in doc/Makefile.in && + cd $JEHANNE_TOOLCHAIN/src/libmpfr && + ( grep -q jehanne config.sub || patch -p0 < $CROSS_DIR/patch/libmpfr.patch ) && + ./configure --host=x86_64-jehanne --disable-shared --prefix=/posix --with-sysroot=$JEHANNE --with-gmp=$JEHANNE/posix/ && + cp $CROSS_DIR/patch/MakeNothing.in doc/Makefile.in && make && make DESTDIR=$JEHANNE/pkgs/libmpfr/4.0.1/ install && libtool --mode=finish $JEHANNE/posix/lib -) >> $WORKING_DIR/gcc.build.log 2>&1 +) >> $LOG 2>&1 failOnError $? "Building libmpfr" echo done. # Copy to /posix (to emulate bind during cross compilation) cp -pfr $JEHANNE/pkgs/libmpfr/4.0.1/posix/* $JEHANNE/posix +rm $JEHANNE/posix/lib/*.la -echo -n Building libmpc... | tee -a $WORKING_DIR/gcc.build.log +echo -n Building libmpc... | tee -a $LOG ( - cd src/libmpc && + cd $JEHANNE_TOOLCHAIN/src/libmpc && ( grep -q jehanne config.sub || ( chmod u+w config.sub && - patch -p0 < $WORKING_DIR/patch/libmpc.patch && + patch -p0 < $CROSS_DIR/patch/libmpc.patch && chmod u-w config.sub ) ) && - ./configure --host=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE --with-gmp=$JEHANNE/pkgs/libgmp/6.1.2/posix/ --with-mpfr=$JEHANNE/pkgs/libmpfr/4.0.1/posix/ && - cp ../../../../patch/MakeNothing.in doc/Makefile.in && + ./configure --host=x86_64-jehanne --disable-shared --prefix=/posix --with-sysroot=$JEHANNE --with-gmp=$JEHANNE/posix/ --with-mpfr=$JEHANNE/posix/ && + cp $CROSS_DIR/patch/MakeNothing.in doc/Makefile.in && make && make DESTDIR=$JEHANNE/pkgs/libmpc/1.1.0/ install && libtool --mode=finish $JEHANNE/posix/lib -) >> $WORKING_DIR/gcc.build.log 2>&1 +) >> $LOG 2>&1 failOnError $? "Building libmpc" echo done. # Copy to /posix (to emulate bind during cross compilation) cp -pfr $JEHANNE/pkgs/libmpc/1.1.0/posix/* $JEHANNE/posix +rm $JEHANNE/posix/lib/*.la -echo -n Building binutils... | tee -a $WORKING_DIR/gcc.build.log +echo -n Building binutils... | tee -a $LOG -export CPATH="$JEHANNE/posix/include:$JEHANNE/sys/include:$JEHANNE/arch/amd64/include:$JEHANNE/hacking/cross/toolchain/lib/gcc/x86_64-jehanne/4.9.4/include:$JEHANNE/hacking/cross/toolchain/lib/gcc/x86_64-jehanne/4.9.4/include-fixed" -export LIBS="-L$JEHANNE/posix/lib -lnewlibc -lposix -lc" -export CC_FOR_BUILD='CPATH="" LIBS="" gcc' # Patch and build binutils if [ "$BINUTILS_BUILD_DIR" = "" ]; then - export BINUTILS_BUILD_DIR=$WORKING_DIR/build-binutils + export BINUTILS_BUILD_DIR=$JEHANNE_TOOLCHAIN/build/binutils-native fi if [ ! -d $BINUTILS_BUILD_DIR ]; then mkdir $BINUTILS_BUILD_DIR fi -( ( grep -q jehanne src/binutils/config.sub || ( -echo done - sed -i '/jehanne/b; /ELF_TARGET_ID/,/elf_backend_can_gc_sections/s/0x200000/0x1000 \/\/ jehanne hack/g' src/binutils/bfd/elf64-x86-64.c && - sed -i '/jehanne/b; s/| midnightbsd\*/| midnightbsd* | jehanne*/g' src/binutils/config.sub && - dynpatch 'binutils/bfd/config.bfd' '\# END OF targmatch.h' && - dynpatch 'binutils/gas/configure.tgt' ' i386-\*-darwin\*)' && - ( grep -q jehanne src/binutils/ld/configure.tgt || patch -p1 < patch/binutils/ld/configure.tgt ) && - cp patch/binutils/ld/emulparams/elf_x86_64_jehanne.sh src/binutils/ld/emulparams/ && - cp patch/binutils/ld/emulparams/elf_i386_jehanne.sh src/binutils/ld/emulparams/ && - dynpatch 'binutils/ld/Makefile.am' 'eelf_x86_64.c: ' && - (grep 'eelf_i386_jehanne.c \\' src/binutils/ld/Makefile.am || sed -i 's/.*ALL_EMULATION_SOURCES = \\.*/&\n\teelf_i386_jehanne.c \\/' src/binutils/ld/Makefile.am) && - (grep 'eelf_x86_64_jehanne.c \\' src/binutils/ld/Makefile.am || sed -i 's/.*ALL_64_EMULATION_SOURCES = \\.*/&\n\teelf_x86_64_jehanne.c \\/' src/binutils/ld/Makefile.am) && - cd src/binutils/ld && automake-1.15 && cd ../ - ) ) && +( + export LIBS="-L$JEHANNE/posix/lib -L$JEHANNE/arch/amd64/lib -lmpc -lmpfr -lgmp" && + 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=$JEHANNE --target=x86_64-jehanne --enable-interwork --enable-multilib --enable-newlib-long-time_t --disable-nls --disable-werror && - cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/bfd/doc/Makefile.in && - cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/bfd/po/Makefile.in && - cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/gas/doc/Makefile.in && - cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/binutils/doc/Makefile.in && - make && + $JEHANNE_TOOLCHAIN/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 $JEHANNE_TOOLCHAIN/src/binutils/bfd/doc/Makefile.in && + cp $CROSS_DIR/patch/MakeNothing.in $JEHANNE_TOOLCHAIN/src/binutils/bfd/po/Makefile.in && + cp $CROSS_DIR/patch/MakeNothing.in $JEHANNE_TOOLCHAIN/src/binutils/gas/doc/Makefile.in && + cp $CROSS_DIR/patch/MakeNothing.in $JEHANNE_TOOLCHAIN/src/binutils/binutils/doc/Makefile.in && + make && make DESTDIR=$JEHANNE/pkgs/binutils/2.33.1/ install -) >> $WORKING_DIR/gcc.build.log 2>&1 +) >> $LOG 2>&1 failOnError $? "Building binutils" echo done. # Copy to /posix (to emulate bind during cross compilation) cp -pfr $JEHANNE/pkgs/binutils/2.33.1/posix/* $JEHANNE/posix +rm $JEHANNE/posix/lib/*.la - -echo -n Building gcc... | tee -a $WORKING_DIR/gcc.build.log -# Patch and build gcc -if [ "$GCC_BUILD_DIR" = "" ]; then - export GCC_BUILD_DIR=$WORKING_DIR/build-gcc -fi -if [ ! -d $GCC_BUILD_DIR ]; then - mkdir $GCC_BUILD_DIR -fi +echo -n "Building gcc (and libgcc)..." | tee -a $LOG ( - pwd && - ( grep -q jehanne src/gcc/gcc/config.gcc || patch -p1 < patch/gcc.patch ) && - cp patch/gcc/gcc/config/jehanne.h src/gcc/gcc/config && - sed -i 's/ftp/https/g' src/gcc/contrib/download_prerequisites && - cd src && - ( cd gcc && ./contrib/download_prerequisites ) && - ( cd gcc/libstdc++-v3 && autoconf -i ) && + export GCC_BUILD_DIR=$JEHANNE_TOOLCHAIN/build/gcc-native && + mkdir -p $GCC_BUILD_DIR && cd $GCC_BUILD_DIR && - $WORKING_DIR/src/gcc/configure --host=x86_64-jehanne --target=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE --enable-languages=c,c++ && - make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true all-gcc all-target-libgcc && - make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true DESTDIR=$JEHANNE/pkgs/gcc/9.2.0/ install-gcc install-target-libgcc -# && -# make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true all-target-libstdc++-v3 && -# make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true install-target-libstdc++-v3 -) >> $WORKING_DIR/gcc.build.log 2>&1 + $JEHANNE_TOOLCHAIN/src/gcc/configure \ + --build=x86_64-pc-linux-gnu --host=x86_64-jehanne --target=x86_64-jehanne \ + --enable-languages=c,c++ \ + --prefix=/posix --with-sysroot=/ --with-build-sysroot=$JEHANNE \ + --without-isl --with-gmp=$JEHANNE/posix --with-mpfr=$JEHANNE/posix --with-mpc=$JEHANNE/posix \ + --disable-multiarch --disable-multilib \ + --disable-shared --disable-threads --disable-tls \ + --disable-libgomp --disable-werror --disable-nls && + make all-gcc && + make DESTDIR=$JEHANNE/pkgs/gcc/9.2.0/ install-gcc && + make all-target-libgcc && + make DESTDIR=$JEHANNE/pkgs/gcc/9.2.0/ install-target-libgcc +) >> $LOG 2>&1 failOnError $? "building gcc" cp -pfr $JEHANNE/pkgs/gcc/9.2.0/posix/* $JEHANNE/posix -# -## add sh -#ln -sf /bin/bash $JEHANNE/hacking/cross/toolchain/bin/x86_64-jehanne-sh - - -#cp src/gcc.bkp/gcc/config.gcc src/gcc/gcc/config.gcc -#cp src/gcc.bkp/config.sub src/gcc/config.sub -#cp src/gcc.bkp/fixincludes/mkfixinc.sh src/gcc/fixincludes/mkfixinc.sh -#cp src/gcc.bkp/libgcc/config.host src/gcc/libgcc/config.host - - - echo "done." From e0420eb690924cd51907976cde35271c872633ba Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Sat, 29 Aug 2020 01:23:19 +0200 Subject: [PATCH 83/91] newlib: add --disable-newlib-unbuf-stream-opt to avoid optimization causing fpu usage in note handler --- cross/pkgs/newlib/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cross/pkgs/newlib/build.sh b/cross/pkgs/newlib/build.sh index 01c5bef..e6bcc38 100755 --- a/cross/pkgs/newlib/build.sh +++ b/cross/pkgs/newlib/build.sh @@ -83,7 +83,7 @@ export CFLAGS_FOR_TARGET="-g -gdwarf-2 -ggdb -O$NEWLIB_OPTIMIZATION -std=gnu11 - mkdir $NEWLIB_BUILD && mkdir $NEWLIB_PREFIX && cd $NEWLIB_BUILD && - $NEWLIB_SRC/configure --enable-newlib-mb --disable-newlib-fvwrite-in-streamio --prefix=/pkgs/newlib --target=x86_64-jehanne && + $NEWLIB_SRC/configure --enable-newlib-mb --disable-newlib-fvwrite-in-streamio --disable-newlib-unbuf-stream-opt --prefix=/pkgs/newlib --target=x86_64-jehanne && make all && make DESTDIR=$NEWLIB_PREFIX install && cd $NEWLIB_PREFIX/pkgs/newlib/x86_64-jehanne/lib && From 545076c6df89e02100da80b0f91dbe07bc2a88bd Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Tue, 1 Sep 2020 13:05:39 +0200 Subject: [PATCH 84/91] gcc: introduce `--posixly` command line option to ease the compilation of POSIX software --- cross/patch/gcc.patch | 5 +- cross/patch/gcc/gcc/config/jehanne.h | 73 ++++++++++++++++++++++++-- cross/patch/gcc/gcc/config/jehanne.opt | 25 +++++++++ 3 files changed, 97 insertions(+), 6 deletions(-) create mode 100644 cross/patch/gcc/gcc/config/jehanne.opt diff --git a/cross/patch/gcc.patch b/cross/patch/gcc.patch index 1c53d6d..bc4239d 100644 --- a/cross/patch/gcc.patch +++ b/cross/patch/gcc.patch @@ -2,7 +2,7 @@ diff --git a/src/gcc/gcc/config.gcc b/src/gcc/gcc/config.gcc index ddd3b8f..702aa59 100644 --- a/src/gcc/gcc/config.gcc +++ b/src/gcc/gcc/config.gcc -@@ -947,6 +947,16 @@ case ${target} in +@@ -947,6 +947,18 @@ case ${target} in tmake_file="$tmake_file vms/t-vmsnative" fi ;; @@ -10,6 +10,7 @@ index ddd3b8f..702aa59 100644 + gas=yes + gnu_ld=yes + default_use_cxa_atexit=yes ++ extra_options="$extra_options jehanne.opt" + case $target in + x86_64-*) + native_system_header_dir="/arch/amd64/include" @@ -19,7 +20,7 @@ index ddd3b8f..702aa59 100644 *-*-vxworks*) tmake_file=t-vxworks xm_defines=POSIX -@@ -1635,6 +1647,9 @@ i[34567]86-*-elfiamcu) +@@ -1635,6 +1648,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" ;; diff --git a/cross/patch/gcc/gcc/config/jehanne.h b/cross/patch/gcc/gcc/config/jehanne.h index e760c28..afa2597 100644 --- a/cross/patch/gcc/gcc/config/jehanne.h +++ b/cross/patch/gcc/gcc/config/jehanne.h @@ -18,16 +18,30 @@ #undef TARGET_JEHANNE #define TARGET_JEHANNE 1 +/* +#undef DRIVER_SELF_SPECS +#define DRIVER_SELF_SPECS "%{-posixly}" +*/ + +/* GCC on Jehanne includes and link libraries from /sys and /arch. + * To ease the port of POSIX applications, we include a --posixly option + * to the GCC driver that will be substituted with proper options + */ +#undef CPP_SPEC +#define CPP_SPEC "%{-posixly:-isystem/posix/include}" + +#undef LINK_SPEC +#define LINK_SPEC "%{-posixly:-L/posix/lib}" -/* Default arguments you want when running x86_64-jehanne-gcc */ #undef LIB_SPEC -#define LIB_SPEC "-ljehanne" +#define LIB_SPEC "%{-posixly:%{!shared:%{g*:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}} -ljehanne" + #undef STANDARD_STARTFILE_PREFIX #define STANDARD_STARTFILE_PREFIX "/arch/amd64/lib/" -#undef MD_STARTFILE_PREFIX -#define MD_STARTFILE_PREFIX "/arch/amd64/lib/" +/* GCC include paths definition START + */ /* Architecture specific header (u.h) goes here (from config.gcc) */ #define ARCH_INCLUDE_DIR NATIVE_SYSTEM_HEADER_DIR @@ -35,14 +49,65 @@ /* The default include dir is /sys/include */ #define PORTABLE_INCLUDE_DIR "/sys/include" +#ifdef GPLUSPLUS_INCLUDE_DIR + /* Pick up GNU C++ generic include files. */ +# define ID_GPLUSPLUS { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, +#else +# define ID_GPLUSPLUS +#endif +#ifdef GPLUSPLUS_TOOL_INCLUDE_DIR + /* Pick up GNU C++ target-dependent include files. */ +# define ID_GPLUSPLUS_TOOL { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, +#else +# define ID_GPLUSPLUS_TOOL +#endif +#ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR + /* Pick up GNU C++ backward and deprecated include files. */ +# define ID_GPLUSPLUS_BACKWARD { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, +#else +# define ID_GPLUSPLUS_BACKWARD +#endif +#ifdef GCC_INCLUDE_DIR + /* This is the dir for gcc's private headers. */ +# define ID_GCC { GCC_INCLUDE_DIR, "GCC", 0, 0, 0, 0 }, +#else +# define ID_GCC +#endif +#ifdef PREFIX_INCLUDE_DIR +# define ID_PREFIX { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0 }, +#else +# define ID_PREFIX +#endif +#if defined (CROSS_INCLUDE_DIR) && defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT) +# define ID_CROSS { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0 }, +#else +# define ID_CROSS +#endif +#ifdef TOOL_INCLUDE_DIR + /* Another place the target system's headers might be. */ +# define ID_TOOL { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0 }, +#else +# define ID_TOOL +#endif + #undef INCLUDE_DEFAULTS #define INCLUDE_DEFAULTS \ { \ + ID_GPLUSPLUS \ + ID_GPLUSPLUS_TOOL \ + ID_GPLUSPLUS_BACKWARD \ + ID_GCC \ + ID_PREFIX \ + ID_CROSS \ + ID_TOOL \ { PORTABLE_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ { ARCH_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ { 0, 0, 0, 0, 0, 0 } \ } +/* GCC include paths definition END + */ + /* Files that are linked before user code. The %s tells gcc to look for these files in the library directory. */ #undef STARTFILE_SPEC diff --git a/cross/patch/gcc/gcc/config/jehanne.opt b/cross/patch/gcc/gcc/config/jehanne.opt new file mode 100644 index 0000000..50a8c80 --- /dev/null +++ b/cross/patch/gcc/gcc/config/jehanne.opt @@ -0,0 +1,25 @@ +; Jehanne options. + +; This file is part of Jehanne. +; +; Copyright (C) 2016-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 . + +; Please try to keep this file in ASCII collating order. + +-posixly +C ObjC C++ ObjC++ Driver RejectNegative +Lookup for POSIX includes and libraries in /posix + +; This comment is to ensure we retain the blank line above. From 8d419405cbb13912c301f45f928d2d5b3dc86a1e Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Tue, 1 Sep 2020 13:10:12 +0200 Subject: [PATCH 85/91] gcc native: remove cross/native.sh and unused patches in cross/pkgs/gcc/patch Apparently we can use the patches created for the cross compiler. cross/native.sh has been moved in cross/pkgs/gcc/build.sh to get some coherence among the packages (in the hope of writing a reasonable package manager in the future). --- cross/native.sh | 178 ------------------ cross/pkgs/gcc/patch/binutils/bfd/config.bfd | 7 - .../pkgs/gcc/patch/binutils/gas/configure.tgt | 3 - cross/pkgs/gcc/patch/binutils/ld/Makefile.am | 8 - .../pkgs/gcc/patch/binutils/ld/configure.tgt | 25 --- .../ld/emulparams/elf_i386_jehanne.sh | 4 - .../ld/emulparams/elf_x86_64_jehanne.sh | 4 - cross/pkgs/gcc/patch/gcc.patch | 71 ------- cross/pkgs/gcc/patch/gcc/gcc/config/jehanne.h | 86 --------- cross/pkgs/gcc/patch/libgmp.patch | 11 -- cross/pkgs/gcc/patch/libmpc.patch | 11 -- cross/pkgs/gcc/patch/libmpfr.patch | 11 -- 12 files changed, 419 deletions(-) delete mode 100755 cross/native.sh delete mode 100644 cross/pkgs/gcc/patch/binutils/bfd/config.bfd delete mode 100644 cross/pkgs/gcc/patch/binutils/gas/configure.tgt delete mode 100644 cross/pkgs/gcc/patch/binutils/ld/Makefile.am delete mode 100644 cross/pkgs/gcc/patch/binutils/ld/configure.tgt delete mode 100644 cross/pkgs/gcc/patch/binutils/ld/emulparams/elf_i386_jehanne.sh delete mode 100644 cross/pkgs/gcc/patch/binutils/ld/emulparams/elf_x86_64_jehanne.sh delete mode 100644 cross/pkgs/gcc/patch/gcc.patch delete mode 100644 cross/pkgs/gcc/patch/gcc/gcc/config/jehanne.h delete mode 100644 cross/pkgs/gcc/patch/libgmp.patch delete mode 100644 cross/pkgs/gcc/patch/libmpc.patch delete mode 100644 cross/pkgs/gcc/patch/libmpfr.patch diff --git a/cross/native.sh b/cross/native.sh deleted file mode 100755 index 6ccc035..0000000 --- a/cross/native.sh +++ /dev/null @@ -1,178 +0,0 @@ -#!/bin/bash - -echo "Cross compiling GCC and dependencies" - -JEHANNE_TOOLCHAIN=$JEHANNE_TOOLCHAIN -CROSS_DIR="$JEHANNE/hacking/cross" -LOG="$JEHANNE_TOOLCHAIN/native.build.log" - -export LD_PRELOAD= - -OPATH=$PATH -export PATH="$CROSS_DIR/wrappers:$PATH" - -function failOnError { - # $1 -> exit status on a previous command - # $2 -> task description - if [ $1 -ne 0 ]; then - echo "ERROR $2" - echo - echo BUILD LOG: - echo - cat $LOG - exit $1 - fi -} - -date > $LOG - -# mock makeinfo (to avoid it as a dependency) -rm -f $JEHANNE/hacking/bin/makeinfo -ln -s `which echo` $JEHANNE/hacking/bin/makeinfo - -# verify libtool is installed -libtool --version >> /dev/null -failOnError $? "libtool installation check" - -(cd $JEHANNE_TOOLCHAIN/src && fetch) >> $LOG -failOnError $? "fetching sources" - - - -echo -n Building libstdc++-v3... | tee -a $LOG -# libstdc++-v3 is part of GCC but must be built after newlib. -( - export GCC_BUILD_DIR=$JEHANNE_TOOLCHAIN/build/gcc && - mkdir -p $GCC_BUILD_DIR && - rm -fr $JEHANNE_TOOLCHAIN/src/gcc/isl-0.18.tar.bz2 && - rm -fr $JEHANNE_TOOLCHAIN/src/gcc/isl-0.18 && - rm -fr $JEHANNE_TOOLCHAIN/src/gcc/isl && - rm -fr $JEHANNE_TOOLCHAIN/src/gcc/gmp-6.1.0.tar.bz2 && - rm -fr $JEHANNE_TOOLCHAIN/src/gcc/gmp-6.1.0 && - rm -fr $JEHANNE_TOOLCHAIN/src/gcc/gmp && - rm -fr $JEHANNE_TOOLCHAIN/src/gcc/mpfr-3.1.4.tar.bz2 && - rm -fr $JEHANNE_TOOLCHAIN/src/gcc/mpfr-3.1.4 && - rm -fr $JEHANNE_TOOLCHAIN/src/gcc/mpfr && - rm -fr $JEHANNE_TOOLCHAIN/src/gcc/mpc-1.0.3.tar.gz && - rm -fr $JEHANNE_TOOLCHAIN/src/gcc/mpc-1.0.3 && - rm -fr $JEHANNE_TOOLCHAIN/src/gcc/mpc && - cd $GCC_BUILD_DIR && - mkdir -p $GCC_BUILD_DIR/x86_64-jehanne/libstdc++-v3 && - cd $GCC_BUILD_DIR/x86_64-jehanne/libstdc++-v3 && - rm -f config.cache && - $JEHANNE_TOOLCHAIN/src/gcc/libstdc++-v3/configure --srcdir=$JEHANNE_TOOLCHAIN/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 -failOnError $? "building libstdc++-v3" -echo done. - -# Copy to /posix (to emulate bind during cross compilation) -cp -pfr $JEHANNE/pkgs/libstdc++-v3/9.2.0/posix/* $JEHANNE/posix -find $JEHANNE/posix/|grep '\.la$'|xargs rm - -echo -n Building libgmp... | tee -a $LOG -( - cd $JEHANNE_TOOLCHAIN/src/libgmp && - ( grep -q jehanne configfsf.sub || patch -p0 < $CROSS_DIR/patch/libgmp.patch ) && - ./configure --host=x86_64-jehanne --disable-shared --prefix=/posix --with-sysroot=$JEHANNE && - make && - make DESTDIR=$JEHANNE/pkgs/libgmp/6.1.2/ install && - libtool --mode=finish $JEHANNE/posix/lib -) >> $LOG 2>&1 -failOnError $? "Building libgmp" -echo done. - -# Copy to /posix (to emulate bind during cross compilation) -cp -pfr $JEHANNE/pkgs/libgmp/6.1.2/posix/* $JEHANNE/posix -rm $JEHANNE/posix/lib/*.la - -echo -n Building libmpfr... | tee -a $LOG -( - cd $JEHANNE_TOOLCHAIN/src/libmpfr && - ( grep -q jehanne config.sub || patch -p0 < $CROSS_DIR/patch/libmpfr.patch ) && - ./configure --host=x86_64-jehanne --disable-shared --prefix=/posix --with-sysroot=$JEHANNE --with-gmp=$JEHANNE/posix/ && - cp $CROSS_DIR/patch/MakeNothing.in doc/Makefile.in && - make && - make DESTDIR=$JEHANNE/pkgs/libmpfr/4.0.1/ install && - libtool --mode=finish $JEHANNE/posix/lib -) >> $LOG 2>&1 -failOnError $? "Building libmpfr" -echo done. - -# Copy to /posix (to emulate bind during cross compilation) -cp -pfr $JEHANNE/pkgs/libmpfr/4.0.1/posix/* $JEHANNE/posix -rm $JEHANNE/posix/lib/*.la - -echo -n Building libmpc... | tee -a $LOG -( - cd $JEHANNE_TOOLCHAIN/src/libmpc && - ( grep -q jehanne config.sub || ( chmod u+w config.sub && - patch -p0 < $CROSS_DIR/patch/libmpc.patch && - chmod u-w config.sub ) ) && - ./configure --host=x86_64-jehanne --disable-shared --prefix=/posix --with-sysroot=$JEHANNE --with-gmp=$JEHANNE/posix/ --with-mpfr=$JEHANNE/posix/ && - cp $CROSS_DIR/patch/MakeNothing.in doc/Makefile.in && - make && - make DESTDIR=$JEHANNE/pkgs/libmpc/1.1.0/ install && - libtool --mode=finish $JEHANNE/posix/lib -) >> $LOG 2>&1 -failOnError $? "Building libmpc" -echo done. - -# Copy to /posix (to emulate bind during cross compilation) -cp -pfr $JEHANNE/pkgs/libmpc/1.1.0/posix/* $JEHANNE/posix -rm $JEHANNE/posix/lib/*.la - -echo -n Building binutils... | tee -a $LOG - - -# Patch and build binutils -if [ "$BINUTILS_BUILD_DIR" = "" ]; then - export BINUTILS_BUILD_DIR=$JEHANNE_TOOLCHAIN/build/binutils-native -fi -if [ ! -d $BINUTILS_BUILD_DIR ]; then - mkdir $BINUTILS_BUILD_DIR -fi -( - export LIBS="-L$JEHANNE/posix/lib -L$JEHANNE/arch/amd64/lib -lmpc -lmpfr -lgmp" && - export CC_FOR_BUILD='CPATH="" LIBS="" gcc' && - mkdir -p $BINUTILS_BUILD_DIR && cd $BINUTILS_BUILD_DIR && - $JEHANNE_TOOLCHAIN/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 $JEHANNE_TOOLCHAIN/src/binutils/bfd/doc/Makefile.in && - cp $CROSS_DIR/patch/MakeNothing.in $JEHANNE_TOOLCHAIN/src/binutils/bfd/po/Makefile.in && - cp $CROSS_DIR/patch/MakeNothing.in $JEHANNE_TOOLCHAIN/src/binutils/gas/doc/Makefile.in && - cp $CROSS_DIR/patch/MakeNothing.in $JEHANNE_TOOLCHAIN/src/binutils/binutils/doc/Makefile.in && - make && - make DESTDIR=$JEHANNE/pkgs/binutils/2.33.1/ install -) >> $LOG 2>&1 -failOnError $? "Building binutils" - -echo done. - -# Copy to /posix (to emulate bind during cross compilation) -cp -pfr $JEHANNE/pkgs/binutils/2.33.1/posix/* $JEHANNE/posix -rm $JEHANNE/posix/lib/*.la - -echo -n "Building gcc (and libgcc)..." | tee -a $LOG -( - export GCC_BUILD_DIR=$JEHANNE_TOOLCHAIN/build/gcc-native && - mkdir -p $GCC_BUILD_DIR && - cd $GCC_BUILD_DIR && - $JEHANNE_TOOLCHAIN/src/gcc/configure \ - --build=x86_64-pc-linux-gnu --host=x86_64-jehanne --target=x86_64-jehanne \ - --enable-languages=c,c++ \ - --prefix=/posix --with-sysroot=/ --with-build-sysroot=$JEHANNE \ - --without-isl --with-gmp=$JEHANNE/posix --with-mpfr=$JEHANNE/posix --with-mpc=$JEHANNE/posix \ - --disable-multiarch --disable-multilib \ - --disable-shared --disable-threads --disable-tls \ - --disable-libgomp --disable-werror --disable-nls && - make all-gcc && - make DESTDIR=$JEHANNE/pkgs/gcc/9.2.0/ install-gcc && - make all-target-libgcc && - make DESTDIR=$JEHANNE/pkgs/gcc/9.2.0/ install-target-libgcc -) >> $LOG 2>&1 -failOnError $? "building gcc" - -cp -pfr $JEHANNE/pkgs/gcc/9.2.0/posix/* $JEHANNE/posix - -echo "done." diff --git a/cross/pkgs/gcc/patch/binutils/bfd/config.bfd b/cross/pkgs/gcc/patch/binutils/bfd/config.bfd deleted file mode 100644 index d707602..0000000 --- a/cross/pkgs/gcc/patch/binutils/bfd/config.bfd +++ /dev/null @@ -1,7 +0,0 @@ -#ifdef BFD64 - x86_64-*-jehanne*) - targ_defvec=x86_64_elf64_vec - targ_selvecs=i386_elf32_vec - want64=true - ;; -#endif diff --git a/cross/pkgs/gcc/patch/binutils/gas/configure.tgt b/cross/pkgs/gcc/patch/binutils/gas/configure.tgt deleted file mode 100644 index 238f7e8..0000000 --- a/cross/pkgs/gcc/patch/binutils/gas/configure.tgt +++ /dev/null @@ -1,3 +0,0 @@ - i386-*-jehanne*) fmt=elf em=gnu ;; - - diff --git a/cross/pkgs/gcc/patch/binutils/ld/Makefile.am b/cross/pkgs/gcc/patch/binutils/ld/Makefile.am deleted file mode 100644 index 35a321e..0000000 --- a/cross/pkgs/gcc/patch/binutils/ld/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -eelf_i386_jehanne.c: $(srcdir)/emulparams/elf_i386_jehanne.sh \ - $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} - ${GENSCRIPTS} elf_i386_jehanne "$(tdir_elf_i386_jehanne)" - -eelf_x86_64_jehanne.c: $(srcdir)/emulparams/elf_x86_64_jehanne.sh \ - $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} - ${GENSCRIPTS} elf_x86_64_jehanne "$(tdir_elf_x86_64_jehanne)" - diff --git a/cross/pkgs/gcc/patch/binutils/ld/configure.tgt b/cross/pkgs/gcc/patch/binutils/ld/configure.tgt deleted file mode 100644 index 27ef033..0000000 --- a/cross/pkgs/gcc/patch/binutils/ld/configure.tgt +++ /dev/null @@ -1,25 +0,0 @@ -diff --git a/src/binutils/ld/configure.tgt b/src/binutils/ld/configure.tgt -index fad8b2e..ba3ddc9 100644 ---- a/src/binutils/ld/configure.tgt -+++ b/src/binutils/ld/configure.tgt -@@ -370,6 +370,9 @@ targ_extra_emuls="elf_i386_nacl elf_x86_64_nacl armelf_nacl armelfb_nacl" - targ_extra_libpath=$targ_extra_emuls - tdir_elf_i386_nacl=`echo ${targ_alias} | sed -e 's/x86_64/i386/'` - ;; -+x86_64*-jehanne*) targ_emul=elf_x86_64_jehanne -+ targ_extra_emuls="elf_i386_jehanne elf_x86_64 elf_i386" -+ ;; - ia16-*-elf*) targ_emul=elf_i386 targ_extra_emuls=i386msdos ;; - ia64-*-elf*) targ_emul=elf64_ia64 ;; - ia64-*-freebsd* | ia64-*-kfreebsd*-gnu) -@@ -806,6 +809,10 @@ ia64-*-aix*) - NATIVE_LIB_DIRS='/usr/local/lib /usr/lib/ia64l64 /lib /usr/lib' - ;; - -+x86_64-*-jehanne*) -+ NATIVE_LIB_DIRS='/arch/amd64/lib' -+ ;; -+ - sparc*-*-solaris2*) - NATIVE_LIB_DIRS='/usr/local/lib /usr/ccs/lib /lib /usr/lib' - ;; diff --git a/cross/pkgs/gcc/patch/binutils/ld/emulparams/elf_i386_jehanne.sh b/cross/pkgs/gcc/patch/binutils/ld/emulparams/elf_i386_jehanne.sh deleted file mode 100644 index 54decda..0000000 --- a/cross/pkgs/gcc/patch/binutils/ld/emulparams/elf_i386_jehanne.sh +++ /dev/null @@ -1,4 +0,0 @@ -. ${srcdir}/emulparams/elf_i386.sh -GENERATE_SHLIB_SCRIPT= -GENERATE_PIE_SCRIPT=yes -ENTRY=_main diff --git a/cross/pkgs/gcc/patch/binutils/ld/emulparams/elf_x86_64_jehanne.sh b/cross/pkgs/gcc/patch/binutils/ld/emulparams/elf_x86_64_jehanne.sh deleted file mode 100644 index dd2b5c7..0000000 --- a/cross/pkgs/gcc/patch/binutils/ld/emulparams/elf_x86_64_jehanne.sh +++ /dev/null @@ -1,4 +0,0 @@ -. ${srcdir}/emulparams/elf_x86_64.sh -GENERATE_SHLIB_SCRIPT= -GENERATE_PIE_SCRIPT=yes -ENTRY=_main diff --git a/cross/pkgs/gcc/patch/gcc.patch b/cross/pkgs/gcc/patch/gcc.patch deleted file mode 100644 index ccf70e4..0000000 --- a/cross/pkgs/gcc/patch/gcc.patch +++ /dev/null @@ -1,71 +0,0 @@ -diff --git a/src/gcc/gcc/config.gcc b/src/gcc/gcc/config.gcc -index f02ddbd..e5ebfe0 100644 ---- a/src/gcc/gcc/config.gcc -+++ b/src/gcc/gcc/config.gcc -@@ -862,6 +862,16 @@ case ${target} in - tmake_file="$tmake_file vms/t-vmsnative" - fi - ;; -+*-*-jehanne*) -+ gas=yes -+ gnu_ld=yes -+ default_use_cxa_atexit=yes -+ case $target in -+ x86_64-*) -+ native_system_header_dir="/arch/amd64/include" -+ ;; -+ esac -+ ;; - *-*-vxworks*) - tmake_file=t-vxworks - xm_defines=POSIX -@@ -1347,6 +1357,9 @@ x86_64-*-darwin*) - 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" -+ ;; - 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/src/gcc/config.sub b/src/gcc/config.sub -index 75bb6a3..1905540 100755 ---- a/src/gcc/config.sub -+++ b/src/gcc/config.sub -@@ -1363,7 +1363,7 @@ case $os in - | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \ - | skyos* | haiku* | rdos* | toppers* | drops* | es* \ - | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ -- | midnightbsd* | amdhsa* | unleashed* | emscripten*) -+ | jehanne* | midnightbsd* | amdhsa* | unleashed* | emscripten*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - qnx*) -diff --git a/src/gcc/fixincludes/mkfixinc.sh b/src/gcc/fixincludes/mkfixinc.sh -index 0f96486..9f0ee74 100755 ---- a/src/gcc/fixincludes/mkfixinc.sh -+++ b/src/gcc/fixincludes/mkfixinc.sh -@@ -14,6 +14,7 @@ case $machine in - i?86-*-cygwin* | \ - i?86-*-mingw32* | \ - x86_64-*-mingw32* | \ -+ *-jehanne* | \ - powerpc-*-eabisim* | \ - powerpc-*-eabi* | \ - powerpc-*-rtems* | \ -diff --git a/src/gcc/libgcc/config.host b/src/gcc/libgcc/config.host -index 91abc84..a994e3a 100644 ---- a/src/gcc/libgcc/config.host -+++ b/src/gcc/libgcc/config.host -@@ -1414,6 +1414,10 @@ nvptx-*) - tmake_file="$tmake_file nvptx/t-nvptx" - extra_parts="crt0.o" - ;; -+x86_64-*-jehanne*) -+ extra_parts="$extra_parts crtbegin.o crtend.o" -+ tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic" -+ ;; - *) - echo "*** Configuration ${host} not supported" 1>&2 - exit 1 diff --git a/cross/pkgs/gcc/patch/gcc/gcc/config/jehanne.h b/cross/pkgs/gcc/patch/gcc/gcc/config/jehanne.h deleted file mode 100644 index 7f99e6c..0000000 --- a/cross/pkgs/gcc/patch/gcc/gcc/config/jehanne.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * This file is part of Jehanne. - * - * Copyright (C) 2016-2019 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 . - */ - -#undef TARGET_JEHANNE -#define TARGET_JEHANNE 1 - -/* Default arguments you want when running x86_64-jehanne-gcc */ -#undef LIB_SPEC -#define LIB_SPEC "-lc" - -#undef STANDARD_STARTFILE_PREFIX -#define STANDARD_STARTFILE_PREFIX "/arch/amd64/lib/" - -#undef MD_STARTFILE_PREFIX -#define MD_STARTFILE_PREFIX "/arch/amd64/lib/" - -#undef GPLUSPLUS_INCLUDE_DIR -#define GPLUSPLUS_INCLUDE_DIR "/posix/g++" - -#undef GCC_INCLUDE_DIR -#define GCC_INCLUDE_DIR "/posix/gcc" - -/* Architecture specific header (u.h) goes here (from config.gcc) */ -#define ARCH_INCLUDE_DIR NATIVE_SYSTEM_HEADER_DIR - -/* The default include dir is /sys/include but... */ -#define PORTABLE_INCLUDE_DIR "/sys/include" - -#define POSIX_INCLUDE_DIR "/posix/include" - -/* ...we have to wrap libc.h and stdio.h with basic POSIX headers */ -#define BASIC_POSIX_INCLUDE_DIR "/sys/include/apw" - -#undef INCLUDE_DEFAULTS -#define INCLUDE_DEFAULTS \ - { \ - { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, 1, 0 }, \ - { GCC_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ - { POSIX_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ - { BASIC_POSIX_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ - { ARCH_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ - { PORTABLE_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ - { ".", 0, 0, 0, 1, 0 }, \ - { 0, 0, 0, 0, 0, 0 } \ - } - -/* Files that are linked before user code. - The %s tells gcc to look for these files in the library directory. */ -#undef STARTFILE_SPEC -#define STARTFILE_SPEC "crt0.o%s crti.o%s crtbegin.o%s" - -/* Files that are linked after user code. */ -#undef ENDFILE_SPEC -#define ENDFILE_SPEC "crtend.o%s crtn.o%s" - -/* Fix https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67132 */ -#undef WCHAR_TYPE -#define WCHAR_TYPE "unsigned int" -#undef WCHAR_TYPE_SIZE -#define WCHAR_TYPE_SIZE 32 - -#undef LINK_GCC_C_SEQUENCE_SPEC -#define LINK_GCC_C_SEQUENCE_SPEC "%G %L" - -/* Additional predefined macros. */ -#undef TARGET_OS_CPP_BUILTINS -#define TARGET_OS_CPP_BUILTINS() \ - do { \ - builtin_define ("__jehanne__"); \ - builtin_assert ("system=jehanne"); \ - } while(0); diff --git a/cross/pkgs/gcc/patch/libgmp.patch b/cross/pkgs/gcc/patch/libgmp.patch deleted file mode 100644 index 7a33851..0000000 --- a/cross/pkgs/gcc/patch/libgmp.patch +++ /dev/null @@ -1,11 +0,0 @@ -diff -Naru ../orig/configfsf.sub ./configfsf.sub ---- ../orig/configfsf.sub 2018-11-26 11:59:08.897396848 +0100 -+++ ./configfsf.sub 2018-11-26 12:20:10.079672849 +0100 -@@ -1399,6 +1399,7 @@ - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ -+ | -jehanne* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; diff --git a/cross/pkgs/gcc/patch/libmpc.patch b/cross/pkgs/gcc/patch/libmpc.patch deleted file mode 100644 index b207673..0000000 --- a/cross/pkgs/gcc/patch/libmpc.patch +++ /dev/null @@ -1,11 +0,0 @@ -diff -Naru ../orig/config.sub ./config.sub ---- ../orig/config.sub 2018-11-27 00:30:59.807843647 +0100 -+++ ./config.sub 2018-11-27 00:32:49.224841688 +0100 -@@ -1393,6 +1393,7 @@ - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ -+ | -jehanne* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; diff --git a/cross/pkgs/gcc/patch/libmpfr.patch b/cross/pkgs/gcc/patch/libmpfr.patch deleted file mode 100644 index 74f3e61..0000000 --- a/cross/pkgs/gcc/patch/libmpfr.patch +++ /dev/null @@ -1,11 +0,0 @@ -diff -Naru ../orig/config.sub ./config.sub ---- ../orig/config.sub 2018-11-26 14:23:59.224388851 +0100 -+++ ./config.sub 2018-11-26 14:24:55.300412850 +0100 -@@ -1416,6 +1416,7 @@ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ -+ | -jehanne* \ - | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; From 7278b664fcab86fc990ebbcdb4f783fe91c2fd14 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Wed, 2 Sep 2020 18:52:23 +0200 Subject: [PATCH 86/91] gcc: fix `--posixly` management in cross compiler --- cross/patch/gcc/gcc/config/jehanne.h | 44 +++++++++++++++++----------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/cross/patch/gcc/gcc/config/jehanne.h b/cross/patch/gcc/gcc/config/jehanne.h index afa2597..cdbbe64 100644 --- a/cross/patch/gcc/gcc/config/jehanne.h +++ b/cross/patch/gcc/gcc/config/jehanne.h @@ -18,23 +18,6 @@ #undef TARGET_JEHANNE #define TARGET_JEHANNE 1 -/* -#undef DRIVER_SELF_SPECS -#define DRIVER_SELF_SPECS "%{-posixly}" -*/ - -/* GCC on Jehanne includes and link libraries from /sys and /arch. - * To ease the port of POSIX applications, we include a --posixly option - * to the GCC driver that will be substituted with proper options - */ -#undef CPP_SPEC -#define CPP_SPEC "%{-posixly:-isystem/posix/include}" - -#undef LINK_SPEC -#define LINK_SPEC "%{-posixly:-L/posix/lib}" - -#undef LIB_SPEC -#define LIB_SPEC "%{-posixly:%{!shared:%{g*:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}} -ljehanne" #undef STANDARD_STARTFILE_PREFIX @@ -79,9 +62,13 @@ # define ID_PREFIX #endif #if defined (CROSS_INCLUDE_DIR) && defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT) +# define JEHANNE_POSIX_INCLUDE_DIR "%:getenv(JEHANNE /posix/include/)" +# define JEHANNE_POSIX_LIB_DIR "%:getenv(JEHANNE /posix/lib/)" # define ID_CROSS { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0 }, #else # define ID_CROSS +# define JEHANNE_POSIX_INCLUDE_DIR "/posix/include/" +# define JEHANNE_POSIX_LIB_DIR "/posix/lib/" #endif #ifdef TOOL_INCLUDE_DIR /* Another place the target system's headers might be. */ @@ -108,6 +95,29 @@ /* GCC include paths definition END */ +/* GCC on Jehanne includes and link libraries from /sys and /arch. + * To ease the port of POSIX applications, we include a --posixly option + * to the GCC driver that will be substituted with proper options + */ + +#ifdef CROSS_DIRECTORY_STRUCTURE +# define JEHANNE_POSIX_INCLUDE_DIR "%:getenv(JEHANNE /posix/include/)" +# define JEHANNE_POSIX_LIB_DIR "%:getenv(JEHANNE /posix/lib/)" +#else +# define JEHANNE_POSIX_INCLUDE_DIR "/posix/include/" +# define JEHANNE_POSIX_LIB_DIR "/posix/lib/" +#endif + +#undef CPP_SPEC +#define CPP_SPEC "%{-posixly:-isystem" JEHANNE_POSIX_INCLUDE_DIR "}" + +#undef LINK_SPEC +#define LINK_SPEC "%{-posixly:-L" JEHANNE_POSIX_LIB_DIR "}" + +#undef LIB_SPEC +#define LIB_SPEC "%{-posixly:%{!shared:%{g*:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}} -ljehanne" + + /* Files that are linked before user code. The %s tells gcc to look for these files in the library directory. */ #undef STARTFILE_SPEC From 48f5a46734925446085d8788a419ad0dc8111cb8 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Wed, 2 Sep 2020 18:53:45 +0200 Subject: [PATCH 87/91] gcc: fix cross/patch/gcc.patch --- cross/patch/gcc.patch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cross/patch/gcc.patch b/cross/patch/gcc.patch index bc4239d..3c0fcd1 100644 --- a/cross/patch/gcc.patch +++ b/cross/patch/gcc.patch @@ -2,7 +2,7 @@ diff --git a/src/gcc/gcc/config.gcc b/src/gcc/gcc/config.gcc index ddd3b8f..702aa59 100644 --- a/src/gcc/gcc/config.gcc +++ b/src/gcc/gcc/config.gcc -@@ -947,6 +947,18 @@ case ${target} in +@@ -947,6 +947,17 @@ case ${target} in tmake_file="$tmake_file vms/t-vmsnative" fi ;; @@ -20,7 +20,7 @@ index ddd3b8f..702aa59 100644 *-*-vxworks*) tmake_file=t-vxworks xm_defines=POSIX -@@ -1635,6 +1648,9 @@ i[34567]86-*-elfiamcu) +@@ -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" ;; From 8e890d973c0a91e82214fe20baf1b157115222f6 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Thu, 3 Sep 2020 00:58:28 +0200 Subject: [PATCH 88/91] continuous-build.sh: update GCC version and paths --- continuous-build.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/continuous-build.sh b/continuous-build.sh index b29c9af..bc660c0 100755 --- a/continuous-build.sh +++ b/continuous-build.sh @@ -6,11 +6,19 @@ set -e +cd `dirname $0` +cd .. +export JEHANNE=`pwd` +REPONAME=`basename $JEHANNE` +export JEHANNE_TOOLCHAIN=`dirname $JEHANNE` +export JEHANNE_TOOLCHAIN="$JEHANNE_TOOLCHAIN/$REPONAME.TOOLCHAIN" +CROSS_TOOLCHAIN=$JEHANNE_TOOLCHAIN/cross/posix + function finish { if [ "$TRAVIS_BUILD_DIR" != "" ]; then # ensure that we preserve the toolchain on broken build/test - if [ -f "$JEHANNE/hacking/cross/toolchain/bin/x86_64-jehanne-gcc" ]; then - mv $JEHANNE/hacking/cross/toolchain/* $JEHANNE/tmp/toolchain/ + if [ -f "$CROSS_TOOLCHAIN/bin/x86_64-jehanne-gcc" ]; then + mv $CROSS_TOOLCHAIN/* $JEHANNE/tmp/toolchain/ fi fi (cd $JEHANNE/hacking; git clean -xdf disk-setup/; git checkout disk-setup/syslinux.cfg) @@ -18,17 +26,14 @@ function finish { trap finish EXIT if [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then - cd `dirname $0` - cd .. - export JEHANNE=`pwd` - CROSS_TOOLCHAIN=$JEHANNE/hacking/cross/toolchain + export PATH="$JEHANNE/hacking/bin:$PATH" export PATH="$CROSS_TOOLCHAIN/bin:$PATH" export ARCH=amd64 # since our cross compiler is inside the system root, we need this too # as it can't find it's own headers - export CPATH=$CROSS_TOOLCHAIN/lib/gcc/x86_64-jehanne/4.9.4/include:$CROSS_TOOLCHAIN/lib/gcc/x86_64-jehanne/4.9.4/include-fixed + export CPATH=$CROSS_TOOLCHAIN/lib/gcc/x86_64-jehanne/9.2.0/include:$CROSS_TOOLCHAIN/lib/gcc/x86_64-jehanne/9.2.0/include-fixed git clean -xdf arch/ sys/ qa/ usr/ if [ ! -f "$JEHANNE/hacking/bin/ufs" ]; then From f598a59d815dd5c0f3b5a229d733c068006e1a8b Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Sun, 6 Sep 2020 12:22:33 +0200 Subject: [PATCH 89/91] gcc: remove `--posixly`, add `-9` The GCC option `--posixly` was introduced to enable the compilation of POSIX code in Jehanne, assuming that building native C code would have been the default. However since - GCC is itself a POSIX program and most programmers that use it assume a POSIX environment - GCC is used as a cross compiler to build Jehanne from POSIX systems - C++ will never be native in Jehanne (too much complexity for a system that want to be simple) and thus will always require a POSIX environment to build POSIX C++ code I decided to invert the logic. Thus now by default GCC, by default, will build POSIX programs, loading required libraries and headers from /posix subdirectories. The new option `-9` will remove such POSIX stuff when compiling native C programs. --- cross/patch/gcc/gcc/config/jehanne.h | 168 ++++++++++++++++--------- cross/patch/gcc/gcc/config/jehanne.opt | 6 +- 2 files changed, 114 insertions(+), 60 deletions(-) diff --git a/cross/patch/gcc/gcc/config/jehanne.h b/cross/patch/gcc/gcc/config/jehanne.h index cdbbe64..102350b 100644 --- a/cross/patch/gcc/gcc/config/jehanne.h +++ b/cross/patch/gcc/gcc/config/jehanne.h @@ -19,103 +19,151 @@ #undef TARGET_JEHANNE #define TARGET_JEHANNE 1 - -#undef STANDARD_STARTFILE_PREFIX -#define STANDARD_STARTFILE_PREFIX "/arch/amd64/lib/" - -/* GCC include paths definition START +/* In Jehanne, GCC has to be able to build two different kind of programs + * - native, directly repending on Jehanne's development environment + * - posix, based on the mainstream standards + * + * LibPOSIX exists to enable, together with a standard library + * (newlib, so far) the cooperation of these two worlds. + * + * By default, GCC will compile POSIX software looking for standard + * libraries and includes in /posix subfolders. + * However, the new option `-9` will enable the compilation of + * native programs by REMOVING the POSIX stuffs from the various Specs. */ /* Architecture specific header (u.h) goes here (from config.gcc) */ #define ARCH_INCLUDE_DIR NATIVE_SYSTEM_HEADER_DIR -/* The default include dir is /sys/include */ #define PORTABLE_INCLUDE_DIR "/sys/include" +/* C++ : only define values for INCLUDE_DEFAULTS */ #ifdef GPLUSPLUS_INCLUDE_DIR - /* Pick up GNU C++ generic include files. */ -# define ID_GPLUSPLUS { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, +# define JEHANNE_ID_GPLUSPLUS { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, #else -# define ID_GPLUSPLUS +# define JEHANNE_ID_GPLUSPLUS #endif #ifdef GPLUSPLUS_TOOL_INCLUDE_DIR - /* Pick up GNU C++ target-dependent include files. */ -# define ID_GPLUSPLUS_TOOL { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, +# define JEHANNE_ID_GPLUSPLUS_TOOL { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, #else -# define ID_GPLUSPLUS_TOOL +# define JEHANNE_ID_GPLUSPLUS_TOOL #endif #ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR - /* Pick up GNU C++ backward and deprecated include files. */ -# define ID_GPLUSPLUS_BACKWARD { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, +# define JEHANNE_ID_GPLUSPLUS_BACKWARD { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, #else -# define ID_GPLUSPLUS_BACKWARD +# define JEHANNE_ID_GPLUSPLUS_BACKWARD #endif + +/* GCC's private headers. */ #ifdef GCC_INCLUDE_DIR - /* This is the dir for gcc's private headers. */ -# define ID_GCC { GCC_INCLUDE_DIR, "GCC", 0, 0, 0, 0 }, +# define JEHANNE_IS_GCC " -isystem" GCC_INCLUDE_DIR +# define JEHANNE_ID_GCC { GCC_INCLUDE_DIR, "GCC", 1, 0, 0, 0 }, #else -# define ID_GCC +# define JEHANNE_ID_GCC +# define JEHANNE_IS_GCC #endif + #ifdef PREFIX_INCLUDE_DIR -# define ID_PREFIX { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0 }, +# define JEHANNE_IS_PREFIX " -isystem" PREFIX_INCLUDE_DIR +# define JEHANNE_ID_PREFIX { PREFIX_INCLUDE_DIR, 0, 1, 1, 0, 0 }, #else -# define ID_PREFIX +# define JEHANNE_ID_PREFIX +# define JEHANNE_IS_PREFIX #endif + #if defined (CROSS_INCLUDE_DIR) && defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT) -# define JEHANNE_POSIX_INCLUDE_DIR "%:getenv(JEHANNE /posix/include/)" -# define JEHANNE_POSIX_LIB_DIR "%:getenv(JEHANNE /posix/lib/)" -# define ID_CROSS { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0 }, +# define JEHANNE_IS_CROSS " -isystem" CROSS_INCLUDE_DIR +# define JEHANNE_ID_CROSS { CROSS_INCLUDE_DIR, "GCC", 1, 0, 0, 0 }, #else -# define ID_CROSS -# define JEHANNE_POSIX_INCLUDE_DIR "/posix/include/" -# define JEHANNE_POSIX_LIB_DIR "/posix/lib/" +# define JEHANNE_ID_CROSS +# define JEHANNE_IS_CROSS #endif + +/* Binutils headers. */ #ifdef TOOL_INCLUDE_DIR - /* Another place the target system's headers might be. */ -# define ID_TOOL { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0 }, +# define JEHANNE_IS_TOOL " -isystem" TOOL_INCLUDE_DIR +# define JEHANNE_ID_TOOL { TOOL_INCLUDE_DIR, "BINUTILS", 1, 1, 0, 0 }, #else -# define ID_TOOL +# define JEHANNE_ID_TOOL +# define JEHANNE_IS_TOOL #endif -#undef INCLUDE_DEFAULTS -#define INCLUDE_DEFAULTS \ - { \ - ID_GPLUSPLUS \ - ID_GPLUSPLUS_TOOL \ - ID_GPLUSPLUS_BACKWARD \ - ID_GCC \ - ID_PREFIX \ - ID_CROSS \ - ID_TOOL \ - { PORTABLE_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ - { ARCH_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ - { 0, 0, 0, 0, 0, 0 } \ - } -/* GCC include paths definition END - */ - -/* GCC on Jehanne includes and link libraries from /sys and /arch. - * To ease the port of POSIX applications, we include a --posixly option - * to the GCC driver that will be substituted with proper options - */ +#define JEHANNE_POSIX_INCLUDE_DIR "/posix/include" +#define JEHANNE_ID_POSIX { JEHANNE_POSIX_INCLUDE_DIR, 0, 1, 0, 1, 0 }, #ifdef CROSS_DIRECTORY_STRUCTURE -# define JEHANNE_POSIX_INCLUDE_DIR "%:getenv(JEHANNE /posix/include/)" -# define JEHANNE_POSIX_LIB_DIR "%:getenv(JEHANNE /posix/lib/)" +# define JEHANNE_IS_POSIX " -isystem%:getenv(JEHANNE " JEHANNE_POSIX_INCLUDE_DIR ")" +# define JEHANNE_POSIX_LIB_DIR "%:getenv(JEHANNE /posix/lib)" #else -# define JEHANNE_POSIX_INCLUDE_DIR "/posix/include/" -# define JEHANNE_POSIX_LIB_DIR "/posix/lib/" +# define JEHANNE_IS_POSIX " -isystem" JEHANNE_POSIX_INCLUDE_DIR +# define JEHANNE_POSIX_LIB_DIR "/posix/lib" #endif + +/* INCLUDE_DEFAULTS is used by gcc/cppdefault.c + * The struct is defined in gcc/cppdefault.h + * + * struct default_include + * { + * const char *const fname; // The name of the directory. + * const char *const component; // The component containing the directory + * (see update_path in prefix.c) + * const char cplusplus; // Only look here if we're compiling C++. + * const char cxx_aware; // Includes in this directory don't need to + * be wrapped in extern "C" when compiling + * C++. + * const char add_sysroot; // FNAME should be prefixed by + * cpp_SYSROOT. + * const char multilib; // FNAME should have appended + * - the multilib path specified with -imultilib + * when set to 1, + * - the multiarch path specified with + * -imultiarch, when set to 2. + * }; + * + * Since C++ assumes a POSIX environment, we include all of the POSIX + * headers but with `cplusplus = 1`, to not mess native C compilation + * that have to react to the `-9` option. + */ +#undef INCLUDE_DEFAULTS +#define INCLUDE_DEFAULTS \ + { \ + JEHANNE_ID_GPLUSPLUS \ + JEHANNE_ID_GPLUSPLUS_TOOL \ + JEHANNE_ID_GPLUSPLUS_BACKWARD \ + JEHANNE_ID_GCC \ + JEHANNE_ID_POSIX \ + JEHANNE_ID_PREFIX \ + JEHANNE_ID_CROSS \ + JEHANNE_ID_TOOL \ + { PORTABLE_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ + { ARCH_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ + { 0, 0, 0, 0, 0, 0 } \ + } + +#undef EXTRA_SPECS +#define EXTRA_SPECS \ + { "posixly_isystems", JEHANNE_IS_GCC \ + JEHANNE_IS_POSIX \ + JEHANNE_IS_PREFIX \ + JEHANNE_IS_CROSS \ + JEHANNE_IS_TOOL }, \ + { "posixly_lib", "%{!shared:%{g*:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}} -lposix" }, + + +/* set CPLUSPLUS_CPP_SPEC to prevent the default fallback to CPP_SPEC */ +#define CPLUSPLUS_CPP_SPEC "" + +/* These Specs reacts `-9` option by removing POSIX stuff */ #undef CPP_SPEC -#define CPP_SPEC "%{-posixly:-isystem" JEHANNE_POSIX_INCLUDE_DIR "}" +#define CPP_SPEC "%{!9:%(posixly_isystems)}" #undef LINK_SPEC -#define LINK_SPEC "%{-posixly:-L" JEHANNE_POSIX_LIB_DIR "}" +#define LINK_SPEC "%{!9:-L" JEHANNE_POSIX_LIB_DIR "}" #undef LIB_SPEC -#define LIB_SPEC "%{-posixly:%{!shared:%{g*:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}} -ljehanne" +#define LIB_SPEC "%{!9:%(posixly_lib)} -ljehanne" /* Files that are linked before user code. @@ -126,6 +174,12 @@ /* Files that are linked after user code. */ #undef ENDFILE_SPEC #define ENDFILE_SPEC "crtend.o%s crtn.o%s" + +/* In Jehanne start files will be in /arch/amd64/lib, nearby libjehanne.a + */ +#undef STANDARD_STARTFILE_PREFIX +#define STANDARD_STARTFILE_PREFIX "/arch/amd64/lib/" + /* Fix https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67132 */ #undef WCHAR_TYPE diff --git a/cross/patch/gcc/gcc/config/jehanne.opt b/cross/patch/gcc/gcc/config/jehanne.opt index 50a8c80..26fe302 100644 --- a/cross/patch/gcc/gcc/config/jehanne.opt +++ b/cross/patch/gcc/gcc/config/jehanne.opt @@ -18,8 +18,8 @@ ; Please try to keep this file in ASCII collating order. --posixly -C ObjC C++ ObjC++ Driver RejectNegative -Lookup for POSIX includes and libraries in /posix +9 +C Driver RejectNegative +Do not lookup for POSIX includes and libraries in /posix ; This comment is to ensure we retain the blank line above. From bab840a4116c3fb71a0fe92680df42535b8a567b Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Thu, 10 Sep 2020 22:39:10 +0200 Subject: [PATCH 90/91] gcc: build works again --- cross/patch/gcc/gcc/config/jehanne.h | 138 +++++++++++++-------------- cross/pkgs/gcc/build.sh | 19 +++- cross/pkgs/newlib/build.sh | 16 ++-- cross/pkgs/newlib/src | 2 +- 4 files changed, 89 insertions(+), 86 deletions(-) diff --git a/cross/patch/gcc/gcc/config/jehanne.h b/cross/patch/gcc/gcc/config/jehanne.h index 102350b..fd63174 100644 --- a/cross/patch/gcc/gcc/config/jehanne.h +++ b/cross/patch/gcc/gcc/config/jehanne.h @@ -37,70 +37,6 @@ #define PORTABLE_INCLUDE_DIR "/sys/include" -/* C++ : only define values for INCLUDE_DEFAULTS */ -#ifdef GPLUSPLUS_INCLUDE_DIR -# define JEHANNE_ID_GPLUSPLUS { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, -#else -# define JEHANNE_ID_GPLUSPLUS -#endif -#ifdef GPLUSPLUS_TOOL_INCLUDE_DIR -# define JEHANNE_ID_GPLUSPLUS_TOOL { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, -#else -# define JEHANNE_ID_GPLUSPLUS_TOOL -#endif -#ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR -# define JEHANNE_ID_GPLUSPLUS_BACKWARD { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, -#else -# define JEHANNE_ID_GPLUSPLUS_BACKWARD -#endif - -/* GCC's private headers. */ -#ifdef GCC_INCLUDE_DIR -# define JEHANNE_IS_GCC " -isystem" GCC_INCLUDE_DIR -# define JEHANNE_ID_GCC { GCC_INCLUDE_DIR, "GCC", 1, 0, 0, 0 }, -#else -# define JEHANNE_ID_GCC -# define JEHANNE_IS_GCC -#endif - -#ifdef PREFIX_INCLUDE_DIR -# define JEHANNE_IS_PREFIX " -isystem" PREFIX_INCLUDE_DIR -# define JEHANNE_ID_PREFIX { PREFIX_INCLUDE_DIR, 0, 1, 1, 0, 0 }, -#else -# define JEHANNE_ID_PREFIX -# define JEHANNE_IS_PREFIX -#endif - -#if defined (CROSS_INCLUDE_DIR) && defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT) -# define JEHANNE_IS_CROSS " -isystem" CROSS_INCLUDE_DIR -# define JEHANNE_ID_CROSS { CROSS_INCLUDE_DIR, "GCC", 1, 0, 0, 0 }, -#else -# define JEHANNE_ID_CROSS -# define JEHANNE_IS_CROSS -#endif - -/* Binutils headers. */ -#ifdef TOOL_INCLUDE_DIR -# define JEHANNE_IS_TOOL " -isystem" TOOL_INCLUDE_DIR -# define JEHANNE_ID_TOOL { TOOL_INCLUDE_DIR, "BINUTILS", 1, 1, 0, 0 }, -#else -# define JEHANNE_ID_TOOL -# define JEHANNE_IS_TOOL -#endif - - -#define JEHANNE_POSIX_INCLUDE_DIR "/posix/include" -#define JEHANNE_ID_POSIX { JEHANNE_POSIX_INCLUDE_DIR, 0, 1, 0, 1, 0 }, - -#ifdef CROSS_DIRECTORY_STRUCTURE -# define JEHANNE_IS_POSIX " -isystem%:getenv(JEHANNE " JEHANNE_POSIX_INCLUDE_DIR ")" -# define JEHANNE_POSIX_LIB_DIR "%:getenv(JEHANNE /posix/lib)" -#else -# define JEHANNE_IS_POSIX " -isystem" JEHANNE_POSIX_INCLUDE_DIR -# define JEHANNE_POSIX_LIB_DIR "/posix/lib" -#endif - - /* INCLUDE_DEFAULTS is used by gcc/cppdefault.c * The struct is defined in gcc/cppdefault.h * @@ -126,6 +62,60 @@ * headers but with `cplusplus = 1`, to not mess native C compilation * that have to react to the `-9` option. */ + +/* C++ : only define values for INCLUDE_DEFAULTS */ +#ifdef GPLUSPLUS_INCLUDE_DIR +# define JEHANNE_ID_GPLUSPLUS { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, +#else +# define JEHANNE_ID_GPLUSPLUS +#endif +#ifdef GPLUSPLUS_TOOL_INCLUDE_DIR +# define JEHANNE_ID_GPLUSPLUS_TOOL { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, +#else +# define JEHANNE_ID_GPLUSPLUS_TOOL +#endif +#ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR +# define JEHANNE_ID_GPLUSPLUS_BACKWARD { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, +#else +# define JEHANNE_ID_GPLUSPLUS_BACKWARD +#endif + +/* GCC's private headers. */ +#ifdef GCC_INCLUDE_DIR +# define JEHANNE_ID_GCC { GCC_INCLUDE_DIR, "GCC", 0, 0, 0, 0 }, +#else +# define JEHANNE_ID_GCC +#endif + +#ifdef PREFIX_INCLUDE_DIR +# define JEHANNE_ID_PREFIX { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0 }, +#else +# define JEHANNE_ID_PREFIX +#endif + +#if defined (CROSS_INCLUDE_DIR) && defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT) +# define JEHANNE_ID_CROSS { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0 }, +#else +# define JEHANNE_ID_CROSS +#endif + +/* Binutils headers. */ +#ifdef TOOL_INCLUDE_DIR +# define JEHANNE_ID_TOOL { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0 }, +#else +# define JEHANNE_ID_TOOL +#endif + +#define JEHANNE_POSIX_INCLUDE_DIR "/posix/include" +#define JEHANNE_ID_POSIX { JEHANNE_POSIX_INCLUDE_DIR, 0, 0, 0, 1, 0 }, + +#ifdef CROSS_DIRECTORY_STRUCTURE +# define JEHANNE_POSIX_LIB_DIR "%:getenv(JEHANNE /posix/lib)" +#else +# define JEHANNE_POSIX_LIB_DIR "/posix/lib" +#endif + + #undef INCLUDE_DEFAULTS #define INCLUDE_DEFAULTS \ { \ @@ -144,20 +134,20 @@ #undef EXTRA_SPECS #define EXTRA_SPECS \ - { "posixly_isystems", JEHANNE_IS_GCC \ - JEHANNE_IS_POSIX \ - JEHANNE_IS_PREFIX \ - JEHANNE_IS_CROSS \ - JEHANNE_IS_TOOL }, \ { "posixly_lib", "%{!shared:%{g*:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}} -lposix" }, -/* set CPLUSPLUS_CPP_SPEC to prevent the default fallback to CPP_SPEC */ -#define CPLUSPLUS_CPP_SPEC "" - /* These Specs reacts `-9` option by removing POSIX stuff */ -#undef CPP_SPEC -#define CPP_SPEC "%{!9:%(posixly_isystems)}" +//#undef CPP_SPEC +//#define CPP_SPEC "%{!9:%(posixly_isystems)}" + +/* Since -nostdinc++ doesn't exclude C headers but we have cheated + * marking them as C++ headers, we need to add them back when + * this option is provided + */ +//#undef CPLUSPLUS_CPP_SPEC +//#define CPLUSPLUS_CPP_SPEC "%{nostdinc++:%(posixly_isystems)}" +//#define CPLUSPLUS_CPP_SPEC "" #undef LINK_SPEC #define LINK_SPEC "%{!9:-L" JEHANNE_POSIX_LIB_DIR "}" diff --git a/cross/pkgs/gcc/build.sh b/cross/pkgs/gcc/build.sh index 8d34770..58c6aef 100755 --- a/cross/pkgs/gcc/build.sh +++ b/cross/pkgs/gcc/build.sh @@ -76,15 +76,25 @@ echo -n Building libstdc++-v3... | tee -a $LOG mkdir -p $GCC_BUILD_DIR/x86_64-jehanne/libstdc++-v3 && cd $GCC_BUILD_DIR/x86_64-jehanne/libstdc++-v3 && rm -f config.cache && - $JEHANNE_TOOLCHAIN/src/gcc/libstdc++-v3/configure --srcdir=$JEHANNE_TOOLCHAIN/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 && + $JEHANNE_TOOLCHAIN/src/gcc/libstdc++-v3/configure \ + --srcdir=$JEHANNE_TOOLCHAIN/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 failOnError $? "building libstdc++-v3" echo done. +export PATH=$OPATH + # Copy to /posix (to emulate bind during cross compilation) -cp -pfr $JEHANNE/pkgs/libstdc++-v3/9.2.0/posix/* $JEHANNE/posix +cp -pfr $JEHANNE/pkgs/libstdc++-v3/9.2.0/posix/* $JEHANNE_TOOLCHAIN/cross/posix +cp -pfr $JEHANNE/pkgs/libstdc++-v3/9.2.0/posix/x86_64-jehanne/* $JEHANNE/posix find $JEHANNE/posix/|grep '\.la$'|xargs rm echo -n Building libgmp... | tee -a $LOG @@ -182,10 +192,11 @@ echo -n "Building gcc (and libgcc)..." | tee -a $LOG --disable-multiarch --disable-multilib \ --disable-shared --disable-threads --disable-tls \ --disable-libgomp --disable-werror --disable-nls && + make all-target-libgcc && + make DESTDIR=$JEHANNE/pkgs/gcc/9.2.0/ install-target-libgcc && make all-gcc && make DESTDIR=$JEHANNE/pkgs/gcc/9.2.0/ install-gcc && - make all-target-libgcc && - make DESTDIR=$JEHANNE/pkgs/gcc/9.2.0/ install-target-libgcc + echo ) >> $LOG 2>&1 failOnError $? "building gcc" diff --git a/cross/pkgs/newlib/build.sh b/cross/pkgs/newlib/build.sh index e6bcc38..f0abc18 100755 --- a/cross/pkgs/newlib/build.sh +++ b/cross/pkgs/newlib/build.sh @@ -61,13 +61,15 @@ function failOnError { function mergeLibPOSIX { TARGET_LIB=$1 - echo "Merging $JEHANNE/arch/$ARCH/lib/libposix.a into $TARGET_LIB." && - x86_64-jehanne-ar -M < Date: Sun, 13 Sep 2020 02:25:47 +0200 Subject: [PATCH 91/91] gcc: map `-9` to a few flags in DRIVER_SELF_SPECS --- cross/patch/gcc/gcc/config/jehanne.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cross/patch/gcc/gcc/config/jehanne.h b/cross/patch/gcc/gcc/config/jehanne.h index fd63174..aa81591 100644 --- a/cross/patch/gcc/gcc/config/jehanne.h +++ b/cross/patch/gcc/gcc/config/jehanne.h @@ -155,6 +155,7 @@ #undef LIB_SPEC #define LIB_SPEC "%{!9:%(posixly_lib)} -ljehanne" +#define DRIVER_SELF_SPECS "%{9:-fno-builtin -fno-omit-frame-pointer -fplan9-extensions -fvar-tracking -fvar-tracking-assignments}" /* Files that are linked before user code. The %s tells gcc to look for these files in the library directory. */