summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Kconfig10
-rw-r--r--Makefile6
2 files changed, 15 insertions, 1 deletions
diff --git a/Kconfig b/Kconfig
index ea2c836115..cbb691e160 100644
--- a/Kconfig
+++ b/Kconfig
@@ -46,6 +46,16 @@ config LOCALVERSION_AUTO
which is done within the script "scripts/setlocalversion".)
+config CC_OPTIMIZE_FOR_SIZE
+ bool "Optimize for size"
+ depends on !SPL_BUILD
+ default y
+ help
+ Enabling this option will pass "-Os" instead of "-O2" to gcc
+ resulting in a smaller U-Boot image.
+
+ This option is enabled by default for U-Boot.
+
endmenu # General setup
menu "Boot images"
diff --git a/Makefile b/Makefile
index 0fea5c2681..9646859083 100644
--- a/Makefile
+++ b/Makefile
@@ -529,7 +529,11 @@ else
include/config/auto.conf: ;
endif # $(dot-config)
-KBUILD_CFLAGS += -Os #-fomit-frame-pointer
+ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
+KBUILD_CFLAGS += -Os
+else
+KBUILD_CFLAGS += -O2
+endif
ifdef BUILD_TAG
KBUILD_CFLAGS += -DBUILD_TAG='"$(BUILD_TAG)"'
OpenPOWER on IntegriCloud