Commit 84c61aff authored by James Larrowe's avatar James Larrowe Committed by Ed Reel

Update cross script (#2686)

* Uodated cross script

* Updated cross script

* Updated cross script, added more red text and fixed patching.

* Made the number of parallel jobs a user variable

* Updated build_cross_gcc script with sha256sums and minor fixes.

* Minor updates?

* clean sha256sum and use nproc --all

* Remove 'mkdir' reference.

* Removed Cloog references.
parent 10c7641b
#!/bin/bash #!/bin/bash
set -e
# '\033[1;31m' outputs red text. '\033[0m' reverts it to normal.
command -v crew &>/dev/null || { echo -e "\033[1;31mcrew command not found.\033[0m"; exit 1; }
GLIBC=glibc-$(crew search glibc -v | tail -1 | cut -d' ' -f2 | cut -d'-' -f1) GLIBC=glibc-$(crew search glibc -v | tail -1 | cut -d' ' -f2 | cut -d'-' -f1)
BINUTILS=binutils-2.31.1 BINUTILS=binutils-$(crew search binutils -v | tail -1 | cut -d' ' -f2 | cut -d'-' -f1)
GCC=gcc-8.2.0 GCC=gcc-$(crew search gcc -v | tail -1 | cut -d' ' -f2 | cut -d'-' -f1)
MPFR=mpfr-4.0.1 MPFR=mpfr-$(crew search mpfr -v | tail -1 | cut -d' ' -f2 | cut -d'-' -f1)
GMP=gmp-6.1.2 GMP=gmp-$(crew search gmp -v | tail -1 | cut -d' ' -f2 | cut -d'-' -f1)
MPC=mpc-1.1.0 MPC=mpc-$(crew search mpc -v | tail -1 | cut -d' ' -f2 | cut -d'-' -f1)
ISL=isl-0.20 ISL=isl-$(crew search isl -v | tail -1 | cut -d' ' -f2 | cut -d'-' -f1)
CLOOG=cloog-0.18.4
KERNEL_VERSION=$(crew search linuxheaders -v | tail -1 | cut -d' ' -f2 | cut -d'-' -f1).1 KERNEL_VERSION=$(crew search linuxheaders -v | tail -1 | cut -d' ' -f2 | cut -d'-' -f1)
MAJOR_VERSION="$(echo $KERNEL_VERSION | cut -c1)" MAJOR_VERSION="$(echo ${KERNEL_VERSION} | cut -c1)"
case $1 in case x${1}x in
-h|--help) echo USAGE: x-hx|x--helpx) echo Usage:
echo \ $0 target arch_type prefix echo \ $0 target [jobs] [prefix]
echo \ \-h, --help: Display this help echo \ \-h, --help: Display this help
echo \ \-v, --version: Display version echo \ \-v, --version: Display version
echo \ \-t, --const: Display constants echo \ \-t, --const: Display constants
echo \ \-c, --clean: Clean current directory echo \ \-c, --clean: Clean current directory
echo \ Valid targets: 'aarch64-cros-linux-gnu', 'x86_64-cros-linux-gnu', 'i686-cros-linux-gnu', 'armv7l-cros-linux-gnueabihf' echo \ Valid targets: 'aarch64-cros-linux-gnu', 'x86_64-cros-linux-gnu', 'i686-cros-linux-gnu', 'armv7l-cros-linux-gnueabihf'
shift
exit 0;; exit 0;;
-v|--version) echo build_cros_gcc version 1.26 x-vx|x--versionx) echo build_cros_gcc version 1.27.1
shift
exit 0;; exit 0;;
-c|--clean) rm -rf build-binutils build-gcc build-glibc x-cx|x--cleanx) rm -rf build-binutils build-gcc build-glibc
rm -rf \ rm -rf \
./$GCC \ ./${GCC} \
./$CLOOG \ ./${GMP} \
./$GMP \ ./${GLIBC} \
./$GLIBC \ ./${BINUTILS} \
./$BINUTILS \ ./${MPFR} \
./$MPFR \ ./${MPC} \
./$MPC \ ./linux-${KERNEL_VERSION} \
./linux-$KERNEL_VERSION \ ./${ISL} \
./$ISL \ ./${GLIBC}.tar.xz \
./$GLIBC.tar.xz \ ./${GMP}.tar.xz \
./$GMP.tar.xz \ ./${GCC}.tar.xz \
./$GCC.tar.xz \ ./${BINUTILS}.tar.xz \
./$BINUTILS.tar.xz \ ./linux-${KERNEL_VERSION}.tar.xz \
./linux-$KERNEL_VERSION.tar.xz \ ./${MPFR}.tar.xz \
./$MPFR.tar.xz \ ./${ISL}.tar.bz2 \
./$CLOOG.tar.gz \ ./${MPC}.tar.gz \
./$ISL.tar.bz2 \ ./sha256sum || true
./$MPC.tar.gz || true
shift
exit 0;; exit 0;;
-t|--const) x-tx|x--constx)
echo KERNEL_VERSION=$KERNEL_VERSION echo KERNEL_VERSION=${KERNEL_VERSION}
echo MAJOR_VERSION=$MAJOR_VERSION echo MAJOR_VERSION=${MAJOR_VERSION}
echo CLOOG=$CLOOG echo ISL=${ISL}
echo ISL=$ISL echo MPC=${MPC}
echo MPC=$MPC echo GMP=${GMP}
echo GMP=$GMP echo MPFR=${MPFR}
echo MPFR=$MPFR echo GCC=${GCC}
echo GCC=$GCC echo BINUTILS=${BINUTILS}
echo BINUTILS=$BINUTILS echo GLIBC=${GLIBC}
echo GLIBC=$GLIBC
shift
exit 0;; exit 0;;
armv7l-cros-linux-gnueabihf) xarmv7l-cros-linux-gnueabihfx)
true;; true;;
aarch64-cros-linux-gnu) xaarch64-cros-linux-gnux)
true;; true;;
i686-cros-linux-gnu) xi686-cros-linux-gnux)
true;; true;;
x86_64-cros-linux-gnu) xx86_64-cros-linux-gnux)
true;; true;;
*) xx)
echo Invalid target or option \'$1\' $0 -h
exit 1;;
x*x)
echo -e "\033[1;31mInvalid target or option '$1'\033[0m"
$0 -h $0 -h
exit 1;; exit 1;;
esac esac
# '\033[1;31' outputs red text. '\033[0m' reverts it to normal. TARGET="$1" && shift
command -v crew > /dev/null || { echo "\033[1;31mcrew command not found.\033[0m"; exit 1; }
if test ! $2; then if ! [[ "$1" =~ "^[0-9]+$" ]] &>/dev/null; then
echo "$1" | grep x86_64 1>/dev/null JOBS="$1"
if [ $? == 0 ]; then shift
$0 $1 x86 $3; else
exit 0; shift
fi fi
echo "$1" | grep i686 1>/dev/null if [[ -d $1 ]] &>/dev/null; then
if [ $? == 0 ]; then PREFIX="$1"
$0 $1 x86 $3; shift
exit 0; else
if ! [[ "$1" =~ "^[0-9]+$" ]] &>/dev/null; then
JOBS="$1"
shift
else
PREFIX="$1"
shift
fi
fi
if [[ -z "${ARCH}" ]]; then
if { echo "${TARGET}" | grep x86_64 1>/dev/null; }; then
ARCH="x86_64";
fi fi
echo "$1" | grep armv7l 1>/dev/null if { echo "${TARGET}" | grep i686 1>/dev/null; }; then
if [ $? == 0 ]; then ARCH="x86";
$0 $1 arm $3;
exit 0;
fi fi
echo "$1" | grep aarch64 1>/dev/null if { echo "${TARGET}" | grep armv7l 1>/dev/null; }; then
if [ $? == 0 ]; then ARCH="arm";
$0 $1 arm64 $3;
exit 0;
fi fi
if { echo "${TARGET}" | grep aarch64 1>/dev/null; }; then
ARCH="arm64";
fi fi
if test ! $3; then fi
$0 $1 $2 $(crew const CREW_PREFIX | cut -d'=' -f2) if [[ -z "${PREFIX}" ]]; then
exit 0 PREFIX="$(crew const CREW_PREFIX | cut -d'=' -f2)"
fi
if [[ -z "${JOBS}" ]]; then
JOBS="$(nproc --all)"
fi fi
$0 -c rm -rf \
./${GLIBC} \
./${GMP} \
./${GCC} \
./${BINUTILS} \
./linux-${KERNEL_VERSION} \
./${MPFR} \
./${ISL} \
./${MPC} \
./sha256sum
echo $1 $2 $3 wget -c https://ftpmirror.gnu.org/gnu/binutils/${BINUTILS}.tar.xz
wget -c https://ftpmirror.gnu.org/gnu/gcc/${GCC}/${GCC}.tar.xz
wget -c https://www.kernel.org/pub/linux/kernel/v"${MAJOR_VERSION}".x/linux-${KERNEL_VERSION}.tar.xz
wget -c https://ftpmirror.gnu.org/gnu/libc/${GLIBC}.tar.xz
wget -c https://ftpmirror.gnu.org/gnu/mpfr/${MPFR}.tar.xz
wget -c https://ftpmirror.gnu.org/gnu/gmp/${GMP}.tar.xz
wget -c https://ftpmirror.gnu.org/gnu/mpc/${MPC}.tar.gz
wget -c http://isl.gforge.inria.fr/${ISL}.tar.bz2
wget https://ftpmirror.gnu.org/gnu/binutils/$BINUTILS.tar.xz SUMS="5d20086ecf5752cc7d9134246e9588fa201740d540f7eb84d795b1f7a93bca86 $BINUTILS.tar.xz\n"
wget https://ftpmirror.gnu.org/gnu/gcc/$GCC/$GCC.tar.xz SUMS+="832ca6ae04636adbb430e865a1451adf6979ab44ca1c8374f61fba65645ce15c $GCC.tar.xz\n"
wget https://www.kernel.org/pub/linux/kernel/v"$MAJOR_VERSION".x/linux-$KERNEL_VERSION.tar.xz SUMS+="94efeb00e4603c8546209cefb3e1a50a5315c86fa9b078b6fad758e187ce13e9 $GLIBC.tar.xz\n"
wget https://ftpmirror.gnu.org/gnu/libc/$GLIBC.tar.xz SUMS+="87b565e89a9a684fe4ebeeddb8399dce2599f9c9049854ca8c0dfbdea0e21912 $GMP.tar.xz\n"
wget https://ftpmirror.gnu.org/gnu/mpfr/$MPFR.tar.xz SUMS+="b587e083eb65a8b394e833dea1744f21af3f0e413a448c17536b5549ae42a4c2 $ISL.tar.bz2\n"
wget https://ftpmirror.gnu.org/gnu/gmp/$GMP.tar.xz SUMS+="becc413cc9e6d7f5cc52a3ce66d65c3725bc1d1cc1001f4ce6c32b69eb188cbd linux-$KERNEL_VERSION.tar.xz\n"
wget https://ftpmirror.gnu.org/gnu/mpc/$MPC.tar.gz SUMS+="6985c538143c1208dcb1ac42cedad6ff52e267b47e5f970183a3e75125b43c2e $MPC.tar.gz\n"
wget http://isl.gforge.inria.fr/$ISL.tar.bz2 SUMS+="67874a60826303ee2fb6affc6dc0ddd3e749e9bfcb4c8655e3953d0458a6e16e $MPFR.tar.xz"
wget https://www.bastoul.net/cloog/pages/download/$CLOOG.tar.gz echo -e "${SUMS}" > sha256sum
for tar in *.tar*; do tar xpf $tar; done if ! { shasum -a 256 -c sha256sum; }; then
echo -e "\033[1;31mChecksum mismatch. Please try again. :/ \033[0m";
exit 1;
fi
rm -f \ for tar in *.tar.*; do echo "Extracting ${tar}..." && tar xpf ${tar}; done
./$GLIBC.tar.xz \
./$GMP.tar.xz \
./$GCC.tar.xz \
./$BINUTILS.tar.xz \
./linux-$KERNEL_VERSION.tar.xz \
./$MPFR.tar.xz \
./$CLOOG.tar.gz \
./$ISL.tar.bz2 \
./$MPC.tar.gz
cd $GCC cd ${GCC}
ln -s ../$CLOOG cloog GCC_PATCHES="gcc-8.2.0-isl-0.20.patch"
ln -s ../$ISL isl for PATCH in ${GCC_PATCHES}; do
ln -s ../$MPC mpc wget https://github.com/JL2210/patches/raw/master/${PATCH}
ln -s ../$GMP gmp patch -Np1 -i ${PATCH}
ln -s ../$MPFR mpfr done
ln -s ../${ISL} isl
ln -s ../${MPC} mpc
ln -s ../${GMP} gmp
ln -s ../${MPFR} mpfr
cd .. cd ..
mkdir build-binutils || true mkdir build-binutils || true
cd build-binutils cd build-binutils
../$BINUTILS/configure --prefix=$3 --target=$1 --disable-multilib ../${BINUTILS}/configure --prefix=${PREFIX} --target=${TARGET} --disable-multilib
make -j$(nproc) make -j${JOBS}
make install make install
cd .. cd ..
cd linux-$KERNEL_VERSION cd linux-${KERNEL_VERSION}
make ARCH=$2 INSTALL_HDR_PATH=$3/$1 headers_install make ARCH=${ARCH} INSTALL_HDR_PATH=${PREFIX}/${TARGET} headers_install
cd .. cd ..
mkdir build-gcc || true mkdir build-gcc || true
cd build-gcc cd build-gcc
../$GCC/configure --disable-libmpx --prefix=$3 --target=$1 --enable-shared --enable-host-shared --enable-languages=c,c++,fortran,go --disable-multilib ../${GCC}/configure --prefix=${PREFIX} --target=${TARGET} --enable-shared --enable-host-shared --enable-languages=c,c++,fortran,go --disable-multilib --disable-libmpx
make -j$(nproc) all-gcc make -j${JOBS} all-gcc
make install-gcc make install-gcc
cd .. cd ..
mkdir build-glibc || true mkdir build-glibc || true
cd build-glibc cd build-glibc
../$GLIBC/configure --disable-libmpx --prefix=$3/$1 --enable-shared --enable-host-shared --build=$MACHTYPE --host=$1 --target=$1 --with-headers=$3/$1/include --disable-multilib libc_cv_forced_unwind=yes ../${GLIBC}/configure --prefix=${PREFIX}/${TARGET} --enable-shared --enable-host-shared --build=${MACHTYPE} --host=${TARGET} --target=${TARGET} --with-headers=${PREFIX}/${TARGET}/include --disable-multilib --disable-werror libc_cv_forced_unwind=yes
make install-bootstrap-headers=yes install-headers make install-bootstrap-headers=yes install-headers
make -j$(nproc) csu/subdir_lib make -j${JOBS} csu/subdir_lib
install csu/crt1.o csu/crti.o csu/crtn.o $3/$1/lib install csu/crt1.o csu/crti.o csu/crtn.o ${PREFIX}/${TARGET}/lib/
$1-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o $3/$1/lib/libc.so ${TARGET}-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o ${PREFIX}/${TARGET}/lib/libc.so
touch $3/$1/include/gnu/stubs.h touch ${PREFIX}/${TARGET}/include/gnu/stubs.h
cd .. cd ..
cd build-gcc cd build-gcc
make -j$(nproc) all-target-libgcc make -j${JOBS} all-target-libgcc
make install-target-libgcc make install-target-libgcc
cd .. cd ..
cd build-glibc cd build-glibc
make -j$(nproc) make -j${JOBS}
make install make install
cd .. cd ..
cd build-gcc cd build-gcc
make -j$(nproc) make -j${JOBS}
make install make install
cd .. cd ..
$1-gcc -v ${TARGET}-gcc -v
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment