aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-11-03 11:52:32 -0400
committerJack Lloyd <[email protected]>2016-11-03 11:52:32 -0400
commitb1021ca76bb3c47b1b520421ccece38d772e5907 (patch)
tree7991dd83c4ab3d443b2d34c6a8d3bdaaf08e352c
parent277b4f703ba6354a37b5d12adebfc4f726cc72af (diff)
Add new configure argument --optimize-for-size
Uses -Os for GCC/Clang/ICC, /O1 for MSVC. Might be used in the future to control compile time features also (eg using a large precomputed table, vs not). Does not have any influence on module selection, just informs the build that a smaller binary is preferable. [ci skip]
-rwxr-xr-xconfigure.py14
-rw-r--r--src/build-data/cc/clang.txt1
-rw-r--r--src/build-data/cc/gcc.txt1
-rw-r--r--src/build-data/cc/icc.txt1
-rw-r--r--src/build-data/cc/msvc.txt1
5 files changed, 17 insertions, 1 deletions
diff --git a/configure.py b/configure.py
index 57f24c8f3..9122b38f0 100755
--- a/configure.py
+++ b/configure.py
@@ -287,6 +287,10 @@ def process_command_line(args):
action='store_false',
help='disable building shared library')
+ build_group.add_option('--optimize-for-size', dest='optimize_for_size',
+ action='store_true', default=False,
+ help='optimize for code size')
+
build_group.add_option('--no-optimizations', dest='no_optimizations',
action='store_true', default=False,
help='disable all optimizations (for debugging)')
@@ -853,6 +857,7 @@ class CompilerInfo(object):
'compile_flags': '',
'debug_info_flags': '',
'optimization_flags': '',
+ 'size_optimization_flags': '',
'coverage_flags': '',
'sanitizer_flags': '',
'shared_flags': '',
@@ -963,7 +968,14 @@ class CompilerInfo(object):
yield self.debug_info_flags
if not options.no_optimizations:
- yield self.optimization_flags
+ if options.optimize_for_size:
+ if self.size_optimization_flags != '':
+ yield self.size_optimization_flags
+ else:
+ logging.warning("No size optimization flags set for current compiler")
+ yield self.optimization_flags
+ else:
+ yield self.optimization_flags
def submodel_fixup(flags, tup):
return tup[0].replace('SUBMODEL', flags.replace(tup[1], ''))
diff --git a/src/build-data/cc/clang.txt b/src/build-data/cc/clang.txt
index 8c5baf7ca..c4a85658f 100644
--- a/src/build-data/cc/clang.txt
+++ b/src/build-data/cc/clang.txt
@@ -16,6 +16,7 @@ maintainer_warning_flags "-Qunused-arguments -Werror -Wno-error=unused-parameter
compile_flags "-c"
debug_info_flags "-g"
optimization_flags "-O3"
+size_optimization_flags "-Os"
#sanitizer_flags "-fsanitize=address,undefined -fsanitize-coverage=edge,indirect-calls,8bit-counters -fno-sanitize-recover=undefined"
sanitizer_flags "-fsanitize=address,undefined"
diff --git a/src/build-data/cc/gcc.txt b/src/build-data/cc/gcc.txt
index b086583ff..b88454ce6 100644
--- a/src/build-data/cc/gcc.txt
+++ b/src/build-data/cc/gcc.txt
@@ -17,6 +17,7 @@ maintainer_warning_flags "-Wold-style-cast -Wsuggest-override -Wshadow -Werror -
compile_flags "-c"
debug_info_flags "-g"
optimization_flags "-O3"
+size_optimization_flags "-Os"
shared_flags "-fPIC"
coverage_flags "--coverage"
diff --git a/src/build-data/cc/icc.txt b/src/build-data/cc/icc.txt
index 084d2a4f2..f1b7e5a15 100644
--- a/src/build-data/cc/icc.txt
+++ b/src/build-data/cc/icc.txt
@@ -10,6 +10,7 @@ add_lib_option -l
compile_flags "-c"
debug_info_flags "-g"
optimization_flags "-O2"
+size_optimization_flags "-Os"
lang_flags "-std=c++0x"
warning_flags "-w1"
diff --git a/src/build-data/cc/msvc.txt b/src/build-data/cc/msvc.txt
index 8231c0429..c1b820b91 100644
--- a/src/build-data/cc/msvc.txt
+++ b/src/build-data/cc/msvc.txt
@@ -11,6 +11,7 @@ add_lib_option ""
compile_flags "/nologo /c"
optimization_flags "/O2"
+size_optimization_flags "/O1"
# for debug info in the object file:
#debug_info_flags "/Z7"