summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Moody <daniel.moody@mongodb.com>2020-08-26 15:35:24 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-08-27 21:35:32 +0000
commita81e107047d3048cea552ee36ff2ed18e98a2347 (patch)
tree86ae85e1fc895403f37c29623f0401c4b76633ea
parent291f925b64efaca3996392b584398f81fb5f6087 (diff)
downloadmongo-a81e107047d3048cea552ee36ff2ed18e98a2347.tar.gz
SERVER-49168 made SYSLIBDEPS_PRIVATE type and switched lzma to use it
-rw-r--r--SConstruct28
-rw-r--r--site_scons/libdeps.py109
-rw-r--r--site_scons/site_tools/mongo_benchmark.py2
-rw-r--r--src/mongo/installer/msi/ca/SConscript4
-rw-r--r--src/mongo/shell/SConscript2
-rw-r--r--src/third_party/SConscript4
-rw-r--r--src/third_party/benchmark/SConscript2
-rw-r--r--src/third_party/unwind/SConscript4
8 files changed, 83 insertions, 72 deletions
diff --git a/SConstruct b/SConstruct
index 7d52ee81fb5..a111a1d39dd 100644
--- a/SConstruct
+++ b/SConstruct
@@ -1990,20 +1990,20 @@ elif env.TargetOSIs('windows'):
env.Append(
LIBS=[
- 'DbgHelp.lib',
- 'Iphlpapi.lib',
- 'Psapi.lib',
- 'advapi32.lib',
- 'bcrypt.lib',
- 'crypt32.lib',
- 'dnsapi.lib',
- 'kernel32.lib',
- 'shell32.lib',
- 'pdh.lib',
- 'version.lib',
- 'winmm.lib',
- 'ws2_32.lib',
- 'secur32.lib',
+ 'DbgHelp',
+ 'Iphlpapi',
+ 'Psapi',
+ 'advapi32',
+ 'bcrypt',
+ 'crypt32',
+ 'dnsapi',
+ 'kernel32',
+ 'shell32',
+ 'pdh',
+ 'version',
+ 'winmm',
+ 'ws2_32',
+ 'secur32',
],
)
diff --git a/site_scons/libdeps.py b/site_scons/libdeps.py
index c04128aa76d..63d1aeaa62e 100644
--- a/site_scons/libdeps.py
+++ b/site_scons/libdeps.py
@@ -51,6 +51,7 @@ automatically added when missing.
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+from collections import OrderedDict
import copy
import os
import textwrap
@@ -62,16 +63,17 @@ import SCons.Util
class Constants:
Libdeps = "LIBDEPS"
- LibdepsPrivate = "LIBDEPS_PRIVATE"
- LibdepsInterface ="LIBDEPS_INTERFACE"
+ LibdepsCached = "LIBDEPS_cached"
LibdepsDependents = "LIBDEPS_DEPENDENTS"
+ LibdepsInterface ="LIBDEPS_INTERFACE"
+ LibdepsPrivate = "LIBDEPS_PRIVATE"
+ LibdepsTags = "LIBDEPS_TAGS"
+ LibdepsTagExpansion = "LIBDEPS_TAG_EXPANSIONS"
+ MissingLibdep = "MISSING_LIBDEP_"
ProgdepsDependents = "PROGDEPS_DEPENDENTS"
SysLibdeps = "SYSLIBDEPS"
- LibdepsCached = "LIBDEPS_cached"
SysLibdepsCached = "SYSLIBDEPS_cached"
- MissingLibdep = "MISSING_LIBDEP_"
- LibdepsTags = "LIBDEPS_TAGS"
- LibdepsTagExpansion = "LIBDEPS_TAG_EXPANSIONS"
+ SysLibdepsPrivate = "SYSLIBDEPS_PRIVATE"
class dependency:
Public, Private, Interface = list(range(3))
@@ -511,6 +513,8 @@ class DependencyCycleError(SCons.Errors.UserError):
class LibdepLinterError(SCons.Errors.UserError):
"""Exception representing a discongruent usages of libdeps"""
+class MissingSyslibdepError(SCons.Errors.UserError):
+ """Exception representing a discongruent usages of libdeps"""
def __get_sorted_direct_libdeps(node):
direct_sorted = getattr(node.attributes, "libdeps_direct_sorted", False)
@@ -568,35 +572,6 @@ def __get_libdeps(node):
return tsorted
-def __get_syslibdeps(node):
- """ Given a SCons Node, return its system library dependencies.
-
- These are the dependencies listed with SYSLIBDEPS, and are linked using -l.
- """
- result = getattr(node.attributes, Constants.SysLibdepsCached, None)
- if result is not None:
- return result
-
- result = node.get_env().Flatten(node.get_env().get(Constants.SysLibdeps, []))
- for lib in __get_libdeps(node):
- for syslib in lib.get_env().get(Constants.SysLibdeps, []):
- if not syslib:
- continue
-
- if type(syslib) is str and syslib.startswith(Constants.MissingLibdep):
- print(
- "Target '{}' depends on the availability of a "
- "system provided library for '{}', "
- "but no suitable library was found during configuration.".format(str(node), syslib[len(Constants.MissingLibdep) :])
- )
- node.get_env().Exit(1)
-
- result.append(syslib)
-
- setattr(node.attributes, Constants.SysLibdepsCached, result)
- return result
-
-
def __missing_syslib(name):
return Constants.MissingLibdep + name
@@ -642,24 +617,60 @@ def get_libdeps_objs(source, target, env, for_signature):
objs.extend(lib.sources)
return objs
+def make_get_syslibdeps_callable(shared):
+
+ def get_syslibdeps(source, target, env, for_signature):
+ """ Given a SCons Node, return its system library dependencies.
+
+ These are the dependencies listed with SYSLIBDEPS, and are linked using -l.
+ """
+
+ deps = getattr(target[0].attributes, Constants.SysLibdepsCached, None)
+ if deps is None:
-def get_syslibdeps(source, target, env, for_signature):
- deps = __get_syslibdeps(target[0])
- lib_link_prefix = env.subst("$LIBLINKPREFIX")
- lib_link_suffix = env.subst("$LIBLINKSUFFIX")
- result = []
- for d in deps:
+ # Get the sys libdeps for the current node
+ deps = target[0].get_env().Flatten(target[0].get_env().get(Constants.SysLibdepsPrivate) or [])
+ deps += target[0].get_env().Flatten(target[0].get_env().get(Constants.SysLibdeps) or [])
+
+ for lib in __get_libdeps(target[0]):
+
+ # For each libdep get its syslibdeps, and then check to see if we can
+ # add it to the deps list. For static build we will also include private
+ # syslibdeps to be transitive. For a dynamic build we will only make
+ # public libdeps transitive.
+ syslibs = []
+ if not shared:
+ syslibs += lib.get_env().get(Constants.SysLibdepsPrivate) or []
+ syslibs += lib.get_env().get(Constants.SysLibdeps) or []
+
+ # Validate the libdeps, a configure check has already checked what
+ # syslibdeps are available so we can hard fail here if a syslibdep
+ # is being attempted to be linked with.
+ for syslib in syslibs:
+ if not syslib:
+ continue
+
+ if isinstance(syslib, str) and syslib.startswith(Constants.MissingLibdep):
+ MissingSyslibdepError(textwrap.dedent(f"""\
+ Target '{str(target[0])}' depends on the availability of a
+ system provided library for '{syslib[len(Constants.MissingLibdep):]}',
+ but no suitable library was found during configuration."""
+ ))
+
+ deps.append(syslib)
+
+ setattr(target[0].attributes, Constants.SysLibdepsCached, deps)
+
+ lib_link_prefix = env.subst("$LIBLINKPREFIX")
+ lib_link_suffix = env.subst("$LIBLINKSUFFIX")
# Elements of syslibdeps are either strings (str or unicode), or they're File objects.
# If they're File objects, they can be passed straight through. If they're strings,
# they're believed to represent library short names, that should be prefixed with -l
# or the compiler-specific equivalent. I.e., 'm' becomes '-lm', but 'File("m.a") is passed
# through whole cloth.
- if type(d) is str:
- result.append("%s%s%s" % (lib_link_prefix, d, lib_link_suffix))
- else:
- result.append(d)
- return result
+ return [f"{lib_link_prefix}{d}{lib_link_suffix}" if isinstance(d, str) else d for d in deps]
+ return get_syslibdeps
def __append_direct_libdeps(node, prereq_nodes):
# We do not bother to decorate nodes that are not actual Objects
@@ -695,8 +706,8 @@ def __get_node_with_ixes(env, node, node_builder_type):
node_builder = env["BUILDERS"][node_builder_type]
node_factory = node_builder.target_factory or env.File
- # Cache the ixes in a function scope global so we don't need
- # to run scons performance intensive 'subst' each time
+ # Cache the 'ixes' in a function scope global so we don't need
+ # to run SCons performance intensive 'subst' each time
cache_key = (id(env), node_builder_type)
try:
prefix, suffix = __get_node_with_ixes.node_type_ixes[cache_key]
@@ -879,7 +890,7 @@ def setup_environment(env, emitting_shared=False, linting='on'):
env["_LIBDEPS_TAGS"] = expand_libdeps_tags
env["_LIBDEPS_GET_LIBS"] = get_libdeps
env["_LIBDEPS_OBJS"] = get_libdeps_objs
- env["_SYSLIBDEPS"] = get_syslibdeps
+ env["_SYSLIBDEPS"] = make_get_syslibdeps_callable(emitting_shared)
env[Constants.Libdeps] = SCons.Util.CLVar()
env[Constants.SysLibdeps] = SCons.Util.CLVar()
diff --git a/site_scons/site_tools/mongo_benchmark.py b/site_scons/site_tools/mongo_benchmark.py
index 1b6eef21098..1f862c16465 100644
--- a/site_scons/site_tools/mongo_benchmark.py
+++ b/site_scons/site_tools/mongo_benchmark.py
@@ -37,7 +37,7 @@ def build_benchmark(env, target, source, **kwargs):
bmEnv.InjectThirdParty(libraries=["benchmark"])
if bmEnv.TargetOSIs("windows"):
- bmEnv.Append(LIBS=["ShLwApi.lib"])
+ bmEnv.Append(LIBS=["ShLwApi"])
libdeps = kwargs.get("LIBDEPS", bmEnv.get("LIBDEPS", [])).copy()
insort_wrapper(libdeps, "$BUILD_DIR/mongo/unittest/benchmark_main")
diff --git a/src/mongo/installer/msi/ca/SConscript b/src/mongo/installer/msi/ca/SConscript
index 97c8ec305c8..d48044fde26 100644
--- a/src/mongo/installer/msi/ca/SConscript
+++ b/src/mongo/installer/msi/ca/SConscript
@@ -19,8 +19,8 @@ else:
env['CCFLAGS'].append("/MT")
env.Append(LIBS=[
- 'msi.lib',
- 'user32.lib'
+ 'msi',
+ 'user32'
]
)
diff --git a/src/mongo/shell/SConscript b/src/mongo/shell/SConscript
index 3e77b125139..bc9a160bcf6 100644
--- a/src/mongo/shell/SConscript
+++ b/src/mongo/shell/SConscript
@@ -295,7 +295,7 @@ if not has_option('noshell') and usemozjs:
shellEnv = env.Clone()
if env.TargetOSIs('windows'):
- shellEnv.Append(LIBS=["winmm.lib"])
+ shellEnv.Append(LIBS=["winmm"])
generatedMongoManifest = shellEnv.Substfile(
'mongo.manifest.in',
diff --git a/src/third_party/SConscript b/src/third_party/SConscript
index 47b2d126f1a..0b0ef5f4fbc 100644
--- a/src/third_party/SConscript
+++ b/src/third_party/SConscript
@@ -190,11 +190,11 @@ if not use_system_version_of_library('kms-message'):
if use_system_libunwind:
thirdPartyEnvironmentModifications['unwind'] = {
- 'SYSLIBDEPS' : [env['LIBDEPS_UNWIND_SYSLIBDEP'], 'lzma'],
+ 'SYSLIBDEPS_PRIVATE' : [env['LIBDEPS_UNWIND_SYSLIBDEP'], 'lzma'],
}
elif use_vendored_libunwind:
thirdPartyEnvironmentModifications['unwind'] = {
- 'SYSLIBDEPS' : ['lzma'],
+ 'SYSLIBDEPS_PRIVATE' : ['lzma'],
}
def injectThirdParty(thisEnv, libraries=[], parts=[]):
diff --git a/src/third_party/benchmark/SConscript b/src/third_party/benchmark/SConscript
index fc8549e0c0f..f4841f3631b 100644
--- a/src/third_party/benchmark/SConscript
+++ b/src/third_party/benchmark/SConscript
@@ -10,7 +10,7 @@ if env.TargetOSIs('windows'):
'/wd4722',
])
- env.Append(LIBS=["ShLwApi.lib"])
+ env.Append(LIBS=["ShLwApi"])
env.Append(CPPDEFINES=["HAVE_STD_REGEX"])
diff --git a/src/third_party/unwind/SConscript b/src/third_party/unwind/SConscript
index ed947c8e8e8..6d31d86fd5e 100644
--- a/src/third_party/unwind/SConscript
+++ b/src/third_party/unwind/SConscript
@@ -110,10 +110,10 @@ env.Append(
# propagates to consumers that Inject (depend on) unwind.
env.RegisterConsumerModifications(
CPPPATH=[unwind_platform.Dir("install/include")],
- LIBS=['lzma'])
+ SYSLIBDEPS_PRIVATE=['lzma'])
env.Append(
- LIBS=['lzma'])
+ SYSLIBDEPS_PRIVATE=['lzma'])
env.Append(
CPPDEFINES=[