69 lines
1.8 KiB
Bash
Executable File
69 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -e
|
|
source $(dirname $0)/setup-env.sh
|
|
|
|
cd $LUNA_ROOT
|
|
|
|
if [ ! -x $(command -v x86_64-luna-as) ]
|
|
then
|
|
echo Binutils should be cross-built before GCC.
|
|
exit 1
|
|
fi
|
|
|
|
tools/install-headers.sh # install the LibC headers before building GCC
|
|
|
|
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
|
|
|
|
rm -rf toolchain/build/gcc
|
|
rm -rf toolchain/build/gcc-$LUNA_GCC_VERSION_REQUIRED
|
|
|
|
echo Extracting GCC...
|
|
|
|
tar xf toolchain/tarballs/gcc-$LUNA_GCC_VERSION_REQUIRED.tar.xz -C toolchain/build/
|
|
|
|
echo Patching GCC...
|
|
|
|
cd toolchain
|
|
|
|
patch -u -i $LUNA_ROOT/tools/gcc.patch -p 1 -d build | filter-lines "gcc" "patch"
|
|
|
|
cd -
|
|
|
|
echo Configuring GCC...
|
|
|
|
mkdir -p toolchain/build/gcc
|
|
|
|
cd toolchain/build/gcc
|
|
|
|
unset CC
|
|
unset CXX
|
|
unset LD
|
|
unset AR
|
|
|
|
../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"
|
|
|
|
echo Building GCC...
|
|
|
|
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"
|
|
|
|
echo Installing GCC...
|
|
|
|
make install-gcc | filter-lines "gcc" "install"
|
|
make install-target-libgcc | filter-lines "libgcc" "install"
|
|
|
|
echo Building libstdc++...
|
|
|
|
$LUNA_ROOT/tools/sync-libc.sh # libstdc++ needs libc to be built
|
|
make all-target-libstdc++v3 CXXFLAGS_FOR_TARGET="-fno-exceptions" -j$(nproc) | filter-lines "libstdc++" "build"
|
|
|
|
echo Installing libstdc++...
|
|
|
|
make install-target-libstdc++v3 | filter-lines "libstdc++" "install" |