aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xconfigure.py17
-rw-r--r--src/build-data/cc/clang.txt1
-rw-r--r--src/build-data/cc/gcc.txt5
3 files changed, 20 insertions, 3 deletions
diff --git a/configure.py b/configure.py
index 986081279..378e12c82 100755
--- a/configure.py
+++ b/configure.py
@@ -1045,7 +1045,7 @@ class CompilerInfo(InfoObject): # pylint: disable=too-many-instance-attributes
lex = lex_me_harder(
infofile,
[],
- ['cpu_flags', 'so_link_commands', 'binary_link_commands',
+ ['cpu_flags', 'cpu_flags_no_debug', 'so_link_commands', 'binary_link_commands',
'mach_abi_linking', 'isa_flags', 'sanitizers'],
{
'binary_name': None,
@@ -1062,6 +1062,7 @@ class CompilerInfo(InfoObject): # pylint: disable=too-many-instance-attributes
'debug_info_flags': '-g',
'optimization_flags': '',
'size_optimization_flags': '',
+ 'sanitizer_optimization_flags': '',
'coverage_flags': '',
'stack_protector_flags': '',
'shared_flags': '',
@@ -1085,6 +1086,7 @@ class CompilerInfo(InfoObject): # pylint: disable=too-many-instance-attributes
self.binary_link_commands = lex.binary_link_commands
self.binary_name = lex.binary_name
self.cpu_flags = lex.cpu_flags
+ self.cpu_flags_no_debug = lex.cpu_flags_no_debug
self.compile_flags = lex.compile_flags
self.coverage_flags = lex.coverage_flags
self.debug_info_flags = lex.debug_info_flags
@@ -1100,6 +1102,7 @@ class CompilerInfo(InfoObject): # pylint: disable=too-many-instance-attributes
self.preproc_flags = lex.preproc_flags
self.sanitizers = lex.sanitizers
self.sanitizer_types = []
+ self.sanitizer_optimization_flags = lex.sanitizer_optimization_flags
self.shared_flags = lex.shared_flags
self.size_optimization_flags = lex.size_optimization_flags
self.so_link_commands = lex.so_link_commands
@@ -1252,6 +1255,9 @@ class CompilerInfo(InfoObject): # pylint: disable=too-many-instance-attributes
def cc_compile_flags(self, options, with_debug_info=None, enable_optimizations=None):
def gen_flags(with_debug_info, enable_optimizations):
+
+ sanitizers_enabled = options.with_sanitizers or (len(options.enable_sanitizers) > 0)
+
if with_debug_info is None:
with_debug_info = options.with_debug_info
if enable_optimizations is None:
@@ -1267,12 +1273,21 @@ class CompilerInfo(InfoObject): # pylint: disable=too-many-instance-attributes
else:
logging.warning("No size optimization flags set for current compiler")
yield self.optimization_flags
+ elif sanitizers_enabled and self.sanitizer_optimization_flags != '':
+ yield self.sanitizer_optimization_flags
else:
yield self.optimization_flags
if options.arch in self.cpu_flags:
yield self.cpu_flags[options.arch]
+ if options.arch in self.cpu_flags_no_debug:
+
+ # Only enable these if no debug/sanitizer options enabled
+
+ if not (options.debug_mode or sanitizers_enabled):
+ yield self.cpu_flags_no_debug[options.arch]
+
return (' '.join(gen_flags(with_debug_info, enable_optimizations))).strip()
@staticmethod
diff --git a/src/build-data/cc/clang.txt b/src/build-data/cc/clang.txt
index 817a0610c..d8c028191 100644
--- a/src/build-data/cc/clang.txt
+++ b/src/build-data/cc/clang.txt
@@ -8,6 +8,7 @@ warning_flags "-Wall -Wextra -Wpedantic -Wshadow -Wstrict-aliasing -Wstrict-over
maintainer_warning_flags "-Wunreachable-code -Wdocumentation -Qunused-arguments -Werror -Wno-error=unused-parameter -Wno-error=unreachable-code"
optimization_flags "-O3"
+sanitizer_optimization_flags "-O1 -fno-optimize-sibling-calls -fno-omit-frame-pointer"
size_optimization_flags "-Os"
<sanitizers>
diff --git a/src/build-data/cc/gcc.txt b/src/build-data/cc/gcc.txt
index 7aeb390e1..0b12e00bc 100644
--- a/src/build-data/cc/gcc.txt
+++ b/src/build-data/cc/gcc.txt
@@ -10,6 +10,7 @@ warning_flags "-Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing
maintainer_warning_flags "-Wstrict-overflow=5 -Wold-style-cast -Wsuggest-override -Wshadow -Werror -Wno-error=strict-overflow"
optimization_flags "-O3"
+sanitizer_optimization_flags "-O1 -fno-optimize-sibling-calls -fno-omit-frame-pointer"
size_optimization_flags "-Os"
shared_flags "-fPIC"
@@ -69,10 +70,10 @@ arm32:neon -> "-mfpu=neon"
arm64:neon -> ""
</isa_flags>
-<cpu_flags>
+<cpu_flags_no_debug>
x86_32 -> "-momit-leaf-frame-pointer"
x86_64 -> "-momit-leaf-frame-pointer"
-</cpu_flags>
+</cpu_flags_no_debug>
# Flags set here are included at compile and link time
<mach_abi_linking>