diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2020-11-26 10:29:19 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-11-26 17:28:35 +0000 |
commit | 710aa34bd1bb9ff1c13a41737c86e636e57f0a88 (patch) | |
tree | d7e6b8c286968946f8a2c4974d4da3c822a78ca2 /src/SConscript | |
parent | 37f35e3c80096b5d55b482b83bfb3cf7af16852f (diff) | |
download | mongo-710aa34bd1bb9ff1c13a41737c86e636e57f0a88.tar.gz |
Revert "SERVER-48291 Ensure runtime is dynamically linked in dynamic builds"
This reverts commit 2a0e76082be0f2aca82830bcaf91f6d737b842ac.
Diffstat (limited to 'src/SConscript')
-rw-r--r-- | src/SConscript | 149 |
1 files changed, 1 insertions, 148 deletions
diff --git a/src/SConscript b/src/SConscript index 3c37fe2cd1c..fbf8e1fcecb 100644 --- a/src/SConscript +++ b/src/SConscript @@ -3,168 +3,21 @@ # This is the principle SConscript file, invoked by the SConstruct. Its job is # to delegate to any and all per-module SConscript files. -from functools import partial - -from site_scons.mongo import insort_wrapper - -import SCons - -Import('dynamicRT') Import('env') Import('get_option') -Import('has_option') Import('module_sconscripts') -def shim_hack(target, source, env, inject_target=None, disable_var=None): - # If we allowed conftests to become dependent, any TryLink - # that happened after we made the below modifications would - # cause the configure steps to try to compile tcmalloc and any - # of its dependencies. Oops! - if any('conftest' in str(t) for t in target): - return target, source - - # It is possible that 'env' isn't a unique - # OverrideEnvironment, since if you didn't pass any kw args - # into your builder call, you just reuse the env you were - # called with. That could mean that we see the same - # environment here multiple times. But that is really OK, - # since the operation we are performing would be performed on - # all of them anyway. The flag serves as a way to disable the - # auto-injection for the handful of libraries where we must do - # so to avoid forming a cycle. - if not env.get(disable_var, False): - lds = env.get('LIBDEPS', []) - shim_target = f"$BUILD_DIR/{inject_target}" - if shim_target not in lds: - insort_wrapper(lds, shim_target) - env['LIBDEPS'] = lds - - return target, source - - -def add_shim_hack(env, hack_method): - for builder_name in ('Program', 'SharedLibrary', 'LoadableModule', 'StaticLibrary'): - builder = env['BUILDERS'][builder_name] - base_emitter = builder.emitter - builder.emitter = SCons.Builder.ListEmitter([hack_method, base_emitter]) - - -# Here, we "hoist" libgcc*.a symbols out of the toolchain and stuff them into -# our own library so they don't get added piecemeal to every shared object and -# executable in a build directly out of the toolchain. -libcrtEnv = env.Clone(LIBS=[]) -libcxxEnv = env.Clone(LIBS=[]) -if dynamicRT == "force": - - if env.ToolchainIs('gcc', 'clang'): - - env.AppendUnique( - LINKFLAGS=[ - '-nodefaultlibs', - '-l:libgcc_s.so' - ], - ) - - libcrtEnv.AppendUnique( - LINKFLAGS=[ - "-Wl,-z,muldefs", - "-static-libgcc", - "-Wl,--push-state", - "-Wl,-Bstatic", - "-Wl,--no-warn-execstack", - "-Wl,--whole-archive", - "-lgcc", - "-lgcc_eh", - "-Wl,--no-whole-archive", - "-Wl,--pop-state", - ] - ) - - if has_option("libc++"): - cxx_lib = "c++" - else: - cxx_lib = "stdc++" - - libcxxEnv.AppendUnique( - LINKFLAGS=[ - "-Wl,-z,muldefs", - f"-static-lib{cxx_lib}", - "-Wl,--push-state", - "-Wl,-Bstatic", - "-Wl,--no-warn-execstack", - "-Wl,--whole-archive", - f"-l{cxx_lib}", - "-Wl,--no-whole-archive", - "-Wl,--pop-state", - ] - ) - -libcrtEnv.ShimLibrary( - name="crt", - needs_link=(dynamicRT == "force" and env.ToolchainIs('gcc', 'clang')), - LIBDEPS_TAGS=[ - # TODO: Remove all of these when SERVER-48291 is merged into stable build tools - # The shim allocator must be linked to every node, including what would - # be considered a leaf node to ensure the system allocator - # is not linked in before tcmalloc. This tag allows nodes tagged as - # leaf nodes to still get the correct allocator. - 'lint-leaf-node-allowed-dep', - # This tag allows the allocator to be linked to nodes marked as not - # allowed to have public dependencies. - 'lint-public-dep-allowed' - ], -) - -libcxxEnv.ShimLibrary( - name="cxx", - needs_link=(dynamicRT == "force" and env.ToolchainIs('gcc', 'clang')), - LIBDEPS_TAGS=[ - # TODO: Remove all of these when SERVER-48291 is merged into stable build tools - # The shim allocator must be linked to every node, including what would - # be considered a leaf node to ensure the system allocator - # is not linked in before tcmalloc. This tag allows nodes tagged as - # leaf nodes to still get the correct allocator. - 'lint-leaf-node-allowed-dep', - # This tag allows the allocator to be linked to nodes marked as not - # allowed to have public dependencies. - 'lint-public-dep-allowed' - ], -) - - +env = env.Clone() if get_option("build-tools") == "next": # Add any "global" dependencies here. This is where we make every build node # depend on a list of other build nodes, such as an allocator or libunwind # or libstdx or similar. env.AppendUnique( LIBDEPS_GLOBAL=[ - '$BUILD_DIR/shim_crt' if dynamicRT == "force" else [], - '$BUILD_DIR/shim_cxx' if dynamicRT == "force" else [], '$BUILD_DIR/third_party/shim_allocator', ], ) -else: - add_shim_hack( - env, - partial( - shim_hack, - inject_target='third_party/shim_allocator', - disable_var='DISABLE_ALLOCATOR_SHIM_INJECTION')) - if dynamicRT == "force": - add_shim_hack( - env, - partial( - shim_hack, - inject_target='shim_cxx', - disable_var='DISABLE_CXX_SHIM_INJECTION')) - add_shim_hack( - env, - partial( - shim_hack, - inject_target='shim_crt', - disable_var='DISABLE_CRT_SHIM_INJECTION')) - # NOTE: We must do third_party first as it adds methods to the environment # that we need in the mongo sconscript |