diff options
author | Andrew Morrow <acm@10gen.com> | 2013-03-24 14:16:01 -0400 |
---|---|---|
committer | Andrew Morrow <acm@10gen.com> | 2013-04-08 20:58:23 -0400 |
commit | ad60f1bdacbcc1fe212a78f310ea73a2f07ec62a (patch) | |
tree | 754d2aa4b53b6beaa174f55fab39c359446ce380 /SConstruct | |
parent | b5aa82c6783029da7fd21480d0271731c0c770f3 (diff) | |
download | mongo-ad60f1bdacbcc1fe212a78f310ea73a2f07ec62a.tar.gz |
Add support for new sanitizers in clang 3.3 and gcc 4.8
Diffstat (limited to 'SConstruct')
-rw-r--r-- | SConstruct | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/SConstruct b/SConstruct index 50023ab9f3e..36a218106e8 100644 --- a/SConstruct +++ b/SConstruct @@ -53,11 +53,14 @@ options = {} options_topass = {} def add_option( name, help, nargs, contributesToVariantDir, - dest=None, default = None, type="string", choices=None ): + dest=None, default = None, type="string", choices=None, metavar=None ): if dest is None: dest = name + if type == 'choice' and not metavar: + metavar = '[' + '|'.join(choices) + ']' + AddOption( "--" + name , dest=dest, type=type, @@ -65,6 +68,7 @@ def add_option( name, help, nargs, contributesToVariantDir, action="store", choices=choices, default=default, + metavar=metavar, help=help ) options[name] = { "help" : help , @@ -198,6 +202,11 @@ add_option( "win2008plus", "use newer operating system API features" , 0 , False # dev options add_option( "d", "debug build no optimization, etc..." , 0 , True , "debugBuild" ) add_option( "dd", "debug build no optimization, additional debug logging, etc..." , 0 , True , "debugBuildAndLogging" ) + +sanitizer_choices = ["address", "memory", "thread", "undefined"] +add_option( "sanitize", "enable selected sanitizer", 1, True, + type="choice", choices=sanitizer_choices, default=None ) + add_option( "durableDefaultOn" , "have durable default to on" , 0 , True ) add_option( "durableDefaultOff" , "have durable default to off" , 0 , True ) @@ -1001,6 +1010,17 @@ def doConfigure(myenv): print( 'libc++ requested, but compiler does not support -stdlib=libc++' ) Exit(1) + if has_option('sanitize'): + if not (using_clang() or using_gcc()): + print( 'sanitize is only supported with clang or gcc') + Exit(1) + sanitizer_option = '-fsanitize=' + GetOption('sanitize') + if AddToCCFLAGSIfSupported(myenv, sanitizer_option): + myenv.Append(LINKFLAGS=[sanitizer_option]) + else: + print( 'Failed to enable sanitizer with flag: ' + sanitizer_option ) + Exit(1) + # Apply any link time optimization settings as selected by the 'lto' option. if has_option('lto'): if using_msvc(): |