aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xconfigure.py42
-rw-r--r--doc/manual/fuzzing.rst5
-rw-r--r--src/build-data/cc/clang.txt11
-rw-r--r--src/build-data/cc/gcc.txt10
4 files changed, 49 insertions, 19 deletions
diff --git a/configure.py b/configure.py
index 5df583c03..99240effc 100755
--- a/configure.py
+++ b/configure.py
@@ -354,6 +354,9 @@ def process_command_line(args): # pylint: disable=too-many-locals
build_group.add_option('--with-sanitizers', action='store_true', default=False, dest='with_sanitizers',
help='enable ASan/UBSan checks')
+ build_group.add_option('--enable-sanitizers', metavar='SAN', default='',
+ help='enable specific sanitizers')
+
build_group.add_option('--with-stack-protector', dest='with_stack_protector',
action='store_false', default=None, help=optparse.SUPPRESS_HELP)
@@ -1042,7 +1045,8 @@ class CompilerInfo(InfoObject): # pylint: disable=too-many-instance-attributes
lex = lex_me_harder(
infofile,
[],
- ['cpu_flags', 'so_link_commands', 'binary_link_commands', 'mach_abi_linking', 'isa_flags'],
+ ['cpu_flags', 'so_link_commands', 'binary_link_commands',
+ 'mach_abi_linking', 'isa_flags', 'sanitizers'],
{
'binary_name': None,
'linker_name': None,
@@ -1059,7 +1063,6 @@ class CompilerInfo(InfoObject): # pylint: disable=too-many-instance-attributes
'optimization_flags': '',
'size_optimization_flags': '',
'coverage_flags': '',
- 'sanitizer_flags': '',
'stack_protector_flags': '',
'shared_flags': '',
'lang_flags': '',
@@ -1095,7 +1098,7 @@ class CompilerInfo(InfoObject): # pylint: disable=too-many-instance-attributes
self.output_to_exe = lex.output_to_exe
self.output_to_object = lex.output_to_object
self.preproc_flags = lex.preproc_flags
- self.sanitizer_flags = lex.sanitizer_flags
+ self.sanitizers = lex.sanitizers
self.shared_flags = lex.shared_flags
self.size_optimization_flags = lex.size_optimization_flags
self.so_link_commands = lex.so_link_commands
@@ -1183,33 +1186,48 @@ class CompilerInfo(InfoObject): # pylint: disable=too-many-instance-attributes
yield options.os
yield options.cpu
- abi_link = list()
+ abi_link = set()
for what in mach_abi_groups():
if what in self.mach_abi_linking:
flag = self.mach_abi_linking.get(what)
if flag != None and flag != '' and flag not in abi_link:
- abi_link.append(flag)
+ abi_link.add(flag)
if options.msvc_runtime:
- abi_link.append("/" + options.msvc_runtime)
+ abi_link.add("/" + options.msvc_runtime)
if options.with_stack_protector and self.stack_protector_flags != '':
- abi_link.append(self.stack_protector_flags)
+ abi_link.add(self.stack_protector_flags)
if options.with_coverage_info:
if self.coverage_flags == '':
raise UserError('No coverage handling for %s' % (self.basename))
- abi_link.append(self.coverage_flags)
+ abi_link.add(self.coverage_flags)
- if options.with_sanitizers:
- if self.sanitizer_flags == '':
+ if options.with_sanitizers or options.enable_sanitizers != '':
+ if not self.sanitizers:
raise UserError('No sanitizer handling for %s' % (self.basename))
- abi_link.append(self.sanitizer_flags)
+
+ default_san = self.sanitizers['default'].split(',')
+
+ if options.enable_sanitizers:
+ san = options.enable_sanitizers.split(',')
+ else:
+ san = default_san
+
+ for s in san:
+ if s not in self.sanitizers:
+ raise UserError('No flags defined for sanitizer %s in %s' % (s, self.basename))
+
+ if s == 'default':
+ abi_link.update([self.sanitizers[s] for s in default_san])
+ else:
+ abi_link.add(self.sanitizers[s])
if options.with_openmp:
if 'openmp' not in self.mach_abi_linking:
raise UserError('No support for OpenMP for %s' % (self.basename))
- abi_link.append(self.mach_abi_linking['openmp'])
+ abi_link.add(self.mach_abi_linking['openmp'])
abi_flags = ' '.join(sorted(abi_link))
diff --git a/doc/manual/fuzzing.rst b/doc/manual/fuzzing.rst
index 8260582d6..9435536fe 100644
--- a/doc/manual/fuzzing.rst
+++ b/doc/manual/fuzzing.rst
@@ -19,9 +19,12 @@ need to compile libFuzzer::
Then build the fuzzers::
$ ./configure.py --cc=clang --build-fuzzer=libfuzzer --unsafe-fuzzer-mode \
- --cc-abi-flags='-fsanitize=address,undefined -fsanitize-coverage=edge,indirect-calls,8bit-counters -fno-sanitize-recover=undefined'
+ --enable-sanitizers=coverage,address,undefined
$ make fuzzers
+Enabling 'coverage' sanitizer flags is required for libFuzzer to work.
+Address sanitizer and undefined sanitizer are optional.
+
The fuzzer binaries will be in `build/fuzzer`. Simply pick one and run it, optionally
also passing a directory containing corpus inputs.
diff --git a/src/build-data/cc/clang.txt b/src/build-data/cc/clang.txt
index 508551eef..817a0610c 100644
--- a/src/build-data/cc/clang.txt
+++ b/src/build-data/cc/clang.txt
@@ -9,8 +9,15 @@ maintainer_warning_flags "-Wunreachable-code -Wdocumentation -Qunused-arguments
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"
+
+<sanitizers>
+default -> address,undefined
+
+address -> "-fsanitize=address"
+undefined -> "-fsanitize=undefined -fno-sanitize-recover=undefined"
+coverage -> "-fsanitize-coverage=edge,indirect-calls,8bit-counters"
+memory -> "-fsanitize=memory"
+</sanitizers>
shared_flags "-fPIC"
coverage_flags "--coverage"
diff --git a/src/build-data/cc/gcc.txt b/src/build-data/cc/gcc.txt
index 5bcb838c9..7aeb390e1 100644
--- a/src/build-data/cc/gcc.txt
+++ b/src/build-data/cc/gcc.txt
@@ -16,11 +16,13 @@ shared_flags "-fPIC"
coverage_flags "--coverage"
stack_protector_flags "-fstack-protector"
-# GCC 4.8
-sanitizer_flags "-D_GLIBCXX_DEBUG -fsanitize=address"
+<sanitizers>
+default -> iterator,address
-# GCC 4.9 and later
-#sanitizer_flags "-D_GLIBCXX_DEBUG -fsanitize=address,undefined -fno-sanitize-recover=undefined"
+iterator -> "-D_GLIBCXX_DEBUG"
+address -> "-fsanitize=address"
+undefined -> "-fsanitize=undefined -fno-sanitize-recover=undefined"
+</sanitizers>
visibility_build_flags "-fvisibility=hidden"
visibility_attribute '__attribute__((visibility("default")))'