diff options
author | Andrew Morrow <acm@mongodb.com> | 2018-04-05 18:25:43 -0400 |
---|---|---|
committer | Andrew Morrow <acm@mongodb.com> | 2018-04-14 07:45:56 -0400 |
commit | b822623d392b9877f5ed8103e1d9190f7687c159 (patch) | |
tree | bd59f5bbe1dc5732d922cb58e528ca0918d1dde9 /SConstruct | |
parent | ae50776bce051930d8d68493aa13c71cdcef4970 (diff) | |
download | mongo-b822623d392b9877f5ed8103e1d9190f7687c159.tar.gz |
SERVER-24238 Use a generator to establish a signature for sanitizer blacklist files
Diffstat (limited to 'SConstruct')
-rw-r--r-- | SConstruct | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/SConstruct b/SConstruct index f899282d9d8..579ee50b3e5 100644 --- a/SConstruct +++ b/SConstruct @@ -2474,14 +2474,36 @@ def doConfigure(myenv): "undefined" : myenv.File("#etc/ubsan.blacklist"), } - blackfiles = set([v for (k, v) in blackfiles_map.iteritems() if k in sanitizer_list]) - blacklist_options=["-fsanitize-blacklist=%s" % blackfile - for blackfile in blackfiles - if os.stat(blackfile.path).st_size != 0] - - for blacklist_option in blacklist_options: - if AddToCCFLAGSIfSupported(myenv, blacklist_option): - myenv.Append(LINKFLAGS=[blacklist_option]) + # Select those unique black files that are associated with the + # currently enabled sanitizers, but filter out those that are + # zero length. + blackfiles = {v for (k, v) in blackfiles_map.iteritems() if k in sanitizer_list} + blackfiles = [f for f in blackfiles if os.stat(f.path).st_size != 0] + + # Filter out any blacklist options that the toolchain doesn't support. + supportedBlackfiles = [] + blackfilesTestEnv = myenv.Clone() + for blackfile in blackfiles: + if AddToCCFLAGSIfSupported(blackfilesTestEnv, "-fsanitize-blacklist=%s" % blackfile): + supportedBlackfiles.append(blackfile) + blackfilesTestEnv = None + blackfiles = sorted(supportedBlackfiles) + + # If we ended up with any blackfiles after the above filters, + # then expand them into compiler flag arguments, and use a + # generator to return at command line expansion time so that + # we can change the signature if the file contents change. + if blackfiles: + blacklist_options=["-fsanitize-blacklist=%s" % blackfile for blackfile in blackfiles] + def SanitizerBlacklistGenerator(source, target, env, for_signature): + if for_signature: + return [f.get_csig() for f in blackfiles] + return blacklist_options + myenv.AppendUnique( + SANITIZER_BLACKLIST_GENERATOR=SanitizerBlacklistGenerator, + CCFLAGS="${SANITIZER_BLACKLIST_GENERATOR}", + LINKFLAGS="${SANITIZER_BLACKLIST_GENERATOR}", + ) llvm_symbolizer = get_option('llvm-symbolizer') if os.path.isabs(llvm_symbolizer): |