2424# This script aauto downloads, compiles, and compresses Cross & Native GCC ARM64 Toolchain
2525# binaries targeting any Raspberry Pi 64-bit (like Pi64) OSes.
2626
27+ set -eo pipefail
28+
2729helpfunction () {
2830 # helper function that prints custom usage help menu
2931 echo " "
@@ -51,15 +53,14 @@ while getopts "g:o:V" opt; do
5153 VERBOSE=1
5254 echo " Info: Activated verbose output!"
5355 echo " "
54- set -eov pipefail # Set verbose mode.
56+ set -v # Set verbose mode.
5557 ;;
5658 ? ) helpfunction ;; # prints help function for invalid parameter
5759 esac
5860done
5961# validates parameters and print usage helper function in case parameters are missing
6062if [ -z " $VERBOSE " ]; then
6163 VERBOSE=0
62- set -eo pipefail # stop the script and exit with return code != 0 if errored
6364fi
6465if [ -z " $GCC_VERSION " ] || [ -z " $RPIOS_TYPE " ]; then
6566 echo " Error: Required parameters are missing!"
@@ -135,7 +136,7 @@ mkdir -p "$INSTALLDIR"
135136cd " $DOWNLOADDIR " || exit
136137# download binaries if not found
137138if [ ! -d " linux" ]; then
138- wget -q https://github.com/$( wget -q https://github.com/raspberrypi/linux/releases/latest -O - | egrep ' /.*/.*/.*.tar.gz' -o)
139+ wget -q https://github.com/$( wget -q https://github.com/raspberrypi/linux/releases/latest -O - | egrep ' /.*/.*/.*.tar.gz' -o | head -n1 )
139140 tar xf raspberrypi* .tar.gz
140141 mv linux* linux
141142 rm ./* .tar.*
@@ -217,15 +218,15 @@ if [ -n "$(ls -A "$DOWNLOADDIR"/binutils-$BINUTILS_VERSION/build)" ]; then rm -r
217218cd " $DOWNLOADDIR " /binutils-$BINUTILS_VERSION /build || exit
218219../configure --target=$TARGET --prefix= --with-arch=$ARCH --with-sysroot=/$TARGET /libc --with-build-sysroot=" $SYSROOTDIR " --disable-multilib
219220make -s -j$( nproc)
220- make -s install DESTDIR=" $INSTALLDIR "
221+ make -s install-strip DESTDIR=" $INSTALLDIR "
221222if [ -n " $( ls -A " $DOWNLOADDIR " /binutils-$BINUTILS_VERSION /build) " ]; then rm -rf " $DOWNLOADDIR " /binutils-$BINUTILS_VERSION /build/* ; fi
222223
223224echo " Building Cross GCC $GCCBASE_VERSION Binaries..."
224225if [ -n " $( ls -A " $DOWNLOADDIR " /gcc-$GCCBASE_VERSION /build) " ]; then rm -rf " $DOWNLOADDIR " /gcc-$GCCBASE_VERSION /build/* ; fi
225226cd " $DOWNLOADDIR " /gcc-$GCCBASE_VERSION /build || exit
226227../configure --prefix= --target=$TARGET --enable-languages=$LANGUAGES --with-sysroot=/$TARGET /libc --with-build-sysroot=" $SYSROOTDIR " --with-arch=$ARCH --disable-multilib
227228make -s -j$( nproc) all-gcc
228- make -s install-gcc DESTDIR=" $INSTALLDIR "
229+ make -s install-strip- gcc DESTDIR=" $INSTALLDIR "
229230if [ -n " $( ls -A " $DOWNLOADDIR " /glibc-$GLIBC_VERSION /build) " ]; then rm -rf " $DOWNLOADDIR " /glibc-$GLIBC_VERSION /build/* ; fi
230231cd " $DOWNLOADDIR " /glibc-$GLIBC_VERSION /build || exit
231232../configure --prefix=/usr --build=" $MACHTYPE " --host=$TARGET --target=$TARGET --with-arch=$ARCH --with-sysroot=/$TARGET /libc --with-build-sysroot=" $SYSROOTDIR " --with-headers=" $SYSROOTDIR " /usr/include --with-lib=" $SYSROOTDIR " /usr/lib --disable-multilib libc_cv_forced_unwind=yes
@@ -243,15 +244,15 @@ make -s install DESTDIR="$SYSROOTDIR"
243244cd " $DOWNLOADDIR " /gcc-$GCCBASE_VERSION /build || exit
244245if [ -n " $( ls -A " $DOWNLOADDIR " /glibc-$GLIBC_VERSION /build) " ]; then rm -rf " $DOWNLOADDIR " /glibc-$GLIBC_VERSION /build/* ; fi
245246make -s -j$( nproc)
246- make -s install DESTDIR=" $INSTALLDIR "
247+ make -s install-strip DESTDIR=" $INSTALLDIR "
247248if [ -n " $( ls -A " $DOWNLOADDIR " /gcc-$GCCBASE_VERSION /build) " ]; then rm -rf " $DOWNLOADDIR " /gcc-$GCCBASE_VERSION /build/* ; fi
248249
249250if [ " $GCC_VERSION " != " $GCCBASE_VERSION " ]; then
250251 cd " $DOWNLOADDIR " /gcc-" $GCC_VERSION " /build || exit
251252 if [ -n " $( ls -A " $DOWNLOADDIR " /gcc-" $GCC_VERSION " /build) " ]; then rm -rf " $DOWNLOADDIR " /gcc-" $GCC_VERSION " /build/* ; fi
252253 ../configure --prefix= --target=$TARGET --enable-languages=$LANGUAGES --with-sysroot=/$TARGET /libc --with-build-sysroot=" $SYSROOTDIR " --with-arch=$ARCH --disable-multilib
253254 make -s -j$( nproc)
254- make -s install DESTDIR=" $INSTALLDIR "
255+ make -s install-strip DESTDIR=" $INSTALLDIR "
255256 if [ -n " $( ls -A " $DOWNLOADDIR " /gcc-" $GCC_VERSION " /build) " ]; then rm -rf " $DOWNLOADDIR " /gcc-" $GCC_VERSION " /build/* ; fi
256257
257258 echo " Building GCC Native GCC $GCC_VERSION Binaries..."
0 commit comments