blob: c65d0099c9e2518dd3f4cae523908daa9dcc922b [file] [log] [blame]
Davide Pesavento5a1d77a2024-03-13 19:24:11 -04001# Davide Pesavento (LIP6), 2016
Davide Pesaventoc58cc7f2017-08-08 16:51:28 -05002
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)