gcc native: almost there

This commit is contained in:
Giacomo Tesio 2019-11-08 01:43:04 +01:00
parent 8f6f592374
commit 23c117a97e
10 changed files with 104 additions and 154 deletions

View File

@ -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."

View File

@ -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

View File

@ -1,3 +0,0 @@
-jehanne*)
os=-jehanne
;;

View File

@ -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

View File

@ -1 +0,0 @@
*-jehanne* | \

View File

@ -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"
;;

View File

@ -1,7 +1,7 @@
/*
* This file is part of Jehanne.
*
* Copyright (C) 2016 Giacomo Tesio <giacomo@tesio.it>
* Copyright (C) 2016-2019 Giacomo Tesio <giacomo@tesio.it>
*
* 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"

View File

@ -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"
;;

View File

@ -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
}

View File

@ -1,6 +0,0 @@
*-jehanne*)
GLIBCXX_CHECK_COMPILER_FEATURES
GLIBCXX_CHECK_LINKER_FEATURES
GLIBCXX_CHECK_MATH_SUPPORT
GLIBCXX_CHECK_STDLIB_SUPPORT
;;