MikeTheBiker
Posts: 8
Joined: Fri Dec 16, 2016 9:32 am

Raspian to conservative / old compiler / cross-compiler

Fri Dec 16, 2016 9:51 am

OK - I know there are a few community OS versions out there but I think we need kind of a rolling Raspian release as our main OS

My main concern is the old compiler (and all the other libs around it) that ships with Raspian - 4.9! gcc 6.0 is the current version.
It's really disappointing - please give us better developer support!

It's the same mess with cross-compiling: https://github.com/raspberrypi/tools - 4.9.3 - at least the most current version in the 4.9 series - but does the Raspberry-Team (don't know who's really behind the "tools") think there is only one OS out there - Linux?

Please provide us with a cross-compiler for OSX and Windows. It's quite hard to compile a cross-compiler yourself - specially on OSX with clang!!

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 28439
Joined: Sat Jul 30, 2011 7:41 pm

Re: Raspian to conservative / old compiler / cross-compiler

Fri Dec 16, 2016 11:04 am

Hmmm, not sure about this. There is nothing wrong with the 4.9 compiler. It's a known, working, pretty decent compiler, which has been thoroughly tested. If you want a more recent one you can, as you say, either install one on the Pi, or built it yourself. For the majority of people, 4.8/9 is fine. Did you know the default compiler on Ubuntu 14.04 LTS is 4.8? Just because something is old, doesn't mean it is no longer the best tool for the job. I've been using 4.8/4.9 on commercial embedded projects including Android stuff, seems to be absolutely fine.

As for cross compilers, not sure how much benefit there is to the Foundation officially supporting Windows and OSX cross compilers. A big support burden for very little benefit. Not saying it won't happen - I know Simon at RPF uses a Mac, so perhaps the work has been done, and just needs to be published. Surely there are downloadable cross compilers out there that work fine?

As for the Raspi team thinking there is only one OS out there, probably true, it's Linux. The supported OS on the Raspberry Pi itself. All development is done on Linux. All of it. Worth remembering that the team is fairly small, so supporting multiple OS's is quite difficult simply due to the work involved.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Working in the Application's Team.

MikeTheBiker
Posts: 8
Joined: Fri Dec 16, 2016 9:32 am

Re: Raspian to conservative / old compiler / cross-compiler

Fri Dec 16, 2016 7:39 pm

First - Thanks for your answer!
There is nothing wrong with the 4.9 compiler. It's a known, working, pretty decent compiler, which has been thoroughly tested. If you want a more recent one you can, as you say, either install one on the Pi, or built it yourself.

4.9[.1 / .2] is outdated, Installing in on the Pi is not an option - I need a cross-compiler.
C++ is moving fast these days. C++17 is on the edge, clang is the default compiler for Google, gets good support from MS and is the default on Apple.
The days of old style C++ are over - even if you code for embedded devices.
gcc-5 would be really cool but 4.9.3 or 4.9.4 would be OK for me - but as said I need it for the Mac.

Cross-compiling with clang for Raspi seems not possible - at least I found nothing about on the web. So the only solution is gcc 4.9
Not sure how much benefit there is to the Foundation officially supporting Windows and OSX cross compilers.
More developers, more + better software = more PIs for the people = more revenue
I know Simon at RPF uses a Mac, so perhaps the work has been done, and just needs to be published. Surely there are downloadable cross compilers out there that work fine?
Cool - maybe he can upload it on GH!

I'm using 4.9.1 on my Mac - but can't remember where I found it!
All development is done on Linux.
- ;-)) nice for you

What I hate is that I think every Developer has to start from scratch if he/she want's to develop for Raspberry.
Compiling on the Raspi is not an option - so good cross-compiling support is mandatory!

