How to change avr-gcc settings?


I’m trying to change some avr-gcc options without success. Changing and copying the makefile has no effect.
I took a look at the arduino IDE source. It looks like the compiler settings are “hard-coded”:

static private List getCommandCompilerC(String avrBasePath, List includePaths,
    String sourceName, String objectName) {
    List baseCommandCompiler = new ArrayList(Arrays.asList(new String[] {
      avrBasePath + "avr-gcc",
      "-c", // compile, don't link
      "-g", // include debugging info (so errors include line numbers)
      "-Os", // optimize for size
      "-w", // surpress all warnings
      "-ffunction-sections", // place each function in its own section
      "-mmcu=" + Preferences.get("boards." + Preferences.get("board") + ".build.mcu"),
      "-DF_CPU=" + Preferences.get("boards." + Preferences.get("board") + ".build.f_cpu"),

So how can I change compiler options, e.g. -Os → -O2; without changing the IDE source code? Are there any tricks I have missed?

Best regards,

The makefile is not used by the IDE.

AFAIK the only way to change the settings is by editing the IDE source and recompiling the IDE.