adfm
Posts: 1
Joined: Fri Jan 29, 2016 9:42 am

gcc5 repository

Fri Jan 29, 2016 9:49 am

Hello,

I've just installed the latest version of raspbian and it comes with gcc 4.9.2-10. I'm using gcc 5 in my main linux distro (openSuse) and I'm looking into having the same version on both platforms.

If I look search for gcc in aptitude I only get version up to 4.9. Can anyone tell me if there is (and where is it) the repository where I can get gcc 5 for raspbian?

Thank you in advance
A

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

Re: gcc5 repository

Fri Jan 29, 2016 1:12 pm

I use GCC 5.3 on the Pi2.
I don't think you can get it from the repositories.
You will have to build it yourself which takes a few hours!
"We are in the beginning of a mass extinction, and all you can talk
about is money and fairy tales of eternal economic growth."
- Greta Thunberg

plugwash
Forum Moderator
Forum Moderator
Posts: 3502
Joined: Wed Dec 28, 2011 11:45 pm

Re: gcc5 repository

Fri Jan 29, 2016 1:16 pm

gcc 5 is in raspbian stretch if you are mad enough to upgrade to that ;)

ejolson
Posts: 4049
Joined: Tue Mar 18, 2014 11:47 am

Re: gcc5 repository

Sat Jan 30, 2016 8:20 am

jahboater wrote:I use GCC 5.3 on the Pi2.
I don't think you can get it from the repositories.
You will have to build it yourself which takes a few hours!
My recollection is a that few hours means about 8 when compiling on the Pi 2B. Note that you will need a 2 GB swap file for the compilation to finish.

Though I haven't tested it, David Carver has placed a build of gcc 5.1.0 on github that he says includes my port of the cilkrts parallel processing library to ARM CPUs. As the patches are only a few lines, I would suggest following my build instructions.

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

Re: gcc5 repository

Sat Jan 30, 2016 6:19 pm

