allowing us to pass flags to gcc

Hi,

We don't know what's going on when the IDE compiles our code and we do not know what flags are used.

To better optimize my application, I use the provided Makefile and compile in cygwin, I did some tests with some gcc flags and the result is impressive.

Compile with IDE or Makefile without mod : 13788 bytes

Compile with Makefile adding "-funsigned-char -fno-split-wide-types -Wl,--relax -fno-inline-small-functions -mcall-prologues" to CFLAGS : 12736 bytes

Having a place in the IDE to tweak the command line used or to add custom flags would be a big +

Is this in Arduino 12? A bunch of code got significantly bigger in 12 due only to changed compiler behavior, and I've never found or seen an explanation of why... Do you now if gcc 4.0.2 (used for Arduino 11 and earlier) behaved differently by default than 4.3.0 (used in 12) ?

I think the newer versions of GCC generate bigger binaries. Things should be smaller in 0013. Custom gcc arguments would be nice, but you can also just use the makefile.

FYI, I tried mags flags (added them to the array list in Compiler.java and Library.java) and it got the mpguino to fit in 0012 in 13099 bytes, which is down from 16935 bytes. Though things are behaving a little strangely ::slight_smile:

It was 14194 bytes when compiled on XP in version 0011 (different platforms can make different size avr hex files, for no good reason).

Also worth noting that I tried to do a hack by modifying diecimila.build.f_cpu:

diecimila.build.f_cpu=16000000L -funsigned-char -fno-split-wide-types -Wl,--relax -fno-inline-small-functions -mcall-prologues

but Runtime.exec wants all the parameters to have their own spot in the arrayList I think. Could add a

diecimila.build.userflags= -funsigned-char -fno-split-wide-types -Wl,--relax -fno-inline-small-functions -mcall-prologues

and parse it I suppose and add each item to the arraylist(s).

I have a keen interest in this topic since Bitlash can use all the space it can get.

Can you say a little more about "behaving a little strangely"?

Edit: fyi/fwiw Bitlash 0.9 saves 700+ bytes with these flags added to 0012 (13532 shrinks to 12824). Preliminary tests OK.

-br

I think the newer versions of GCC generate bigger binaries. Things should be smaller in 0013. Custom gcc arguments would be nice, but you can also just use the makefile.

My application was bigger with 0011, and smaller with 0012, using the IDE.
I also use gcc 4.3.2 and latest avrlibc but it grows size by 1K :frowning:

Can you say a little more about "behaving a little strangely"?

I didn't have to wait long to see strangeness. The first thing it does is go to the mpguino setup screen where I saw a "/" instead of a "0" for the character being edited. It is the first time it ever ran under 0012 though so it might be something else other than the optimizations.

Here's a patched copy of Compiler.java with the amended flags:

http://bitlash.net/downloads/cflags-patch/Compiler.java

-br

My application was bigger with 0011, and smaller with 0012, using the IDE.

Magister: you're running linux with an independently installed avr-gcc? Or did your app actually shrink going from gcc 4.0.2 (Arduino 0011) to gcc 4.3.0 (Arduino 0012) Us windows/mac users get a copy of gcc packaged with the Arduino environment; I gather it goes somewhat differently in the linux world.

There are two issues with 12; one is the re-write of certain core Arudino functions. (For instance, the timer0 interrupt code is bigger.) Probably these make most sketches SLIGHTLY bigger, but that's not the big concern. The other issue is that the newer version of gcc seems to produce about 10% more object code for the same source code. :frowning: I haven't seen this explained, though I've asked several places. I may have to analyze some object files myself!

I am in Windows, the compile test was between arduino-0011 and arduino-0012, the java IDE and the integrated WinAVR toolchains. And yes my app in 0012 is smaller than 0011. I do not use really "wiring" modules in my code.

I also have a full cygwin installed and I recompiled the latest AVR binutils/gcc/libc (took 3 hours...) and I noticed that with the latest libc I gained 4 bytes, but with gcc432 I lost 1K :frowning:

At least in cygwin it's easier to play with libraries, Makefile, gcc options, etc