diff options
author | Jack Lloyd <[email protected]> | 2018-04-07 14:22:48 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-04-07 14:22:48 -0400 |
commit | 65afee3f1220960c0049a7ec21a97c69c60bb68f (patch) | |
tree | 4fcef4b33b3de33820fff950a62a4ec021e60bdb /configure.py | |
parent | f70ca7111ef3d6688ae77ded1b20a48497aa2936 (diff) |
Add sanitizer-specific optimization flags
Diffstat (limited to 'configure.py')
-rwxr-xr-x | configure.py | 17 |
1 files changed, 16 insertions, 1 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 |