Louis B.
Louis B.

Reputation: 517

AVR gcc version < gcc release versions -- why?

I noticed that gcc for AVR lags behind the main development stream of gcc. For example, gcc for AVR8 is 4.9.2 in Atmel Studio 7 and Arduino, and AVR32 is at 4.4.7 in Atmel Studio. Meanwhile, gcc 4.9.4 is the current 4.9 release, and development is pushing multiple branches 5.x, 6.x and 7.x (https://gcc.gnu.org/develop.html).

Update (November 2019): Atmel Studio and the Arduino toolchain are now up to gcc 5.4, which still only fully implements C++11.


My concern is that I may run into early implementation issues by using recently added features of the C++ language with an older compiler. Additionally, the development process of AVR support in gcc is unclear.

Upvotes: 2

Views: 2811

Answers (2)

jonspaceharper
jonspaceharper

Reputation: 4347

Overview

gcc supports compiling for AVR when built with certain build options and passed the correct flags. gcc built with those AVR-specific build options is avr-gcc.

Both Atmel and Arduino ship with a custom build of avr-gcc and the rest of the needed toolchain (binutils, avr-libc). Arduino is actually downstream of Atmel's toolchain, and Arduino only updates their toolchain when Atmel does.

There is a nifty blog post by Zak Kemble that has the recent builds for everything in the toolchain (avr-gcc, binutils, avr-libc), available for Windows (along with Make and AVRDUDE), Linux, and MacOS. Additionally, Arch Linux keeps an up-to-date build of avr-gcc here as a package.

For Arduino, the blog post I mentioned details how to integrate an updated build of avr-gcc into Arduino IDE and includes a build script if you want to build avr-gcc on your own. I have not used Atmel Studio and do not know if it is possible to swap out the avr-gcc build in a similar manner, but the release notes make me think it may be possible.

Caveats:

  • One point discussed on the gcc wiki but not discussed here is avr-libc, which appears largely inactive (no repo commits in several years). Even if gcc supports your target platform, avr-libc must support it, as well. As mentioned above, support is halted at gcc 5.x.
  • Atmel warns there are known limitations with C++ on AVR, and the avr-libc FAQ discusses it here. Basically, if you’re hoping for the Standard Library, you’re out of luck.

Summary:

Atmel and Arduino include avr-libc which only supports gcc through 5.x. This gives you access to C++11. You can swap this out for a newer build of avr-gcc, binutils, and the rest and continue to use the IDE (at least for Arduino). If you would like to free up your choice of IDE, use AVRDUDE or arduino-cli (which uses AVRDUDE anyway) and call them from your IDE or the command line. Lastly, there is no modern, >= C++11 Standard Library implementation available for AVR, to my knowledge (and I have looked).

Upvotes: 5

old_timer
old_timer

Reputation: 71506

If there is a particular version of GCC you want to use, just use it. Build it yourself or get a pre-built, there is no reason you need to use the Atmel sandbox.

Upvotes: 1

Related Questions