From 61806bacc92564a1632f9961ac8f74e6a3c5dbf8 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Tue, 5 Nov 2019 00:19:53 +0100 Subject: [PATCH] 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 + ;;