[PATCH v2] build system: allow users to select the optimization mode
Bartosz Golaszewski
bartekgola at gmail.com
Wed Apr 15 11:43:01 UTC 2015
In some scenarios busybox performance may be prefered over its
small size.
Allow users to select the compiler optimization level by adding
appropriate config options.
Signed-off-by: Bartosz Golaszewski <bartekgola at gmail.com>
---
version 2:
- make the choice simplier for less advanced users by leaving only
the choice between optimization for speed and optimization for
size (default)
version 1:
http://lists.busybox.net/pipermail/busybox/2015-April/082765.html
Config.in | 25 +++++++++++++++++++++++++
Makefile.flags | 10 +++++-----
2 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/Config.in b/Config.in
index 07b4bf3..227fc78 100644
--- a/Config.in
+++ b/Config.in
@@ -514,6 +514,31 @@ config PIE
Most people will leave this set to 'N'.
+choice
+ prompt "Compiler optimization"
+ default OPTIMIZE_SIZE
+ help
+ Set the compiler optimization mode.
+
+config OPTIMIZE_SIZE
+ bool "Optimize for size"
+ help
+ Optimize for size. This enables all standard speed
+ optimizations that do not typically increase code size.
+ It also performs further optimizations designed to reduce
+ code size.
+
+ This is the default for busybox.
+
+config OPTIMIZE_SPEED
+ bool "Optimize for speed"
+ help
+ Perform nearly all supported optimizations that do not involve
+ a space-speed tradeoff. This option increases both compilation
+ time and the performance of the generated code.
+
+endchoice
+
config NOMMU
bool "Force NOMMU build"
default n
diff --git a/Makefile.flags b/Makefile.flags
index a1ed148..a7eaee1 100644
--- a/Makefile.flags
+++ b/Makefile.flags
@@ -61,17 +61,17 @@ CFLAGS += $(call cc-option,-fno-asynchronous-unwind-tables,)
# be fixed..
#CFLAGS += $(call cc-option,-Wconversion,)
-ifneq ($(CONFIG_DEBUG),y)
-CFLAGS += $(call cc-option,-Os,$(call cc-option,-O2,))
-else
+ifeq ($(CONFIG_DEBUG),y)
CFLAGS += $(call cc-option,-g,)
-#CFLAGS += "-D_FORTIFY_SOURCE=2"
+endif
+
ifeq ($(CONFIG_DEBUG_PESSIMIZE),y)
CFLAGS += $(call cc-option,-O0,)
+else ifeq ($(CONFIG_OPTIMIZE_SPEED),y)
+CFLAGS += $(call cc-option,-O2,)
else
CFLAGS += $(call cc-option,-Os,$(call cc-option,-O2,))
endif
-endif
# If arch/$(ARCH)/Makefile did not override it (with, say, -fPIC)...
ARCH_FPIC ?= -fpic
--
2.1.4
More information about the busybox
mailing list