jahboater
Posts: 4477
Joined: Wed Feb 04, 2015 6:38 pm

GCC 9.1 released

Fri May 03, 2019 2:01 pm

Now includes D (use gdc - see "man gdc" for info)

https://gcc.gnu.org/gcc-9/changes.html

echmain
Posts: 216
Joined: Fri Mar 04, 2016 8:26 pm

Re: GCC 9.1 released

Fri May 03, 2019 5:14 pm

Would the build parameters be the same as 8.x?

jahboater
Posts: 4477
Joined: Wed Feb 04, 2015 6:38 pm

Re: GCC 9.1 released

Fri May 03, 2019 5:25 pm

echmain wrote:
Fri May 03, 2019 5:14 pm
Would the build parameters be the same as 8.x?
Yes, except that I added "d" to the --enable-languages list.
I built it OK on my x86 PC and a Pi3B+, still waiting for the build to complete on the Pi Zero ....

Code: Select all

#!/bin/bash

#
#  This is the new GCC version to install.
#
VERSION=9.1.0

#
#  For the Pi or 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
  wget ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-$VERSION/gcc-$VERSION.tar.xz
  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>
#

# Pi3+, Pi3, and new Pi2
../configure --enable-languages=c,d,c++,fortran --with-cpu=cortex-a53 \
  --with-fpu=neon-fp-armv8 --with-float=hard --build=arm-linux-gnueabihf \
  --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf --enable-checking=no

# Pi Zero's
#../configure --enable-languages=c,d,c++,fortran --with-cpu=arm1176jzf-s \
#  --with-fpu=vfp --with-float=hard --build=arm-linux-gnueabihf \
#  --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf --enable-checking=no

# x86_64
#../configure --disable-multilib --enable-languages=c,d,c++,fortran --enable-checking=no

# Odroid-C2 AArch64
#../configure --enable-languages=c,d,c++,fortran --with-cpu=cortex-a53 --enable-checking=no

# Old Pi2
#../configure --enable-languages=c,d,c++,fortran --with-cpu=cortex-a7 \
#  --with-fpu=neon-vfpv4 --with-float=hard --build=arm-linux-gnueabihf \
#  --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf --enable-checking=no

#
#  Now build GCC which will take a long time.  This could range from
#  4.5 hours on a Pi3B+ 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

echmain
Posts: 216
Joined: Fri Mar 04, 2016 8:26 pm

Re: GCC 9.1 released

Sat May 04, 2019 8:26 pm

My build completed.

I enabled only c, c++ and it took about 6 hours 15 min on a fan-cooled 3B+. It also uses an SSD, not a microSD card.

From time to time I checked the temperature and it never got over 48-49c.

dsyleixa123
Posts: 293
Joined: Mon Jun 11, 2018 11:22 am

Re: GCC 9.1 released

Mon May 06, 2019 1:30 pm

which are the pros and cons about D vs. C++ for hobby users?

jahboater
Posts: 4477
Joined: Wed Feb 04, 2015 6:38 pm

Re: GCC 9.1 released

Mon May 06, 2019 5:47 pm

dsyleixa123 wrote:
Mon May 06, 2019 1:30 pm
which are the pros and cons about D vs. C++ for hobby users?
I'm not an expert, but at first glance, to me, it seems cleaner and more modern than C++, yet still very powerful.
Why don't you just try writing a sample program in both?

The D compiler is called "gdc" (Gnu D Compiler) by the way. "man gdc" should give you some info.

This book is good:
https://www.amazon.co.uk/Programming-Tu ... 181&sr=8-5

Heater
Posts: 12747
Joined: Tue Jul 17, 2012 3:02 pm

Re: GCC 9.1 released

Tue May 07, 2019 3:25 am

dsyleixa123,
which are the pros and cons about D vs. C++ for hobby users?
That rather depends what your hobby is.

My hobby includes trying out various languages occasionally, if only to see what the idea is. If if they prove useful for something I want to do they may get pressed into use.

I know little of D but now that it is supported by both GCC and LLVM I will certainly be taking a closer looking at it. As a cleaned up and memory safe progression from C, and as a far simpler language than C++ it seems quite attractive.

I suspect D will not be useful for Arduino and other such small systems anytime soon, if ever. So far I see no way to use D for my RISC V CPU on FPGA with only 40KB RAM. So if you want consistency across your different hobby projects that could be a consideration.

C++ has grown into such a huge and complex language that nobody understands how all it's parts work anymore. Or how those parts interact. But if you can keep things simple, like on Arduino, C++ can do anything.

jahboater
Posts: 4477
Joined: Wed Feb 04, 2015 6:38 pm

Re: GCC 9.1 released

Tue May 07, 2019 5:01 am

For the general case, D should run on RISC-V since GCC supports it.