There a few sites with crosstool-ng instructions out there - This is OK if your are not on Mac - but try to compile gcc on Mac with clang - forget it!
I tried this one: http://www.jaredwolff.com/blog/cross-co ... pberry-pi/ which is by far the best! Took me 3 days to compile a working 5.2 version for Raspi 1.
Now I have gcc-5.2 but I have to link libstdc++ statically - also not really an option.

However - I start the link-list with a few sites I found: Useless - but maybe someone needs it nevertheless

User avatar
kusti8
Posts: 3439
Joined: Sat Dec 21, 2013 5:29 pm
Location: USA

Re: Raspian to conservative / old compiler / cross-compiler

Fri Dec 16, 2016 7:50 pm

The point is that is there something that you need from newer gcc versions? If not, then there's no problem because whether it's old or not, it still works. It probably will be updated when features are required but now it isn't needed. Cross compiling from Mac is a bit difficult because there aren't too many people using it to cross compile and rather than try and support such a platform, it's easier to invest more time in other things.

Why do you need to cross compile though? Only for really big projects do you need it, even gcc compiles well on a Pi3.

Also, I cross compile Chromium for the Pi and that uses clang also. You should be able to get it to work.

When I compile for Chromium, I can't compile on Arch or Mac simply because it's not supported and there would need to have a huge effort to set up a compile environment and document it for such systems. So I just triple boot Ubuntu and I'm fine with that.
There are 10 types of people: those who understand binary and those who don't.

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

Re: Raspian to conservative / old compiler / cross-compiler

Fri Dec 16, 2016 9:52 pm

MikeTheBiker,
Compiling on the Raspi is not an option - so good cross-compiling support is mandatory!
What?!

I compile on the Pi all the time. Sure it's not as fast as my desktop PC but quite usable. Heck, I even built Qt 5 on an original Pi. New Pis are many times faster. Besides, when is one rebuilding all of such a huge project?

Raspbian is based on Debian. Debian is very conservative in it's updates. Which is a good thing. They value stability over newness. That is not stability as in "does not crash" but stability as in "does not break anything else in the OS when someone does an update"

If you really want the latest an greatest GCC or Clang/LLVM or any other program you can have it. Just build it on a Pi!
Memory in C++ is a leaky abstraction .

User avatar
jahboater
Posts: 6941
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: Raspian to conservative / old compiler / cross-compiler

Fri Dec 16, 2016 9:55 pm

GCC 4.9 is no longer supported.

The current version is 6.2 with 6.3 due for release in the next day or so (before Christmas anyway).

It takes about 6.5 hours to compile gcc on a Pi3, so just leave it overnight!

User avatar
jahboater
Posts: 6941
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: Raspian to conservative / old compiler / cross-compiler

Fri Dec 16, 2016 10:13 pm

MikeTheBiker wrote: 4.9[.1 / .2] is outdated, Installing in on the Pi is not an option - I need a cross-compiler.
Installing GCC on the Pi is trivial - I have many Pi's and GCC 6.2 runs on all of them (including a Pi Zero - which to be fair does take a long time to install).
MikeTheBiker wrote:Cross-compiling with clang for Raspi seems not possible - at least I found nothing about on the web. So the only solution is gcc 4.9
Just do "sudo apt install clang" - how hard is that?
MikeTheBiker wrote:Compiling on the Raspi is not an option - so good cross-compiling support is mandatory!
GCC itself is actually the biggest thing I compile on a Pi, last time I looked it was about 17 million lines of code in 104,000 source files - how big is your project that you cant compile it on Pi?
Last edited by jahboater on Fri Dec 16, 2016 10:42 pm, edited 1 time in total.

MikeTheBiker
Posts: 8
Joined: Fri Dec 16, 2016 9:32 am

Re: Raspian to conservative / old compiler / cross-compiler

Fri Dec 16, 2016 10:28 pm

I compile on the Pi all the time. Sure it's not as fast as my desktop PC but quite usable. Heck, I even built Qt 5 on an original Pi. New Pis are many times faster.


