waf: add support for the macOS clang address sanitizer

This commit is contained in:
Andy Piper 2020-04-14 11:45:40 +01:00 committed by Peter Barker
parent 0e40d1cb6b
commit 6245197204
2 changed files with 17 additions and 0 deletions

View File

@ -541,6 +541,13 @@ information across clean commands, so that that information is changed
only when really necessary. Also, some tasks that don't really produce
files persist their signature. This option avoids that behavior when
cleaning the build.
''')
g.add_option('--asan',
action='store_true',
help='''Build using the macOS clang Address Sanitizer. In order to run with
Address Sanitizer support llvm-symbolizer is required to be on the PATH.
This option is only supported on macOS versions of clang.
''')
def build(bld):

View File

@ -385,6 +385,12 @@ class sitl(Board):
'-O3',
]
if 'clang++' in cfg.env.COMPILER_CXX and cfg.options.asan:
env.CXXFLAGS += [
'-fsanitize=address',
'-fno-omit-frame-pointer',
]
env.LIB += [
'm',
]
@ -393,6 +399,10 @@ class sitl(Board):
cfg.check_feenableexcept()
env.LINKFLAGS += ['-pthread',]
if cfg.env.DEBUG and 'clang++' in cfg.env.COMPILER_CXX and cfg.options.asan:
env.LINKFLAGS += ['-fsanitize=address']
env.AP_LIBRARIES += [
'AP_HAL_SITL',
'SITL',