summaryrefslogtreecommitdiff
path: root/SConstruct
diff options
context:
space:
mode:
authorAndrew Morrow <acm@mongodb.com>2018-07-01 17:15:13 -0400
committerAndrew Morrow <acm@mongodb.com>2018-09-12 19:43:21 -0400
commitd9fd86255542015f3e6d9bc16e6ff349f109f07b (patch)
tree882e5a25ea4d8f1577a4fb9d773e3829cbf5004b /SConstruct
parent83b9f6e435e6bbcadcc270345fa5c0ab1c480819 (diff)
downloadmongo-d9fd86255542015f3e6d9bc16e6ff349f109f07b.tar.gz
SERVER-33911 Implement collapsed library builds under a new link model
(cherry picked from commit 47ab234e910a04cb2bee4114170b042d47586c35)
Diffstat (limited to 'SConstruct')
-rw-r--r--SConstruct39
1 files changed, 32 insertions, 7 deletions
diff --git a/SConstruct b/SConstruct
index 4917d4c97ac..4db8cf12750 100644
--- a/SConstruct
+++ b/SConstruct
@@ -462,7 +462,7 @@ add_option('variables-files',
help="Specify variables files to load",
)
-link_model_choices = ['auto', 'object', 'static', 'dynamic', 'dynamic-strict']
+link_model_choices = ['auto', 'object', 'static', 'dynamic', 'dynamic-strict', 'dynamic-sdk']
add_option('link-model',
choices=link_model_choices,
default='auto',
@@ -602,7 +602,6 @@ def variable_tools_converter(val):
"gziptool",
'idl_tool',
"jsheader",
- "mergelib",
"mongo_benchmark",
"mongo_integrationtest",
"mongo_unittest",
@@ -1273,8 +1272,8 @@ if link_model == "auto":
# Windows can't currently support anything other than 'object' or 'static', until
# we have both hygienic builds and have annotated functions for export.
-if env.TargetOSIs('windows') and link_model not in ['object', 'static']:
- env.FatalError("Windows builds must use the 'object' or 'static' link models");
+if env.TargetOSIs('windows') and link_model not in ['object', 'static', 'dynamic-sdk']:
+ env.FatalError("Windows builds must use the 'object', 'dynamic-sdk', or 'static' link models")
# The 'object' mode for libdeps is enabled by setting _LIBDEPS to $_LIBDEPS_OBJS. The other two
# modes operate in library mode, enabled by setting _LIBDEPS to $_LIBDEPS_LIBS.
@@ -1283,11 +1282,24 @@ env['_LIBDEPS'] = '$_LIBDEPS_OBJS' if link_model == "object" else '$_LIBDEPS_LIB
env['BUILDERS']['ProgramObject'] = env['BUILDERS']['StaticObject']
env['BUILDERS']['LibraryObject'] = env['BUILDERS']['StaticObject']
+env['SHARPREFIX'] = '$LIBPREFIX'
+env['SHARSUFFIX'] = '${SHLIBSUFFIX}${LIBSUFFIX}'
+env['BUILDERS']['SharedArchive'] = SCons.Builder.Builder(
+ action=env['BUILDERS']['StaticLibrary'].action,
+ emitter='$SHAREMITTER',
+ prefix='$SHARPREFIX',
+ suffix='$SHARSUFFIX',
+ src_suffix=env['BUILDERS']['SharedLibrary'].src_suffix,
+)
+
if link_model.startswith("dynamic"):
- # Redirect the 'Library' target, which we always use instead of 'StaticLibrary' for things
- # that can be built in either mode, to point to SharedLibrary.
- env['BUILDERS']['Library'] = env['BUILDERS']['SharedLibrary']
+ def library(env, target, source, *args, **kwargs):
+ sharedLibrary = env.SharedLibrary(target, source, *args, **kwargs)
+ sharedArchive = env.SharedArchive(target, source=sharedLibrary[0].sources, *args, **kwargs)
+ return (sharedLibrary, sharedArchive)
+
+ env['BUILDERS']['Library'] = library
env['BUILDERS']['LibraryObject'] = env['BUILDERS']['SharedObject']
# TODO: Ideally, the conditions below should be based on a
@@ -1356,6 +1368,19 @@ if link_model.startswith("dynamic"):
return ["-Wl,-undefined,dynamic_lookup"]
return []
env['LIBDEPS_TAG_EXPANSIONS'].append(libdeps_tags_expand_incomplete)
+ elif env.TargetOSIs('windows'):
+ if link_model == "dynamic-strict":
+ # Windows is strict by default
+ pass
+ else:
+ def libdeps_tags_expand_incomplete(source, target, env, for_signature):
+ # On windows, since it is strict by default, we need to add a flag
+ # when libraries are tagged incomplete.
+ if ('illegal_cyclic_or_unresolved_dependencies_whitelisted'
+ in target[0].get_env().get("LIBDEPS_TAGS", [])):
+ return ["/FORCE:UNRESOLVED"]
+ return []
+ env['LIBDEPS_TAG_EXPANSIONS'].append(libdeps_tags_expand_incomplete)
else:
env.AppendUnique(LINKFLAGS=["-Wl,--no-as-needed"])