My dev machine has 3 screens, 16 G Ram, a fast i7 and a fast SSD. IntelliJ and CLion installed. Do you really think I want to leave those things behind and compile on Raspi??

User avatar
jahboater
Posts: 6941
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: Raspian to conservative / old compiler / cross-compiler

Fri Dec 16, 2016 10:36 pm

MikeTheBiker wrote:
I compile on the Pi all the time. Sure it's not as fast as my desktop PC but quite usable. Heck, I even built Qt 5 on an original Pi. New Pis are many times faster.


My dev machine has 3 screens, 16 G Ram, a fast i7 and a fast SSD. IntelliJ and CLion installed. Do you really think I want to leave those things behind and compile on Raspi??
My dev machine only has one screen, but it is a 4GHz i7 with 16GB ram and a fast SSD.
I compile stuff on Pi's all the time too. I do choose a Pi3 though, as a Pi Zero is a bit tedious for a large build.
There must be something wrong with your makefile or build setup if you are continually having to recompile so much that it takes a far too long on a Pi3.
It is quad core, have you tried make -j4 ?

MikeTheBiker
Posts: 8
Joined: Fri Dec 16, 2016 9:32 am

Re: Raspian to conservative / old compiler / cross-compiler

Fri Dec 16, 2016 10:42 pm

Code: Select all

Just do "sudo apt install clang" - how hard is that?
It's not hard - it's not even an option. Raspi is a nice little embedded device but it's clearly not a development-machine - see my answer above!
how big is your project that you cant compile it on Pi?
Turnaround-time is the keyword.
If you can leave your computer for x-hours while your program compiles - no problem. You can do something else. But it matters if it takes 1sec, 5secs or even 30secs to compile if you develop on a daily base. If you try something out - type, compile, type compile... every second counts. I program because I like not because I'm masochist!

User avatar
jahboater
Posts: 6941
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: Raspian to conservative / old compiler / cross-compiler

Fri Dec 16, 2016 11:08 pm

MikeTheBiker wrote:

Code: Select all

Just do "sudo apt install clang" - how hard is that?
It's not hard - it's not even an option. Raspi is a nice little embedded device but it's clearly not a development-machine - see my answer above!
I think you are getting the Pi mixed up with the Arduino.
The Pi most definitely is a full development system - yes not as fast as an Intel PC I agree, but very usable and complete.
It comes with an astonishing collection of languages and support tools.
MikeTheBiker wrote:
how big is your project that you cant compile it on Pi?
Turnaround-time is the keyword.
If you can leave your computer for x-hours while your program compiles - no problem. You can do something else. But it matters if it takes 1sec, 5secs or even 30secs to compile if you develop on a daily base. If you try something out - type, compile, type compile... every second counts. I program because I like not because I'm masochist!
What are you doing that takes x hours? I was recently compiling a single .c file that was 15,500 lines (much bigger than normal) it takes 1.5 sec on the 4GHz Intel PC, and 10 seconds on the Pi.
But in real life who has source files that big?
No, it would normally be split into multiple smaller files. Make would ensure that only the one small file you have edited gets recompiled. Yes you could have changed a header but that's less common.
And if multiple files do need recompiling, make -j does 4 or so of them at the same time on the 4 cores.
Small source files build in less than a second, usually much less.

There is a frequent reaction that because the Pi is small and cheap you cant build on it and you have to spend days of effort setting up cross compiling. Wrong!

If you remain convinced that the Pi is not a development platform, you might be better off with something else.
About 11 million people think otherwise though ;)

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

Re: Raspian to conservative / old compiler / cross-compiler

Fri Dec 16, 2016 11:35 pm

MikeTheBiker,
My dev machine has 3 screens, 16 G Ram, a fast i7 and a fast SSD. IntelliJ and CLion installed. Do you really think I want to leave those things behind and compile on Raspi??
Ooo, such luxury, beyond my wildest dreams.

Given that you are such a wiz, I'm sure getting yourself setup with a cross-compile environment will be a breeze.

