From f26b0834d38869c131b6b2e0b9bb681e4c7188e4 Mon Sep 17 00:00:00 2001 From: James Larrowe Date: Sat, 11 Aug 2018 20:07:28 -0400 Subject: [PATCH] Added cross compiler script at @uberhacker's request (#2544) * Added cross compiler script at @uberhacker's request * Disabled libmpx, adds lines to save space --- tools/build_cross_gcc | 116 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100755 tools/build_cross_gcc diff --git a/tools/build_cross_gcc b/tools/build_cross_gcc new file mode 100755 index 000000000..8ba58f14d --- /dev/null +++ b/tools/build_cross_gcc @@ -0,0 +1,116 @@ +#!/bin/sh + + set -e + + case $1 in + + -h) echo USAGE: + echo \ $0 [options] target arch_type kernel_version + echo \ \-h, --help: Display help + echo \ \-v, --version: Display version + echo \ \-c, --clean: Clean current directory + shift + exit 0;; + --help) echo USAGE: + echo \ $0 target arch_type kernel_version + echo \ \-h, --help: Display help + echo \ \-v, --version: Display version + echo \ \-c, --clean: Clean current directory + shift + exit 0;; + -v) echo build_cross_gcc version 1.2.0 + shift + exit 0;; + --version) echo build_cross_gcc version 1.2.0 + shift + exit 0;; + -c) rm -rf build-binutils build-gcc build-glibc + rm -rf \ + ./gcc-8.2.0 \ + ./cloog-0.18.4 \ + ./gmp-6.1.2 \ + ./glibc-2.28 \ + ./binutils-2.31.1 \ + ./mpfr-4.0.1 \ + ./mpc-1.1.0 \ + ./linux-3.18.1 \ + ./isl-0.20 + shift + exit 0;; + --clean) rm -rf build-binutils build-gcc build-glibc + rm -rf \ + ./gcc-8.2.0 \ + ./cloog-0.18.4 \ + ./gmp-6.1.2 \ + ./glibc-2.28 \ + ./binutils-2.31.1 \ + ./mpfr-4.0.1 \ + ./mpc-1.1.0 \ + ./linux-3.18.1 \ + ./isl-0.20 + shift + exit 0;; + esac + + export major_version="$(echo $3 | cut -c1)" + + wget https://ftpmirror.gnu.org/gnu/binutils/binutils-2.31.1.tar.xz + wget https://ftpmirror.gnu.org/gnu/gcc/gcc-8.2.0/gcc-8.2.0.tar.xz + wget https://mirrors.edge.kernel.org/pub/linux/kernel/v"$major_version".x/linux-$3.tar.xz + wget https://ftpmirror.gnu.org/gnu/libc/glibc-2.28.tar.xz + wget https://ftpmirror.gnu.org/gnu/mpfr/mpfr-4.0.1.tar.xz + wget https://ftpmirror.gnu.org/gnu/gmp/gmp-6.1.2.tar.xz + wget https://ftpmirror.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz + wget http://isl.gforge.inria.fr/isl-0.20.tar.bz2 + wget https://www.bastoul.net/cloog/pages/download/cloog-0.18.4.tar.gz + + for tar in *.tar*; do tar xpf $tar; done + + rm -f \ + ./glibc-2.28.tar.xz \ + ./gmp-6.1.2.tar.xz \ + ./gcc-8.2.0.tar.xz \ + ./binutils-2.31.1.tar.xz \ + ./linux-3.18.1.tar.xz \ + ./mpfr-4.0.1.tar.xz \ + ./cloog-0.18.4.tar.gz \ + ./isl-0.20.tar.bz2 \ + ./mpc-1.1.0.tar.gz \ + + mkdir build-binutils || true + cd build-binutils + ../binutils-2.31.1/configure --prefix=/usr/local --target=$1 + make -j$(nproc) + make install + cd .. + cd linux-$3 + make ARCH=$2 INSTALL_HDR_PATH=/usr/local/$1 headers_install + cd .. + mkdir build-gcc || true + cd build-gcc + ../gcc-8.2.0/configure --prefix=/usr/local --target=$1 --enable-languages=c,c++,fortran --disable-multilib + make -j$(nproc) all-gcc + make install-gcc + cd .. + mkdir build-glibc || true + cd build-glibc + ../glibc-2.28/configure --disable-libmpx --prefix=/usr/local/$1 --disable-werror --enable-shared --build=$MACHTYPE --host=$1 --with-headers=/usr/local/$1/include --disable-multilib libc_cv_forced_unwind=yes + make install-bootstrap-headers=yes install-headers + make -j$(nproc) csu/subdir_lib + install csu/crt1.o csu/crti.o csu/crtn.o /usr/local/$1/lib + $1-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o /usr/local/$1/lib/libc.so + touch /usr/local/$1/include/gnu/stubs.h + cd .. + cd build-gcc + make -j$(nproc) all-target-libgcc + make install-target-libgcc + cd .. + cd build-glibc + make -j$(nproc) + make install + cd .. + cd build-gcc + make -j$(nproc) + make install + cd .. + $1-gcc -v