Go Down

Topic: Supplying compiler option flags within Arduino IDE (Read 11697 times) previous topic - next topic

chessplayer

Is it possible to specify compiler options to avr-gcc within the context of the Arduino IDE?  I'd rather not have to use a separate makefile.

Specifically, I'd like to adjust the values for -O option and for the -finline-limit option.

mellis


chessplayer

As I suspected from my investigation.

I'd vote or adding at least some compilation customization capability to the IDE.

Another suggestion would be the ability to suppress the automatic inclusion of various header files.   For example, HardwareSerial.h/.cpp that eats up over one half KB of memory when instantiated for an avr1280 to implement serial ports that may never be used.

borref

Quote
... the ability to suppress the automatic inclusion of various header files

One way to accomplish this is to add

Code: [Select]
#define HardwareSerial_h

at the top of your sketch.

Other header files will have similar defines.

chessplayer

True, I could avoid including HardwareSerial, but what if I want one serial port but not all four serial ports?

The solution is to have the coder explicitly include various headers and instantiate any objects needed -- but no more than are necessary.  The chips in use just don't have that much memory available for unused objects.

Also, some of the files that are currently automatically included may be in conflict with code that might be ported to the Arduino.  This has already happened to me.

I do not argue that the automatically included resources are not useful.  I do argue that the programmer should decide what is needed.

bill2009

Well, you can always go poke around the .c .h and makefile files in \cores\arduino and make your adjustments there.

chessplayer

If I change any of the supplied source files, then it will make things more difficult for others to compile my code.

Also, the makefiles used by the IDE are (apparently) not accessible under Mac OS/X.

ricklon

If you look in the boards.txt there are values set there that are past into the compiler. It would be nice to have a build.cflags option where you could specify the flags you'd like to send to the compiler.

For instance "-s -save-temps" in order to keep all the build information in a really tough debugging situation.

With a bit of experimentation you can add this line to existing values and pass the values through, but it's more likely to break things, than help.

In the example of "-s -save-temps" the problem is more that the Java code controls all the file nameing of the output. In which case some files are overwritten by the same name so saving the temp files doesn't really work even inf the flag is included.

I'm not sure the priority for changing this area, but it might make sense before encouraging an overhaul to make it more complex is there a way to make simpler? One option is to have the Java code run a makefile, but that introduces a dependency on having make.  The other option I've used in the past has been to create an ant build.xml file, and run that file from Java.

I'm really interested what you all think about this.


Go Up