Of course you then have to move the executable to the Pi to see if it works which will slow you down a bit...
Raspi is a nice little embedded device but it's clearly not a development-machine..
This makes me chuckle. The Pi is so much faster and more capable than the 100MHz 486 I was compiling Linux kernels on in 1997!

To be more serious. Here is how I tackle things today.

1) Develop the bulk of the code in the luxury of my desktop machine. Nice and fast. Be that C++ or node.js or whatever.

2) When that looks good move the source to the Pi and build it there.

3) Of course some parts will be Pi specific. That is pretty small fry and can be iterated on the Pi itself fast enough.

My experience of messing with cross-compilers over the years has been that it's a pain to set up and then use. The above procedure is much quicker/easier.
Memory in C++ is a leaky abstraction .

User avatar
jahboater
Posts: 6941
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: Raspian to conservative / old compiler / cross-compiler

Fri Dec 16, 2016 11:48 pm

Heater wrote: 1) Develop the bulk of the code in the luxury of my desktop machine. Nice and fast. Be that C++ or node.js or whatever.

2) When that looks good move the source to the Pi and build it there.

3) Of course some parts will be Pi specific. That is pretty small fry and can be iterated on the Pi itself fast enough.

My experience of messing with cross-compilers over the years has been that it's a pain to set up and then use. The above procedure is much quicker/easier.
That's not dissimilar to what I do - and it helps make sure your code is portable.
I suspect though that most Pi projects are fairly small, you don't need millions of lines of code.
In which case just develop it on the Pi.
And how many people who go the cross compiler route spend more time setting it up than the project would have taken to develop on the Pi ? (or give up completely as its too much hastle!).
Last edited by jahboater on Fri Dec 16, 2016 11:51 pm, edited 2 times in total.

User avatar
rpdom
Posts: 18532
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Raspian to conservative / old compiler / cross-compiler

Fri Dec 16, 2016 11:48 pm

MikeTheBiker wrote:My dev machine has 3 screens, 16 G Ram, a fast i7 and a fast SSD. IntelliJ and CLion installed. Do you really think I want to leave those things behind and compile on Raspi??
My general purpose laptop has 3 screens, 16 G RAM, a fast i7 and a fast SSD.

I compile stuff on my Raspis all the time. :D

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

Re: Raspian to conservative / old compiler / cross-compiler

Sat Dec 17, 2016 6:05 pm

rpdom wrote:My general purpose laptop has 3 screens, 16 G RAM, a fast i7 and a fast SSD.
How do you fit all that stuff on your lap when you use it?

I can definitely imagine someone so used to a specific integrated development environment that they have trouble using more widely available tools. This tendency seems the main reason Microsoft put such a disproportionate amount of effort into the their IDE. Although Microsoft C underperforms, you can now use clang/GCC in Visual Studio. Still, it seems the educational community has outsmarted them all by refusing to install any meaningful programming tools under Windows in the school computing labs. It is amazing how a little SBC marketed as a development platform to teach programming has changed things. A new curriculum also makes a difference.

When you complain about the version of the Debian compiler, I think you are confusing the system compiler with the one you personally need. The system compiler has been verified to correctly compile the kernel, utilities, X windows and the thousands of other programs included in the Raspbian distribution. For many years Linus said the only compiler that correctly compiled the kernel was the 2.7.x series. In those days the developers of GCC didn't appear to care whether changes broke Linux, maybe because it was a minor project used by hobbyists and a few scientists at the national labs. These days there is regression testing, however, things can still break. Therefore, the system compiler usually takes a very conservative approach to updates.

As mentioned, compiling new versions of gcc on the Pi is fairly easy. If you decide to do this, my recommendation is to include this one line patch to enable the Intel/MIT Cilkplus parallel programming extensions that are built by default only for Intel compatible hardware. Although the above link describes compiling GCC version 5.0, the upstream patches to cilkrts haven't made it back downstream to GCC version 6.2 at least.

