gcc native: add cross compilation of GCC to pkgs build (to setup proper POSIX headers in /posix)
This commit is contained in:
parent
ed6ae29834
commit
18da65783b
@ -1,8 +1,12 @@
|
||||
{
|
||||
"CrossCompiledPackages": {
|
||||
"Env": [
|
||||
"CROSS_PKGS_BUILD=1"
|
||||
],
|
||||
"Pre": [
|
||||
"./newlib/build.sh",
|
||||
"./mksh/build.sh"
|
||||
"./mksh/build.sh",
|
||||
"./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."
|
||||
|
Loading…
x
Reference in New Issue
Block a user