And it works on the Pi Zero ...

Code: Select all

[email protected]:~ $ gdc -v
Using built-in specs.
COLLECT_GCC=gdc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/arm-linux-gnueabihf/9.1.0/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../configure --enable-languages=c,d,c++,fortran --with-cpu=arm1176jzf-s --with-fpu=vfp --with-float=hard --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf --enable-checking=no
Thread model: posix
gcc version 9.1.0 (GCC) 

dsyleixa123
Posts: 293
Joined: Mon Jun 11, 2018 11:22 am

Re: GCC 9.1 released

Tue May 07, 2019 6:58 am

I would need it indeed for building mobile and manipulating robots, so what's needed is
all libs/modules which Python has for the Pi,
feat. Arduino-like GPIO control,
Arduino-based ESP8266-like WiFi-/WebServer/Client libs,
plus simple designer tools for user-GUIs (like Borland C++ Builder)
plus Cam applications for object detection (e.g., like PixyCam has it on-board, color and shape recognition)

nairn62
Posts: 7
Joined: Wed Dec 16, 2015 11:48 pm

Re: GCC 9.1 released

Tue May 07, 2019 12:18 pm

echmain wrote:
Sat May 04, 2019 8:26 pm
My build completed.

I enabled only c, c++ and it took about 6 hours 15 min on a fan-cooled 3B+. It also uses an SSD, not a microSD card.

From time to time I checked the temperature and it never got over 48-49c.
I have different compile time options, and my Pi 3B+ took just over an hour to generate GCC 9.1. Works perfectly for now ;)

knute
Posts: 428
Joined: Thu Oct 23, 2014 12:14 am
Location: Texas
Contact: Website

Re: GCC 9.1 released

Tue May 07, 2019 1:32 pm

Is there an uninstall script in case one doesn't like it?

jahboater
Posts: 4477
Joined: Wed Feb 04, 2015 6:38 pm

Re: GCC 9.1 released

Tue May 07, 2019 2:01 pm

knute wrote:
Tue May 07, 2019 1:32 pm
Is there an uninstall script in case one doesn't like it?
I don't know, but the old compiler (GCC 6.3 on the Pi) is available as gcc-6
The new GCC goes into /usr/local/bin (by default), the old compiler remains in /usr/bin (echo $PATH shows /usr/local/bin comes first).
You can set the destination directory with "--prefix=dir"

Why would you not "like" the latest compiler version?
Last edited by jahboater on Tue May 07, 2019 2:06 pm, edited 1 time in total.

jahboater
Posts: 4477
Joined: Wed Feb 04, 2015 6:38 pm

Re: GCC 9.1 released

Tue May 07, 2019 2:01 pm

nairn62 wrote:
Tue May 07, 2019 12:18 pm
I have different compile time options, and my Pi 3B+ took just over an hour to generate GCC 9.1. Works perfectly for now ;)
Can you share how you built it that quickly?

nairn62
Posts: 7
Joined: Wed Dec 16, 2015 11:48 pm

Re: GCC 9.1 released

Tue May 07, 2019 2:59 pm

jahboater wrote:
Tue May 07, 2019 2:01 pm
nairn62 wrote:
Tue May 07, 2019 12:18 pm
I have different compile time options, and my Pi 3B+ took just over an hour to generate GCC 9.1. Works perfectly for now ;)
Can you share how you built it that quickly?
I've been using the following code for a few years now without any problems. The salient option for speed is the "--disable-bootstrap". Instead of 3 passes it only passes once. The 3 compilation passes are on by default and its primary function is to ensure that non-GCC compilers produce matching results. I've just complied the latest Linux Kernel 5.1.0 on my Raspberry Pi using GCC 9.1.0 e.g.

Version: Linux version 5.1.0-rc7-v7 ([email protected]_mockup) (gcc version 9.1.0 (GCC)) #1 SMP Tue May 7 13:30:25 BST 2019

My new 5.1.0 kernel is working OK. Hope this explains the massive speed up in compiling.

Code: Select all

#!/bin/sh
unset LIBRARY_PATH CPATH C_INCLUDE_PATH PKG_CONFIG_PATH CPLUS_INCLUDE_PATH INCLUDE
CFLAGS="-Ofast -fno-fast-math -march=armv8-a -mfpu=neon-fp-armv8 -mfloat-abi=hard" \
../gcc-9.1.0/configure -v           \
    --with-system-zlib              \
    --disable-bootstrap             \
    --with-mode=arm                 \
    --prefix=/usr/local/gcc-9.1.0   \
    --enable-languages=c,c++        \
    --disable-multilib              \
    --program-suffix=-9.1.0         \
    --with-arch=armv8-a             \
    --with-float=hard               \
    --with-fpu=neon-fp-armv8        \
    --build=arm-linux-gnueabihf     \
    --host=arm-linux-gnueabihf      \
    --target=arm-linux-gnueabihf

