diff options
author | Andrew Morrow <acm@mongodb.com> | 2019-12-18 14:56:01 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-02-16 19:12:35 +0000 |
commit | 6674514dfcc5b3ec4e80c2b727c8d7f9f6f6e86f (patch) | |
tree | a6f384592a6c31fba8c2df669db88ecbb13c482c /site_scons | |
parent | b909337c9cfa982b6cdbc59e6f73b49f79b0cfc7 (diff) | |
download | mongo-6674514dfcc5b3ec4e80c2b727c8d7f9f6f6e86f.tar.gz |
SERVER-45236 Eliminate need to reiterate compile flags on the link line
Diffstat (limited to 'site_scons')
-rw-r--r-- | site_scons/site_tools/mongo_libfuzzer.py | 3 | ||||
-rw-r--r-- | site_scons/site_tools/smartlink_cflags.py | 48 |
2 files changed, 49 insertions, 2 deletions
diff --git a/site_scons/site_tools/mongo_libfuzzer.py b/site_scons/site_tools/mongo_libfuzzer.py index bcbc0412688..a3718afb0b2 100644 --- a/site_scons/site_tools/mongo_libfuzzer.py +++ b/site_scons/site_tools/mongo_libfuzzer.py @@ -44,8 +44,7 @@ def build_cpp_libfuzzer_test(env, target, source, **kwargs): libdeps = kwargs.get("LIBDEPS", myenv.get("LIBDEPS", [])).copy() kwargs["LIBDEPS"] = libdeps kwargs["INSTALL_ALIAS"] = ["tests"] - sanitizer_option = "-fsanitize=fuzzer" - myenv.Prepend(LINKFLAGS=[sanitizer_option]) + kwargs["FSAN_DO_LINK"] = True libfuzzer_test_components = {"tests", "fuzzertests"} if "AIB_COMPONENT" in kwargs and not kwargs["AIB_COMPONENTS"].endswith( diff --git a/site_scons/site_tools/smartlink_cflags.py b/site_scons/site_tools/smartlink_cflags.py new file mode 100644 index 00000000000..6ebce3d624e --- /dev/null +++ b/site_scons/site_tools/smartlink_cflags.py @@ -0,0 +1,48 @@ +# Copyright 2020 MongoDB Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This tool adjusts the LINKFLAGS and SHLINKFLAGS so that +# [SH]C[{C,CXX}]FLAGS are reiterated on the link line. This is +# important for flags like -mmacosx-version-min which has effects at +# both compile and link time. We use the CXX flags if the sources are +# C++. + +from SCons.Tool.cxx import iscplusplus + +def _smartlink_flags(source, target, env, for_signature): + if iscplusplus(source): + return '$CXXFLAGS $CCFLAGS $CXXLINKFLAGS' + return '$CFLAGS $CCFLAGS $CLINKFLAGS' + +def _smartshlink_flags(source, target, env, for_signature): + if iscplusplus(source): + return '$SHCXXFLAGS $SHCCFLAGS $SHCXXLINKFLAGS' + return '$SHCFLAGS $SHCCFLAGS $SHCLINKFLAGS' + + +def exists(env): + return True + +def generate(env): + + if not exists(env): + return + + env['SMARTLINKFLAGS'] = _smartlink_flags + env['SMARTSHLINKFLAGS'] = _smartshlink_flags + + env.PrependUnique( + LINKFLAGS=['$SMARTLINKFLAGS'], + SHLINKFLAGS=['$SMARTSHLINKFLAGS'], + ) |