blob: c65d0099c9e2518dd3f4cae523908daa9dcc922b [file] [log] [blame]
Davide Pesavento682b2af2024-02-23 21:25:41 -05001# Davide Pesavento (LIP6), 2016
Davide Pesavento1349d2d2016-08-09 06:43:57 +02002
3def options(opt):
4 opt.add_option('--with-sanitizer', action='store', default='', dest='sanitizers',
5 help='Comma-separated list of compiler sanitizers to enable [default=none]')
6
7def configure(conf):
8 for san in conf.options.sanitizers.split(','):
9 if not san:
10 continue
11
12 sanflag = '-fsanitize=%s' % san
13 conf.start_msg('Checking if compiler supports %s' % sanflag)
14
15 if conf.check_cxx(cxxflags=['-Werror', sanflag, '-fno-omit-frame-pointer'],
16 linkflags=[sanflag], mandatory=False):
17 conf.end_msg('yes')
18 conf.env.append_unique('CXXFLAGS', [sanflag, '-fno-omit-frame-pointer'])
19 conf.env.append_unique('LINKFLAGS', [sanflag])
20 else:
21 conf.end_msg('no', color='RED')
22 conf.fatal('%s sanitizer is not supported by the current compiler' % san)