Davide Pesavento | 5a1d77a | 2024-03-13 19:24:11 -0400 | [diff] [blame^] | 1 | # Davide Pesavento (LIP6), 2016 |
Davide Pesavento | c58cc7f | 2017-08-08 16:51:28 -0500 | [diff] [blame] | 2 | |
| 3 | def 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 | |
| 7 | def 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) |