summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--SConstruct141
-rw-r--r--src/SConscript128
-rw-r--r--src/mongo/platform/SConscript10
-rw-r--r--src/third_party/SConscript4
4 files changed, 6 insertions, 277 deletions
diff --git a/SConstruct b/SConstruct
index b3b14271e39..9ebf301cf3b 100644
--- a/SConstruct
+++ b/SConstruct
@@ -486,15 +486,6 @@ add_option("cxx-std",
help="Select the C++ language standard to build with",
)
-add_option("dynamic-runtime",
- choices=["force", "off", "auto"],
- const="on",
- default="auto",
- help="Force the static compiler and C++ runtimes to be linked dynamically",
- nargs="?",
- type="choice",
-)
-
def find_mongo_custom_variables():
files = []
paths = [path for path in sys.path if 'site_scons' in path]
@@ -1791,121 +1782,6 @@ if link_model.startswith("dynamic"):
env['LIBDEPS_TAG_EXPANSIONS'].append(libdeps_tags_expand_incomplete)
-# If requested, wrap the static runtime libraries in shims and use those to link
-# them dynamically. This allows us to "convert" runtimes in toolchains that have
-# linker scripts in place of shared libraries which actually link the static
-# library instead. The benefit of making this conversion is that shared
-# libraries produced by these toolchains are smaller because we don't end up
-# spreading runtime symbols all over the place, and in turn they should also
-# get loaded by the dynamic linker more quickly as well.
-dynamicRT = get_option("dynamic-runtime")
-
-if dynamicRT == "auto":
- if env.ToolchainIs('msvc'):
- # TODO: SERVER-53102
- # Windows Enterprise *requires* a dynamic CRT because it needs to have
- # shared state in order to load the external libraries required for SSL,
- # LDAP, etc. This state of affairs may eventually change as Windows
- # dynamic builds improve, but for now we just force a dynamic CRT with
- # Windows until we have some way of detecting when we can get away with
- # a static CRT.
- #
- # Ideally, we should be determining whether a static build is requested,
- # and if so, whether a dynamic CRT *must* be used in such a case.
-
- dynamicRT = "force"
-
- elif get_option("link-model") != "dynamic":
- dynamicRT = "off"
-
- elif env.TargetOSIs('linux') and env.ToolchainIs('gcc', 'clang'):
- def CheckRuntimeLibraries(context):
- context.Message("Checking whether any runtime libraries are linker scripts... ")
-
- result = {}
- libs = [ 'libgcc', 'libgcc_s', 'libgcc_eh' ]
-
- if get_option('libc++'):
- libs.append('libc++')
- else:
- libs.append('libstdc++')
-
- compiler = subprocess.Popen(
- [context.env['CXX'], "-print-search-dirs"],
- stdout=subprocess.PIPE
- )
-
- # This just pulls out the library paths and *only* the library
- # paths, deleting all other lines. It also removes the leading
- # "libraries" tag from the line so only the paths are left in
- # the output.
- sed = subprocess.Popen(
- [
- "sed",
- "/^lib/b 1;d;:1;s,.*:[^=]*=,,",
- ],
- stdin=compiler.stdout,
- stdout=subprocess.PIPE
- )
- compiler.stdout.close()
-
- search_paths = sed.communicate()[0].decode('utf-8').split(':')
-
- for lib in libs:
- for search_path in search_paths:
- lib_file = os.path.join(search_path, lib + ".so")
- if os.path.exists(lib_file):
- file_type = subprocess.check_output(["file", lib_file]).decode('utf-8')
- match = re.search('ASCII text', file_type)
- result[lib] = bool(match)
- break
- if any(result.values()):
- ret = "yes"
- else:
- ret = "no"
- context.Result(ret)
- return ret
-
- detectStaticRuntime = Configure(detectEnv, help=False, custom_tests = {
- 'CheckRuntimeLibraries' : CheckRuntimeLibraries,
- })
-
- if detectStaticRuntime.CheckRuntimeLibraries() == "yes":
- # TODO: SERVER-48291
- # Set this to "force" when the issue with jsCore test failures with
- # dynamic runtime have been resolved.
- dynamicRT = "off"
- else:
- dynamicRT = "off"
-
- detectStaticRuntime.Finish()
-
-if dynamicRT == "force":
- if not (env.TargetOSIs('linux') or env.TargetOSIs('windows')):
- env.FatalError("A dynamic runtime can be forced only on Windows and Linux at this time.")
-
- # GCC and Clang get configured in src/SConscript so as to avoid affecting
- # the conftests.
- if env.ToolchainIs('msvc'):
- if debugBuild:
- env.Append(CCFLAGS=["/MDd"])
- else:
- env.Append(CCFLAGS=["/MD"])
-
- else:
- if get_option("link-model") != "dynamic":
- env.FatalError("A dynamic runtime can only be forced with dynamic linking on this toolchain.")
-
- if not env.ToolchainIs('gcc', 'clang'):
- env.FatalError("Don't know how to force a dynamic runtime on this toolchain.")
-
-if dynamicRT == "off" and env.ToolchainIs('msvc'):
- if debugBuild:
- env.Append(CCFLAGS=["/MTd"])
- else:
- env.Append(CCFLAGS=["/MT"])
-
-
if optBuild:
env.SetConfigHeaderDefine("MONGO_CONFIG_OPTIMIZED_BUILD")
@@ -2381,6 +2257,10 @@ elif env.TargetOSIs('windows'):
if not any(flag.startswith('/DEBUG') for flag in env['LINKFLAGS']):
env.Append(LINKFLAGS=["/DEBUG"])
+ # /MD: use the multithreaded, DLL version of the run-time library (MSVCRT.lib/MSVCR###.DLL)
+ # /MDd: Defines _DEBUG, _MT, _DLL, and uses MSVCRTD.lib/MSVCRD###.DLL
+ env.Append(CCFLAGS=["/MDd" if debugBuild else "/MD"])
+
if optBuild:
# /O1: optimize for size
# /O2: optimize for speed (as opposed to size)
@@ -2569,14 +2449,8 @@ if env.TargetOSIs('posix'):
# On OS X, clang doesn't want the pthread flag at link time, or it
# issues warnings which make it impossible for us to declare link
# warnings as errors. See http://stackoverflow.com/a/19382663.
- #
- # We don't need it anyway since we explicitly link to -lpthread,
- # so all we need beyond that is the preprocessor variable.
- if not env.ToolchainIs('clang'):
- env.Append(
- CPPDEFINES=[("_REENTRANT", "1")],
- LINKFLAGS=["-pthread"]
- )
+ if not (env.TargetOSIs('darwin') and env.ToolchainIs('clang')):
+ env.Append( LINKFLAGS=["-pthread"] )
# SERVER-9761: Ensure early detection of missing symbols in dependent libraries at program
# startup.
@@ -4261,10 +4135,8 @@ def doConfigure(myenv):
language='C++')
if posix_system:
conf.env.SetConfigHeaderDefine("MONGO_CONFIG_HAVE_HEADER_UNISTD_H")
- conf.CheckLib('c')
conf.CheckLib('rt')
conf.CheckLib('dl')
- conf.CheckLib('pthread')
if posix_monotonic_clock:
conf.env.SetConfigHeaderDefine("MONGO_CONFIG_HAVE_POSIX_MONOTONIC_CLOCK")
@@ -5217,7 +5089,6 @@ module_sconscripts = moduleconfig.get_module_sconscripts(mongo_modules)
# and they are exported here, as well.
Export([
'debugBuild',
- 'dynamicRT',
'endian',
'free_monitoring',
'get_option',
diff --git a/src/SConscript b/src/SConscript
index 28c848a675e..0c3a05f8d81 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -9,7 +9,6 @@ from site_scons.mongo import insort_wrapper
import SCons
-Import('dynamicRT')
Import('env')
Import('get_option')
Import('has_option')
@@ -52,34 +51,6 @@ def shim_hack(target, source, env, inject_target=None, exclusions=None):
return target, source
-def nodefaultlibs_hack(target, source, env):
- if any('conftest' in str(t) for t in target):
- return target, source
-
- runtime_shim_names = [
- 'shim_crt',
- 'shim_cxx',
- ]
- runtime_shims = [f"$BUILD_DIR/{name}" for name in runtime_shim_names]
-
- # If we're building either the CRT or CXX shim, don't insert the
- # nodefaultlibs argument because it makes static library insertion not work
- # in clang and gcc.
- if any(name in str(t) for name in runtime_shim_names for t in target):
- return target, source
-
- libdeps_no_inherit = set(env.get('LIBDEPS_NO_INHERIT', []))
-
- if not any(shim in libdeps_no_inherit for shim in runtime_shims):
- linkflags = env.get('LINKFLAGS', [])
- if '-nodefaultlibs' not in linkflags:
- linkflags = ['-nodefaultlibs'] + linkflags
-
- env['LINKFLAGS'] = linkflags
-
- return target, source
-
-
def hack_builder_emitters(env, hack_method):
for builder_name in ('Program', 'SharedLibrary', 'LoadableModule', 'StaticLibrary'):
builder = env['BUILDERS'][builder_name]
@@ -87,115 +58,16 @@ def hack_builder_emitters(env, hack_method):
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'):
- # Clang ang GCC get configured here because the dynamic runtimes are
- # injected in ways that would not be fully applied to conftests. The
- # only way to fix that means running part of the build before we can
- # run conftests. It may be worth it to do that at some point, but it's
- # complexity we should consider later if it's determined we need it.
-
- hack_builder_emitters(env, nodefaultlibs_hack)
-
- 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",
- ],
- SYSLIBDEPS=[
- ':libgcc_s.so',
- ]
- )
-
- 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"),
- LIBDEPS_TAGS=[
- # TODO: Remove when SERVER-48291 is merged into stable build tools.
- # An inserted dependency must be linked to every node, including what would
- # be considered a leaf node to ensure that a system dependency is not linked
- # in before this one. This tag allows nodes tagged as leaf nodes to still
- # get the correct allocator.
- 'lint-leaf-node-allowed-dep',
- # This tag allows this dependency 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"),
- LIBDEPS_TAGS=[
- # TODO: Remove when SERVER-48291 is merged into stable build tools.
- # An inserted dependency must be linked to every node, including what would
- # be considered a leaf node to ensure that a system dependency is not linked
- # in before this one. This tag allows nodes tagged as leaf nodes to still
- # get the correct allocator.
- 'lint-leaf-node-allowed-dep',
- # This tag allows this dependency to be linked to nodes marked as not
- # allowed to have public dependencies.
- 'lint-public-dep-allowed'
- ]
-)
-
-
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:
- if dynamicRT == "force":
- hack_builder_emitters(
- env,
- partial(
- shim_hack,
- inject_target='shim_crt'))
- hack_builder_emitters(
- env,
- partial(
- shim_hack,
- inject_target='shim_cxx'))
hack_builder_emitters(
env,
partial(
diff --git a/src/mongo/platform/SConscript b/src/mongo/platform/SConscript
index 193a62de65c..68ab49dad4c 100644
--- a/src/mongo/platform/SConscript
+++ b/src/mongo/platform/SConscript
@@ -43,8 +43,6 @@ env.Library(
],
LIBDEPS_NO_INHERIT=[
'$BUILD_DIR/third_party/shim_allocator',
- '$BUILD_DIR/shim_crt',
- '$BUILD_DIR/shim_cxx',
],
LIBDEPS=[],
MONGO_API_NAME="visibility_test_libcommon",
@@ -57,8 +55,6 @@ env.Library(
],
LIBDEPS_NO_INHERIT=[
'$BUILD_DIR/third_party/shim_allocator',
- '$BUILD_DIR/shim_crt',
- '$BUILD_DIR/shim_cxx',
],
LIBDEPS=[],
LIBDEPS_PRIVATE=[
@@ -74,8 +70,6 @@ env.Library(
],
LIBDEPS_NO_INHERIT=[
'$BUILD_DIR/third_party/shim_allocator',
- '$BUILD_DIR/shim_crt',
- '$BUILD_DIR/shim_cxx',
],
LIBDEPS=[
"visibility_test_lib1",
@@ -93,8 +87,6 @@ visibility_test1 = env.Program(
],
LIBDEPS_NO_INHERIT=[
'$BUILD_DIR/third_party/shim_allocator',
- '$BUILD_DIR/shim_crt',
- '$BUILD_DIR/shim_cxx',
],
LIBDEPS=[
"visibility_test_lib1",
@@ -114,8 +106,6 @@ visibility_test2 = env.Program(
],
LIBDEPS_NO_INHERIT=[
'$BUILD_DIR/third_party/shim_allocator',
- '$BUILD_DIR/shim_crt',
- '$BUILD_DIR/shim_cxx',
],
LIBDEPS=[
"visibility_test_lib2",
diff --git a/src/third_party/SConscript b/src/third_party/SConscript
index 6ee43dbd14e..08b2c2cdc35 100644
--- a/src/third_party/SConscript
+++ b/src/third_party/SConscript
@@ -243,8 +243,6 @@ s2Env.SConscript('s2/SConscript', exports={'env' : s2Env})
if use_libunwind:
unwindEnv = env.Clone(
LIBDEPS_NO_INHERIT=[
- '$BUILD_DIR/shim_crt',
- '$BUILD_DIR/shim_cxx',
'$BUILD_DIR/third_party/shim_allocator',
],
)
@@ -465,8 +463,6 @@ if "tom" in env["MONGO_CRYPTO"]:
gperftoolsEnv = env.Clone(
LIBDEPS_NO_INHERIT=[
- '$BUILD_DIR/shim_crt',
- '$BUILD_DIR/shim_cxx',
'$BUILD_DIR/third_party/shim_allocator',
],
)