There are surely people using cross compilers with the Raspberry Pi. Given the hundreds of libraries included with Raspbian, a useful cross-compiler development platform could be quite complicated. While I can't speak for the foundation, using the Pi to teach computer science to children seems their main focus. Cross compiling assumes that another computer exists which can be used for software development. The fact that no such computers already existed in schools is one of the problems the Pi attempts to solve. In this setting a cross compiler that runs on the Pi and produces PDP-11 code to use in the SIMH simulator is more practical.

Aside from focus, another reason there is no standard cross-compiler development environment for the Pi is the diversity of development platforms. A standard cross compiler would have to be available for Arch, Debian, Fedora, OSX, Ubuntu, Windows 7 and maybe Windows 10. How standard could that be?

User avatar
karrika
Posts: 1317
Joined: Mon Oct 19, 2015 6:21 am
Location: Finland

Re: Raspian to conservative / old compiler / cross-compiler

Sat Dec 17, 2016 6:46 pm

Funny thread. There is many plugins available for Raspbian only, like SPI, GPIO. Even for multiple platform sources you need to debug the code in the real envuronment.
At least Qt5 libraries are available and compiling QLC+ takes a few minutes. Creating the code and testing it takes the whole evening.

The Hero Quest Allegro code with light sensitive game pegs was entirely created on a PiZero. A large program with ambient sounds, DMX light support, full screen game board. After changing something the inremental compile and linking was only 6 minutes.

I fine tuned the code several times during Ropecon 2016. A PiZero is a very capable development platform imho.

User avatar
Penthux
Posts: 79
Joined: Thu Oct 11, 2012 7:33 am
Location: United Kingdom

Re: Raspian to conservative / old compiler / cross-compiler

Mon Dec 19, 2016 2:52 pm

MikeTheBiker wrote:It's quite hard to compile a cross-compiler yourself
I disagree. http://docs.slackware.com/howtos:hardwa ... s-compiler = quite easy. All the hard work has already been done for you. :P
Penthux
------------
Slackware ARM on a Raspberry Pi - SARPi
http://sarpi.co.uk
"Slackware ARM - it's not for NOOBS!"

Aydan
Posts: 742
Joined: Fri Apr 13, 2012 11:48 am
Location: Germany, near Lake Constance

Re: Raspian to conservative / old compiler / cross-compiler

Mon Dec 19, 2016 4:43 pm

Just to add my 2 cents worth.
I mostly develop in python on my Win7 machine in Eclipse/Pydev, but I develop remotely. Meaning all the sources are on the Pi, shared via Samba. I have a little debug wrapper script that connects automatically to the PyDev debug server on the machine i'm sshing in from, so develop in luxury ;) , run on target.

So for C/C++ development this would in effect work just the same.
Setup your source directory for samba sharing.
Setup GDB for remote debugging
SHH into Pi
Type Make
run program
Done

No need to either crosscompile or give up your fancy triple-head development machine.

On another note: If you compile every few seconds, youre doing something wrong!
Think, type, compile, debug, repeat.

Regards
Aydan

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

Re: Raspian to conservative / old compiler / cross-compiler

Mon Dec 19, 2016 8:52 pm

Aydan,
If you compile every few seconds, youre doing something wrong!
I'm old school too but:

If your editor can syntax check your code as you type it that is good. You don't have to wait for the compile, run, debug cycle to see where you made a typo.

If your editor can compile your code as you type that is even better, then those mis-spelled and hence undefined functions/methods/variables show up as you type. How is that bad?

Finally, if your editor can actually run the code as you type you are going to see weird behavior as you work. How is that bad?

This is pretty much not possible in C++ as it takes forever to compile. It has been shown to work in other languages.

But hey, I'm with you on the "think" part.
Memory in C++ is a leaky abstraction .

