ct-ng: An AVR32 GNU cross-toolchain builder
Better code generation for AVR32 processors
This project is a fork of the community cross-toolchain builder crosstool-ng.org, adding support for AVR32 processors, optimizations to produce more compact code, the latest patches from Atmel's forthcoming AVR32 GNU Toolchain 3.4.2 release and a selection of extra bug fixes from Debian, OpenEmbedded? and elsewhere.
It fetches the source code from the mainline repositories, applies the patches and compiles the whole thing to make your own version of the AVR32 GNU Toolchain which generates 3% smaller code than the Atmel releases.
Using it on Linux
Install necessary build tools (these are the Debian/Ubuntu/Mint runes):
sudo apt-get install git autoconf bash gawk g++ libncurses-dev
git clone https://firstname.lastname@example.org/git/ct-ng cd ct-ng sh bootstrap ./configure --enable-local make ./ct-ng build
If all goes well, this will place the toolchain in a folder x-tools in your home directory, and to use it you need to say:
PATH=$HOME/x-tools/avr32-unknown-none/bin:$PATH export PATH
before calling avr32-gcc and its friends.
Using other toolchain component versions
The default configuration gives you the most recent toolchain components optimized to produce the smallest AVR32 code. For further instructions on using and configuring ct-ng, consult the documentation on the crosstool-ng.org web site. In brief:
AVR32 support is enabled in the following versions of the toolchain components:
Optimizing for size
Conclusion: the smallest flash image is generated by a toolchain built by ct-ng using gcc-4.4.7 with the Atmel GNU Toolchain 3.4.2 patches and newlib-1.17.0.
Further size optimizations
Alternative inliner tuning
The extra size optimization applied in gcc-4.2 is equivalent to gcc's command-line option --param inline-call-cost=4 which tunes the size optimizer to avoid inlining functions if that would make the resulting code larger when optimizing for size.
In gcc-4.3 and 4.4 we apply the equivalent of --param max-inline-insns-auto=2 which counteracts the over-zealousness of the new function inliner introduced in gcc-4.3. Adding the same flag to Atmel GNU Toolchain 3.4.1 reduces eLua's code size from 173638 to 170890 bytes.
A strange alternative set of optimizer tunings --param inline-call-cost=0 --param max-inline-insns-auto=8 produces even smaller code with gcc-4.4, reducing eLua's code size from 168174 to 168102 bytes. These alternate flags make no sense since the inline call cost for AVR32 is 8 bytes (=4 regular instructions), not 0, and applying the same alternate flags to glib and newlib makes them slightly larger. The effectiveness of these settings on eLua may depend on the statistical distribution of the size of its inlinable functions and the number of opportunities for inlining each of them.
Graphite loop optimizer
Enabling the Graphite loop optimizer in GCC-4.4 makes almost no difference to the resulting code size. Only in one case did its -floop-interchange option save 4 bytes of code out of 200K. Note that if you enable this option in ./ct-ng menuconfig's "C Compiler" section you must also go to the "Companion libraries" section and set the PPL version to the old 0.10.0. Otherwise ./ct-ng build fails.
To Dan Kegel for the original crosstool, to Yann Morin for creating and maintaining crosstool-ng since 2006, to simplemachines.it and the GCC compile farm for providing the very fast computers used in this development and to Atmel for being open with source code.