Davide Pesavento | 1349d2d | 2016-08-09 06:43:57 +0200 | [diff] [blame] | 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
| 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) |