Add config option for address sanitizer
authorSakari Bergen <sakari.bergen@beatwaves.net>
Mon, 6 Jan 2014 15:03:46 +0000 (17:03 +0200)
committerSakari Bergen <sakari.bergen@beatwaves.net>
Mon, 6 Jan 2014 15:04:07 +0000 (17:04 +0200)
wscript

diff --git a/wscript b/wscript
index e68780f1e0a09c54739056dd331235521c836f2a..d657ea2cad56db0ed3c3f6c266aaedbe597c1e22 100644 (file)
--- a/wscript
+++ b/wscript
@@ -162,6 +162,11 @@ def set_compiler_flags (conf,opt):
             # Prevents visibility issues in standard headers
             conf.define("_DARWIN_C_SOURCE", 1)
 
+    if conf.options.asan:
+        conf.check_cxx(cxxflags=["-fsanitize=address"], linkflags=["-fsanitize=address"])
+        cxx_flags.append('-fsanitize=address')
+        linker_flags.append('-fsanitize=address')
+
     if is_clang and platform == "darwin":
         # Silence warnings about the non-existing osx clang compiler flags
         # -compatibility_version and -current_version.  These are Waf
@@ -502,6 +507,8 @@ def options(opt):
                     help='Do not ask questions that require confirmation during the build')
     opt.add_option('--cxx11', action='store_true', default=False, dest='cxx11',
                     help='Turn on c++11 compiler flags (-std=c++11)')
+    opt.add_option('--address-sanitizer', action='store_true', default=False, dest='asan',
+                    help='Turn on AddressSanitizer (requires GCC >= 4.8 or clang)')
     for i in children:
         opt.recurse(i)