make -j4
sudo make install

sudo update-alternatives --remove-all gcc-ar
sudo update-alternatives --remove-all gcc-nm
sudo update-alternatives --remove-all gcc-ranlib
sudo update-alternatives --remove-all gcc
sudo update-alternatives --remove-all g++
sudo update-alternatives --install /usr/bin/g++ g++ /usr/local/gcc-9.1.0/bin/g++-9.1.0 20
sudo update-alternatives --install /usr/bin/gcc gcc /usr/local/gcc-9.1.0/bin/gcc-9.1.0 20
sudo update-alternatives --install /usr/bin/gcc-ranlib gcc-ranlib \
/usr/local/gcc-9.1.0/bin/gcc-ranlib-9.1.0 20
sudo update-alternatives --install /usr/bin/gcc-nm gcc-nm /usr/local/gcc-9.1.0/bin/gcc-nm-9.1.0 20
sudo update-alternatives --install /usr/bin/gcc-ar gcc-ar /usr/local/gcc-9.1.0/bin/gcc-ar-9.1.0 20
Last edited by nairn62 on Tue May 07, 2019 3:32 pm, edited 1 time in total.

Heater
Posts: 12747
Joined: Tue Jul 17, 2012 3:02 pm

Re: GCC 9.1 released

Tue May 07, 2019 3:15 pm

jahboater,
For the general case, D should run on RISC-V since GCC supports it.
I have no doubt. LLVM too.

Perhaps I should elaborate:

My RISC V is written in SpinalHDL for FPGA. It's an RV32I. I only have about 40K bytes RAM available. At least until I figure out how drive the 32MB SDRAM on my DE0-Nano board. No support for supervisor mode or virtual memory so can't run Linux.

What concerns me is the run-time support that D needs. As far as I can tell that requires a memory allocator, exception handling, and so on.

I can't see how I can just compile a program and stick the binary in memory to run like I do with C/C++. With no more of a run-time than setting the stack pointer and calling main from assembler.

nairn62
Posts: 7
Joined: Wed Dec 16, 2015 11:48 pm

Re: GCC 9.1 released

Tue May 07, 2019 3:27 pm

jahboater wrote:
Mon May 06, 2019 5:47 pm
dsyleixa123 wrote:
Mon May 06, 2019 1:30 pm
which are the pros and cons about D vs. C++ for hobby users?
I'm not an expert, but at first glance, to me, it seems cleaner and more modern than C++, yet still very powerful.
Why don't you just try writing a sample program in both?

The D compiler is called "gdc" (Gnu D Compiler) by the way. "man gdc" should give you some info.

This book is good:
https://www.amazon.co.uk/Programming-Tu ... 181&sr=8-5
Free PDF copy of the book located here: http://ddili.org/ders/d.en/Programming_in_D.pdf

jahboater
Posts: 4477
Joined: Wed Feb 04, 2015 6:38 pm

Re: GCC 9.1 released

Tue May 07, 2019 4:20 pm

Heater wrote:
Tue May 07, 2019 3:15 pm
What concerns me is the run-time support that D needs. As far as I can tell that requires a memory allocator, exception handling, and so on.
Does this option help? (from man gdc).

Code: Select all

-fno-druntime
    Implements <https://dlang.org/spec/betterc.html>.  Assumes that compilation targets an
    environment without a D runtime library.

    This is equivalent to compiling with the following options:

          gdc -nophoboslib -fno-exceptions -fno-moduleinfo -fno-rtti

jahboater
Posts: 4477
Joined: Wed Feb 04, 2015 6:38 pm

Re: GCC 9.1 released

Tue May 07, 2019 4:29 pm

nairn62 wrote:
Tue May 07, 2019 2:59 pm
I've been using the following code for a few years now without any problems. The salient option for speed is the "--disable-bootstrap". Instead of 3 passes it only passes once.
Thanks.
Sounds all that's needed anyway if the current installed compiler is a recent GCC (say you are upgrading from 8.3 to 9.1).
With the three passes, I guess the final version is built with itself, and that thoroughly tests itself too.

nairn62
Posts: 7
Joined: Wed Dec 16, 2015 11:48 pm

Re: GCC 9.1 released

Tue May 07, 2019 4:38 pm

jahboater wrote:
Tue May 07, 2019 4:29 pm
nairn62 wrote:
Tue May 07, 2019 2:59 pm
I've been using the following code for a few years now without any problems. The salient option for speed is the "--disable-bootstrap". Instead of 3 passes it only passes once.
Thanks.
Sounds all that's needed anyway if the current installed compiler is a recent GCC (say you are upgrading from 8.3 to 9.1).
With the three passes, I guess the final version is built with itself, and that thoroughly tests itself too.
Yes, I've upgraded from 8.3 to 9.1, and also, 6.3 to 9.1; they all work fine. Compiling the latest Linux Kernel from source with GCC 9.1 proves you don't need the extra 2 steps on Raspbian.

