diff options
author | Jonathan Reams <jbreams@mongodb.com> | 2015-04-22 16:46:05 -0400 |
---|---|---|
committer | Jonathan Reams <jbreams@mongodb.com> | 2015-04-22 16:46:05 -0400 |
commit | 33ef05ce2d71107533d283e6d2d31c34b01d33b7 (patch) | |
tree | ca6ea4b611ef032d39de49ebdfb9d6a9f98074c7 /SConstruct | |
parent | db96b5908d2da1be53b05a957fc63ed13d6365bd (diff) | |
download | mongo-33ef05ce2d71107533d283e6d2d31c34b01d33b7.tar.gz |
SERVER-17455 Re-add std::atomic configure checks
Diffstat (limited to 'SConstruct')
-rw-r--r-- | SConstruct | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/SConstruct b/SConstruct index 5c2a52f9230..c06ed1bae70 100644 --- a/SConstruct +++ b/SConstruct @@ -1972,6 +1972,45 @@ def doConfigure(myenv): print "Invalid --allocator parameter: \"%s\"" % get_option('allocator') Exit(1) + def CheckStdAtomic(context, type): + test_body = """ + #include <atomic> + + int main() {{ + std::atomic<{0}> x; + + x.store(0); + {0} y = 1; + x.fetch_add(y); + x.fetch_sub(y); + x.exchange(y); + x.compare_exchange_strong(y, x); + return x.load(); + }} + """.format(type) + + context.Message("Checking whether toolchain supports std::atomic<{0}> ".format(type)) + ret = context.TryLink(textwrap.dedent(test_body), ".cpp") + context.Result(ret) + return ret + conf.AddTest("CheckStdAtomic", CheckStdAtomic) + + def check_all_atomics(): + for t in ('int64_t', 'uint64_t', 'int32_t', 'uint32_t'): + if not conf.CheckStdAtomic(t): + return False + return True + + if not check_all_atomics(): + if not conf.env.ToolchainIs('msvc'): + conf.env.AppendUnique(LIBS=['atomic']) + if not check_all_atomics(): + print "The toolchain does not support std::atomic, cannot continue" + Exit(1) + else: + print "The toolchain does not support std::atomic, cannot continue" + Exit(1) + # ask each module to configure itself and the build environment. moduleconfig.configure_modules(mongo_modules, conf) |