My recollection is a that few hours means about 8 when compiling on the Pi 2B. Note that you will need a 2 GB swap file for the compilation to finish.
It all depends on how long you have - "make" or "make -j1" will take nearly two days, but will succeed without any extra swap space. As you increase towards -j4 it needs more and more memory, but never needs more than 1GB swap even with "make -j4" (at least it doesn't for me).
Create the swapfile if needed

Code: Select all

sudo dd if=/dev/zero of=/swapfile1GB bs=1M count=1024
sudo mkswap /swapfile1GB
sudo swapon /swapfile1GB
Download the extras (gmp, mpfr etc).

Code: Select all

cd gcc-5.3.0
contrib/download_prerequisites
Build it (and wait!!!)

Code: Select all

mkdir obj
cd obj
../configure -v --with-arch=armv6 --with-fpu=vfp \
  --with-float=hard --build=arm-linux-gnueabihf \
  --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf \
  --prefix=/home/pi/gcc-5.3 \
  --disable-softfloat \
  --enable-languages=c
make -j4
"We are in the beginning of a mass extinction, and all you can talk
about is money and fairy tales of eternal economic growth."
- Greta Thunberg

ejolson
Posts: 4049
Joined: Tue Mar 18, 2014 11:47 am

Re: gcc5 repository

Sun Jan 31, 2016 5:22 am

jahboater wrote:As you increase towards -j4 it needs more and more memory, but never needs more than 1GB swap even with "make -j4" (at least it doesn't for me).
That is interesting. I chose 2GB based on the rule of thumb that swap should be 2x available RAM. Getting by with less could be useful, especially for those putting swap on the sdcard.

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

Re: gcc5 repository

Sun Jan 31, 2016 9:54 am

I added:-
--disable-softfloat \
--enable-languages=c
to try and speed things up a little, which may reduce the swap needed, I don't know.
The configure in your build instructions looks better

Code: Select all

 ../gcc-src/configure -v --enable-languages=c,c++ \
--prefix=/usr/local/gcc-5.3 --with-arch=armv7-a \
--with-fpu=vfp --with-float=hard --build=arm-linux-gnueabihf \
--host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
"We are in the beginning of a mass extinction, and all you can talk
about is money and fairy tales of eternal economic growth."
- Greta Thunberg

d3m0n1q_733rz
Posts: 5
Joined: Thu Mar 24, 2016 11:03 pm

Re: gcc5 repository

Thu Mar 24, 2016 11:11 pm

Does that command work when cross compiling on a 64-bit desktop of Ubuntu with the arm binaries installed? If not, how would you set the cross compiler to avoid all of the memory constraints and decrease compile time?
I'm looking at using --thumb-interwork, graphite, gold, and lto to eventually compile recalbox. I'm also looking at compiling a Thumb based distro for the RPi3 with ARM code as needed.

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

Re: gcc5 repository

Fri Mar 25, 2016 8:29 pm

d3m0n1q_733rz wrote:Does that command work when cross compiling on a 64-bit desktop of Ubuntu with the arm binaries installed? If not, how would you set the cross compiler to avoid all of the memory constraints and decrease compile time?
I'm looking at using --thumb-interwork, graphite, gold, and lto to eventually compile recalbox. I'm also looking at compiling a Thumb based distro for the RPi3 with ARM code as needed.
To be honest I don't know.
The GCC build time on the Pi3 is down to 4.5 - 5 hours which is good enough for me, new releases don't come out that often.
Now I use:-

Code: Select all

../configure -v --enable-languages=c,c++ \
  --prefix=/home/pi/gcc-5.3 --with-arch=armv8-a \
  --with-fpu=neon-vfpv4 --with-float=hard --build=arm-linux-gnueabihf \
  --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
By the way, I get an odd warning building thumb2 programs for the cortex-a53 about deprecated arm instructions in IT blocks.
"We are in the beginning of a mass extinction, and all you can talk
about is money and fairy tales of eternal economic growth."
- Greta Thunberg

d3m0n1q_733rz
Posts: 5
Joined: Thu Mar 24, 2016 11:03 pm

Re: gcc5 repository

Sat Mar 26, 2016 12:32 am

I'm not entirely sure why it states that it's depreciated unless it's still trying to consider A32 mode instead of T32. You did specify to compile in Thumb as default and maybe interwork with ARM where it makes sense? In ARM mode, it doesn't use if-then statements as far as I understand. It's also possible that it's trying to use depreciated conditions in the if-then command. So it's sort of a toss-up to see what's going on unless you can disassemble and find the block it's talking about.

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

Re: gcc5 repository

Sat Mar 26, 2016 8:01 am

d3m0n1q_733rz wrote:I'm not entirely sure why it states that it's depreciated unless it's still trying to consider A32 mode instead of T32. You did specify to compile in Thumb as default and maybe interwork with ARM where it makes sense? In ARM mode, it doesn't use if-then statements as far as I understand. It's also possible that it's trying to use depreciated conditions in the if-then command. So it's sort of a toss-up to see what's going on unless you can disassemble and find the block it's talking about.
I use thumb2 (-mthumb) for the entire program so there is no interwork. I've been doing this ever since the Pi2 came out. Perhaps its a GCC or gas bug, I know conditional execution is limited in aarch64 and may be its getting mixed up somehow.
/tmp/cckgobmA.s: Assembler messages:
/tmp/cckgobmA.s:1280: Warning: IT blocks containing 32-bit Thumb instructions are deprecated in ARMv8
/tmp/cckgobmA.s:22025: Warning: IT blocks containing 32-bit Thumb instructions are deprecated in ARMv8
/tmp/cckgobmA.s:22940: Warning: IT blocks containing 32-bit Thumb instructions are deprecated in ARMv8
I narrowed it down to the -mfpu=neon-vfpv4 flag without which it assembles cleanly. /tmp/cckgobmA.s is removed before I can look at it. Using -S, there are no IT blocks near the lines stated.

EDIT:
I think it is a bug.
https://gcc.gnu.org/ml/gcc-bugs/2015-09/msg01248.html
-mrestrict-it
Restricts generation of IT blocks to conform to the rules of ARMv8. IT blocks can
only contain a single 16-bit instruction from a select set of instructions. This
option is on by default for ARMv8 Thumb mode.
Adding -mrestrict-it doesn't help.
"We are in the beginning of a mass extinction, and all you can talk
about is money and fairy tales of eternal economic growth."
- Greta Thunberg

Return to “C/C++”