Heater
Posts: 12747
Joined: Tue Jul 17, 2012 3:02 pm

Re: GCC 9.1 released

Tue May 07, 2019 5:10 pm

jahboater,

"BetterC". I like it. Thanks. Now you have spun me off into yet another new programming language world.

Sadly it means classes are no longer available. But I can live with that for now.

User avatar
Paeryn
Posts: 2570
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: GCC 9.1 released

Tue May 07, 2019 7:45 pm

jahboater wrote:
Tue May 07, 2019 4:29 pm
nairn62 wrote:
Tue May 07, 2019 2:59 pm
I've been using the following code for a few years now without any problems. The salient option for speed is the "--disable-bootstrap". Instead of 3 passes it only passes once.
Thanks.
Sounds all that's needed anyway if the current installed compiler is a recent GCC (say you are upgrading from 8.3 to 9.1).
With the three passes, I guess the final version is built with itself, and that thoroughly tests itself too.
Two passes is better than one, it makes sure that is built with the version it is designed to be built with. Plus your new compiler wouldn't itself be built using any new-fangled optimisations the new compiler has. By just doing one pass the new compiler could be buggy and it won't have any new optimisations applied (it can apply them to code it generates but the compiler itself won't have been compiled with them).

The third pass allows it to check that everything built correctly (passes two and three should produce identical binaries). If you already know that everything builds fine (i.e. you've used the exact same versions before that worked) then the third pass can be skipped to save time, similarly if you don't mind having a possibly slower compiler or possible bugs that a proper build won't have then you can do just the one pass.

Personally I wouldn't make do with a one pass build, you wouldn't be able to submit bug reports on it if it doesn't work properly.
She who travels light — forgot something.

jahboater
Posts: 4477
Joined: Wed Feb 04, 2015 6:38 pm

Re: GCC 9.1 released

Sun May 12, 2019 10:55 am

Paeryn,

That all makes sense, thanks.

That is, until you build it on a Pi Zero :)
The three stage build takes over 50 hours on the p0, but (surprisingly) it works perfectly.
Just leave it running over the weekend.

FYI, the new D front end added around one million lines of code ...

User avatar
Paeryn
Posts: 2570
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: GCC 9.1 released

Sun May 12, 2019 1:03 pm

jahboater wrote:
Sun May 12, 2019 10:55 am
Paeryn,

That all makes sense, thanks.

That is, until you build it on a Pi Zero :)
The three stage build takes over 50 hours on the p0, but (surprisingly) it works perfectly.
Just leave it running over the weekend.

FYI, the new D front end added around one million lines of code ...
I'll have to get around to building for my RPi & PC, A million is quite a lot for a front end, I wonder if it generates GIMPLE for the back end rather than GENERIC (the C and C++ front ends do)? Darn, I'm going to have to take a squiz at the source and see now :geek: . I remember playing around with D for a few weeks way back when it was first released but never did anything in it.
She who travels light — forgot something.

jahboater
Posts: 4477
Joined: Wed Feb 04, 2015 6:38 pm

Re: GCC 9.1 released

Sun May 12, 2019 1:09 pm

Paeryn wrote:
Sun May 12, 2019 1:03 pm
I'll have to get around to building for my RPi & PC, A million is quite a lot for a front end, I wonder if it generates GIMPLE for the back end rather than GENERIC (the C and C++ front ends do)? Darn, I'm going to have to take a squiz at the source and see now :geek: . I remember playing around with D for a few weeks way back when it was first released but never did anything in it.
See this old post:
https://www.phoronix.com/scan.php?page= ... D-Language
Adding the D support touches more than three thousand files (most of which is test suite cases) and 859,714 lines of code.... Yes, the better part of a million new lines.
So only 860k LOC really.

ichibrosan
Posts: 2
Joined: Fri May 24, 2019 7:34 am

Re: GCC 9.1 released

Fri May 24, 2019 11:00 am

nairn62 wrote:
Tue May 07, 2019 12:18 pm
echmain wrote:
Sat May 04, 2019 8:26 pm
My build completed.

I enabled only c, c++ and it took about 6 hours 15 min on a fan-cooled 3B+. It also uses an SSD, not a microSD card.

From time to time I checked the temperature and it never got over 48-49c.
I have different compile time options, and my Pi 3B+ took just over an hour to generate GCC 9.1. Works perfectly for now ;)
I tried building gcc 9.1 on my Mac the other day and it was very difficult, and in fact isn't working yet.

Did you have to deal with prerequisites in your build?

Return to “C/C++”