Compile options: default to -O2 when -Os is not available
authorWolfgang Denk <wd@denx.de>
Sun, 1 May 2011 12:00:27 +0000 (14:00 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Mon, 2 May 2011 00:50:46 +0000 (02:50 +0200)
Recent versions of GCC for PowerPC systems suffer from some compiler
bugs which prevent the use of "--enable-target-optspace" in their
configuration, which makes the compiler option "-Os" unavailable;
for reference see

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43810
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48278
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45053

In the result, BusyBox will be compiled without any optimization
options, which causes a huge binary (1.8 MiB for default configuration
on PPC, built with gcc 54.51 from the Yocto / Poky / OpenEmbedded tool
chains).  This commit changes behaviour so "-O2" gets used as fallback
when "-Os" is not available.  This reduces the image size in above
test to 1.3 MiB.  This is still 10...15% more then what we get with
"-Os", but much better than using no optimization at all.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Makefile.flags

index 363300b..b3e1371 100644 (file)
@@ -58,14 +58,14 @@ CFLAGS += $(call cc-option,-falign-functions=1 -falign-jumps=1 -falign-labels=1
 #CFLAGS += $(call cc-option,-Wconversion,)
 
 ifneq ($(CONFIG_DEBUG),y)
-CFLAGS += $(call cc-option,-Os,)
+CFLAGS += $(call cc-option,-Os,$(call cc-option,-O2,))
 else
 CFLAGS += $(call cc-option,-g,)
 #CFLAGS += "-D_FORTIFY_SOURCE=2"
 ifeq ($(CONFIG_DEBUG_PESSIMIZE),y)
 CFLAGS += $(call cc-option,-O0,)
 else
-CFLAGS += $(call cc-option,-Os,)
+CFLAGS += $(call cc-option,-Os,$(call cc-option,-O2,))
 endif
 endif