12 posts • Page 1 of 1
A while back there was a thread with a script for downloading and compiling gcc 10 (I think it was 10 anyway). I can't seem to find it again. I have need for gcc 10. Anybody remember who posted the script or what the title was?
Here it is:
Code: Select all
#!/bin/bash # REMEMBER TO UNCOMMENT THE CONFIGURE LINE FOR YOUR TARGET PLATFORM. # ... and comment out the default of course. # # This is the new GCC version to install. # VERSION=10.2.0 # # These are the languages the new compiler should support. # LANG=c,c++,fortran # # For any computer with less than 2GB of memory. # #if [ -f /etc/dphys-swapfile ]; then # sudo sed -i 's/^CONF_SWAPSIZE=[0-9]*$/CONF_SWAPSIZE=1024/' /etc/dphys-swapfile # sudo /etc/init.d/dphys-swapfile restart #fi if [ -d gcc-$VERSION ]; then cd gcc-$VERSION rm -rf obj else echo "Download source tree ..." wget ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-$VERSION/gcc-$VERSION.tar.xz echo "Uncompress source tree ..." tar xf gcc-$VERSION.tar.xz rm -f gcc-$VERSION.tar.xz cd gcc-$VERSION contrib/download_prerequisites fi mkdir -p obj cd obj # # Now run the ./configure which must be checked/edited beforehand. # Uncomment the sections below depending on your platform. You may build # on a Pi3 for a target Pi Zero by uncommenting the Pi Zero section. # To alter the target directory set --prefix=<dir> # For a very quick build try: --disable-bootstrap # # x86_64 #../configure --disable-multilib --enable-languages=$LANG # AArch64 Pi4 running Raspberry Pi OS 64-bit ../configure --enable-languages=$LANG --with-cpu=cortex-a72 # Pi Zero #../configure --enable-languages=$LANG --with-cpu=arm1176jzf-s \ # --with-fpu=vfp --with-float=hard --build=arm-linux-gnueabihf \ # --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf # Pi3+, Pi3, Pi4 in 32-bit mode #../configure --enable-languages=$LANG --with-cpu=cortex-a53 \ # --with-fpu=neon-fp-armv8 --with-float=hard --build=arm-linux-gnueabihf \ # --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf # Old Pi2 #../configure --enable-languages=$LANG --with-cpu=cortex-a7 \ # --with-fpu=neon-vfpv4 --with-float=hard --build=arm-linux-gnueabihf \ # --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf # # Now build GCC which will take a long time. This could range from # 3.5 hours on a 4GB Pi4 up to about 50 hours on a Pi Zero. It can be # left to complete overnight (or over the weekend for a Pi Zero :-) # The most likely causes of failure are lack of disk space, lack of # swap space or memory, or the wrong configure section uncommented. # The new compiler is placed in /usr/local/bin, the existing compiler remains # in /usr/bin and may be used by giving its version gcc-6 (say). # if make -j `nproc` then echo read -p "Do you wish to install the new GCC (y/n)? " yn case $yn in [Yy]* ) sudo make install ;; * ) exit ;; esac fi
Last edited by jahboater on Fri Dec 11, 2020 2:10 am, edited 1 time in total.
One more question, I've compiled it but how do I install it somewhere?
You flipped the script on me . I ran the original script from ~/bin. It created a directory gcc-10.2.0. There was no Makefile in ~/bin so I went to ~/bin/gcc-10.2.0/obj and entered sudo make install. I think it is working like it is supposed to. It needed a restart of the terminal.
FYI arm_64bit changes the Kernel to 64bit, but Userland is still 32bit.
Take what I advise as advice not the utopian holy grail, and it is gratis !!
I have been using 64 bit GCC and Rust by using the nspawn 64 bit container environment:
Code: Select all
pi@heater-pi:~ $ sudo apt-get install raspbian-nspawn-64 pi@heater-pi:~ $ ds64-shell pi@debian-buster-64:~ $ Connected to machine debian-buster-64. Press ^] three times within 1s to exit session. pi@debian-buster-64:~ $ sudo apt-get install gcc pi@debian-buster-64:~ $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/aarch64-linux-gnu/8/lto-wrapper Target: aarch64-linux-gnu ... ... Thread model: posix gcc version 8.3.0 (Debian 8.3.0-6) $ gcc hello.c pi@debian-buster-64:~ $ file ./a.out ./a.out: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 3.7.0, BuildID[sha1]=ecb9ffc2d6736670604025bd67d48b6e08c2a8ab, not stripped
Memory in C++ is a leaky abstraction .
I use the 64-bit version of Raspberry Pi OS and build GCC with this simple configure line:
Then I get the full 64-bit tool chain and compiler for the Pi4.
Code: Select all
../configure --enable-languages=c,d,c++,fortran --with-cpu=cortex-a72