2022-10-08 13:35:39 +00:00
|
|
|
#!/usr/bin/env bash
|
2022-09-05 14:13:51 +00:00
|
|
|
set -e
|
|
|
|
source $(dirname $0)/setup-env.sh
|
|
|
|
|
|
|
|
cd $LUNA_ROOT
|
|
|
|
|
2022-10-02 10:21:02 +00:00
|
|
|
if [ ! -x $(command -v x86_64-luna-as) ]
|
2022-09-05 14:13:51 +00:00
|
|
|
then
|
|
|
|
echo Binutils should be cross-built before GCC.
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-10-02 10:47:50 +00:00
|
|
|
tools/install-headers.sh # install the LibC headers before building GCC
|
|
|
|
|
2022-09-05 14:13:51 +00:00
|
|
|
mkdir -p toolchain/tarballs
|
|
|
|
mkdir -p toolchain/build
|
|
|
|
|
|
|
|
if [ ! -f toolchain/tarballs/gcc-$LUNA_GCC_VERSION_REQUIRED.tar.xz ]; then
|
|
|
|
echo Downloading GCC...
|
|
|
|
|
|
|
|
wget -Otoolchain/tarballs/gcc-$LUNA_GCC_VERSION_REQUIRED.tar.xz https://ftp.gnu.org/gnu/gcc/gcc-$LUNA_GCC_VERSION_REQUIRED/gcc-$LUNA_GCC_VERSION_REQUIRED.tar.xz
|
|
|
|
fi
|
|
|
|
|
2022-10-02 17:58:52 +00:00
|
|
|
rm -rf toolchain/build/gcc
|
|
|
|
rm -rf toolchain/build/gcc-$LUNA_GCC_VERSION_REQUIRED
|
|
|
|
|
2022-09-05 14:13:51 +00:00
|
|
|
echo Extracting GCC...
|
|
|
|
|
|
|
|
tar xf toolchain/tarballs/gcc-$LUNA_GCC_VERSION_REQUIRED.tar.xz -C toolchain/build/
|
|
|
|
|
2022-10-02 10:47:50 +00:00
|
|
|
echo Patching GCC...
|
2022-10-02 10:21:02 +00:00
|
|
|
|
|
|
|
cd toolchain
|
|
|
|
|
2022-10-23 18:03:29 +00:00
|
|
|
patch -u -i $LUNA_ROOT/tools/gcc.patch -p 1 -d build | filter-lines "gcc" "patch"
|
2022-10-02 10:21:02 +00:00
|
|
|
|
|
|
|
cd -
|
|
|
|
|
2022-09-05 14:13:51 +00:00
|
|
|
echo Configuring GCC...
|
|
|
|
|
|
|
|
mkdir -p toolchain/build/gcc
|
|
|
|
|
|
|
|
cd toolchain/build/gcc
|
|
|
|
|
2022-10-02 17:58:52 +00:00
|
|
|
unset CC
|
|
|
|
unset CXX
|
2022-10-24 18:33:29 +00:00
|
|
|
unset LD
|
|
|
|
unset AR
|
2022-10-02 17:58:52 +00:00
|
|
|
|
2022-10-23 18:03:29 +00:00
|
|
|
../gcc-$LUNA_GCC_VERSION_REQUIRED/configure --prefix="$BUILD_PREFIX" --target=$BUILD_TARGET --disable-nls --with-sysroot=$BUILD_SYSROOT --enable-languages=c,c++ --without-headers | filter-lines "gcc" "configure"
|
2022-09-05 14:13:51 +00:00
|
|
|
|
|
|
|
echo Building GCC...
|
|
|
|
|
2022-10-23 18:03:29 +00:00
|
|
|
make all-gcc -j$(nproc) | filter-lines "gcc" "build"
|
|
|
|
make all-target-libgcc -j$(nproc) CFLAGS_FOR_TARGET='-g -O2 -mcmodel=large -mno-red-zone' | filter-lines "libgcc" "build"
|
2022-09-05 14:13:51 +00:00
|
|
|
|
|
|
|
echo Installing GCC...
|
|
|
|
|
2022-10-23 18:03:29 +00:00
|
|
|
make install-gcc | filter-lines "gcc" "install"
|
2022-11-09 10:56:08 +00:00
|
|
|
make install-target-libgcc | filter-lines "libgcc" "install"
|
|
|
|
|
|
|
|
echo Building libstdc++...
|
|
|
|
|
|
|
|
$LUNA_ROOT/tools/sync-libc.sh # libstdc++ needs libc to be built
|
2022-11-09 16:15:02 +00:00
|
|
|
make all-target-libstdc++-v3 CXXFLAGS_FOR_TARGET="-fno-exceptions" -j$(nproc) | filter-lines "libstdc++" "build"
|
2022-11-09 10:56:08 +00:00
|
|
|
|
|
|
|
echo Installing libstdc++...
|
|
|
|
|
2022-11-09 16:15:02 +00:00
|
|
|
make install-target-libstdc++-v3 | filter-lines "libstdc++" "install"
|