Aydan
Posts: 742
Joined: Fri Apr 13, 2012 11:48 am
Location: Germany, near Lake Constance

Re: Raspian to conservative / old compiler / cross-compiler

Mon Dec 19, 2016 8:58 pm

If you use Eclipse for C/C++ development, you'll only have to point it to your library headers and it will do syntax checking and autocomplete by doing code analysis without compiling. It only complains if it's missing libraries.
This is worse in e.g. Python for some platform specific binary extensions.

Regards
Aydan

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

Re: Raspian to conservative / old compiler / cross-compiler

Mon Dec 19, 2016 10:33 pm

Heater wrote:Finally, if your editor can actually run the code as you type you are going to see weird behavior as you work. How is that bad?
I always see weird behaviour when I work. Last night I changed the oil in the car: it took longer to find my keys afterwards then anything else.

User avatar
Gavinmc42
Posts: 5482
Joined: Wed Aug 28, 2013 3:31 am

Re: Raspian to conservative / old compiler / cross-compiler

Tue Dec 20, 2016 1:29 am

Ready for flaming? No war please, personal opinion here.

Are you compiling old stuff?
Or do you want to DIY programs?
Other languages compile faster.
Lazarus/Free Pascal, Rust ........

I have compiled both of these on Pi's and they compile themselves much faster than GCC.
These are stronger typed languages which means less need to compile,test,edit,compile,test,edit....
I would say if you are using C you are an old conservative :lol:

As people have said GCC 6.2 installs and works, but boy does it take time to compile itself.
The old 4.8 etc is there because not everything has been checked to compile on 6.2.

I have nothing against C, been using it for decades, but Pi's are for education.
Nothing wrong with learning new languages, I still get buzz when a new one can compile on a Pi.
That to me is the miracle, the latest stuff works on Pi's.
These little toys might be a bit slow, but then so am I these days. :lol:

As for rolling releases there are other distributions for that, Suse, Arch.....
If you have Pi 3's you are probably still running 32bit OS.
Want more speed and bleeding edge go Aarch64.

Raspbian is the kitchensink OS, does everything but it is not the latest and greatest.
I am waiting for a good 64Bit OS before really moving to Pi3's for serious development.
At the moment it is learning and tinkering with OS's, languages and coding.

Staying up to date and current is not RPF main aim, it is to educate.
Education still uses chalk and pencils :lol:

In the big wide world of Linux, RPF is a very small player pulling way above their weight .
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

User avatar
jahboater
Posts: 6941
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: Raspian to conservative / old compiler / cross-compiler

Tue Dec 20, 2016 9:31 am

Gavinmc42 wrote:I have compiled both of these on Pi's and they compile themselves much faster than GCC.
Yes indeed. But the GCC produced code will run faster. Compile once, run many times.
Gavinmc42 wrote:As people have said GCC 6.2 installs and works, but boy does it take time to compile itself.
The old 4.8 etc is there because not everything has been checked to compile on 6.2.
Just leave it overnight, who cares how long it takes?
The old default compiler works, but is out of date and no longer supported.

MikeTheBiker
Posts: 8
Joined: Fri Dec 16, 2016 9:32 am

Re: Raspian to conservative / old compiler / cross-compiler

Sat Jan 07, 2017 11:12 am

If someone else comes across this thread - here is gcc 4.9.3 for Mac:

https://github.com/MikeMitterer/xc-gcc_4.9.3_mac_rpi

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 28439
Joined: Sat Jul 30, 2011 7:41 pm

Re: Raspian to conservative / old compiler / cross-compiler

Sat Jan 07, 2017 11:26 am

MikeTheBiker wrote:If someone else comes across this thread - here is gcc 4.9.3 for Mac:

https://github.com/MikeMitterer/xc-gcc_4.9.3_mac_rpi
Thanks Mike. Presumably a Mac=>Pi Cross compiler build? How long did it take to get it going?
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Working in the Application's Team.

Return to “General discussion”