mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-28 07:59:02 +01:00
SERVER-27320 Enable fine grained application of whole archive extraction
This commit is contained in:
parent
b44308aa77
commit
955faacc40
22
SConstruct
22
SConstruct
@ -1181,8 +1181,8 @@ elif has_option("release") and link_model != "object":
|
||||
|
||||
# The only link model currently supported on Windows is 'object', since there is no equivalent
|
||||
# to --whole-archive.
|
||||
if env.TargetOSIs('windows') and link_model != 'object':
|
||||
env.FatalError("Windows builds must use the 'object' link model");
|
||||
if env.TargetOSIs('windows') and link_model not in ['object', 'static']:
|
||||
env.FatalError("Windows builds must use the 'object' 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.
|
||||
@ -1366,18 +1366,24 @@ libdeps.setup_environment(env, emitting_shared=(link_model.startswith("dynamic")
|
||||
if env.TargetOSIs('linux', 'freebsd', 'openbsd'):
|
||||
env['LINK_LIBGROUP_START'] = '-Wl,--start-group'
|
||||
env['LINK_LIBGROUP_END'] = '-Wl,--end-group'
|
||||
env['LINK_WHOLE_ARCHIVE_START'] = '-Wl,--whole-archive'
|
||||
env['LINK_WHOLE_ARCHIVE_END'] = '-Wl,--no-whole-archive'
|
||||
# NOTE: The leading and trailing spaces here are important. Do not remove them.
|
||||
env['LINK_WHOLE_ARCHIVE_LIB_START'] = '-Wl,--whole-archive '
|
||||
env['LINK_WHOLE_ARCHIVE_LIB_END'] = ' -Wl,--no-whole-archive'
|
||||
elif env.TargetOSIs('darwin'):
|
||||
env['LINK_LIBGROUP_START'] = ''
|
||||
env['LINK_LIBGROUP_END'] = ''
|
||||
env['LINK_WHOLE_ARCHIVE_START'] = '-Wl,-all_load'
|
||||
env['LINK_WHOLE_ARCHIVE_END'] = '-Wl,-noall_load'
|
||||
# NOTE: The trailing space here is important. Do not remove it.
|
||||
env['LINK_WHOLE_ARCHIVE_LIB_START'] = '-force_load '
|
||||
env['LINK_WHOLE_ARCHIVE_LIB_END'] = ''
|
||||
elif env.TargetOSIs('solaris'):
|
||||
env['LINK_LIBGROUP_START'] = '-z rescan-start'
|
||||
env['LINK_LIBGROUP_END'] = '-z rescan-end'
|
||||
env['LINK_WHOLE_ARCHIVE_START'] = '-z allextract'
|
||||
env['LINK_WHOLE_ARCHIVE_END'] = '-z defaultextract'
|
||||
# NOTE: The leading and trailing spaces here are important. Do not remove them.
|
||||
env['LINK_WHOLE_ARCHIVE_LIB_START'] = '-z allextract '
|
||||
env['LINK_WHOLE_ARCHIVE_LIB_END'] = ' -z defaultextract'
|
||||
elif env.TargetOSIs('windows'):
|
||||
env['LINK_WHOLE_ARCHIVE_LIB_START'] = '/WHOLEARCHIVE:'
|
||||
env['LINK_WHOLE_ARCHIVE_LIB_END'] = ''
|
||||
|
||||
# ---- other build setup -----
|
||||
if debugBuild:
|
||||
|
@ -350,25 +350,44 @@ def setup_environment(env, emitting_shared=False):
|
||||
env['_LIBDEPS'] = '$_LIBDEPS_LIBS'
|
||||
|
||||
env['_LIBDEPS_TAGS'] = expand_libdeps_tags
|
||||
|
||||
env['_LIBDEPS_LIBS'] = get_libdeps
|
||||
|
||||
env['_LIBDEPS_GET_LIBS'] = get_libdeps
|
||||
env['_LIBDEPS_OBJS'] = get_libdeps_objs
|
||||
env['_SYSLIBDEPS'] = get_syslibdeps
|
||||
env['_SHLIBDEPS'] = '$SHLIBDEP_GROUP_START ${_concat(SHLIBDEPPREFIX, __env__.subst(_LIBDEPS, target=TARGET, source=SOURCE), SHLIBDEPSUFFIX, __env__, target=TARGET, source=SOURCE)} $SHLIBDEP_GROUP_END'
|
||||
|
||||
env[libdeps_env_var] = SCons.Util.CLVar()
|
||||
env[syslibdeps_env_var] = SCons.Util.CLVar()
|
||||
|
||||
env.Append(LIBEMITTER=libdeps_emitter)
|
||||
if emitting_shared:
|
||||
env['_LIBDEPS_LIBS'] = '$_LIBDEPS_GET_LIBS'
|
||||
env.Append(
|
||||
PROGEMITTER=shlibdeps_emitter,
|
||||
SHLIBEMITTER=shlibdeps_emitter)
|
||||
else:
|
||||
|
||||
def expand_libdeps_with_extraction_flags(source, target, env, for_signature):
|
||||
result = []
|
||||
libs = get_libdeps(source, target, env, for_signature)
|
||||
for lib in libs:
|
||||
if 'init-no-global-side-effects' in env.Entry(lib).get_env().get('LIBDEPS_TAGS', []):
|
||||
result.append(str(lib))
|
||||
else:
|
||||
result.extend(env.subst('$LINK_WHOLE_ARCHIVE_LIB_START'
|
||||
'$TARGET'
|
||||
'$LINK_WHOLE_ARCHIVE_LIB_END', target=lib).split())
|
||||
return result
|
||||
|
||||
env['_LIBDEPS_LIBS_WITH_TAGS'] = expand_libdeps_with_extraction_flags
|
||||
|
||||
env['_LIBDEPS_LIBS'] = ('$LINK_WHOLE_ARCHIVE_START '
|
||||
'$LINK_LIBGROUP_START '
|
||||
'$_LIBDEPS_LIBS_WITH_TAGS '
|
||||
'$LINK_LIBGROUP_END '
|
||||
'$LINK_WHOLE_ARCHIVE_END')
|
||||
env.Append(
|
||||
PROGEMITTER=libdeps_emitter,
|
||||
SHLIBEMITTER=libdeps_emitter)
|
||||
env.Prepend(_LIBFLAGS=' $_LIBDEPS_TAGS $LINK_WHOLE_ARCHIVE_START $LINK_LIBGROUP_START $_LIBDEPS $LINK_LIBGROUP_END $LINK_WHOLE_ARCHIVE_END $_SYSLIBDEPS ')
|
||||
env.Prepend(_LIBFLAGS='$_LIBDEPS_TAGS $_LIBDEPS $_SYSLIBDEPS ')
|
||||
for builder_name in ('Program', 'SharedLibrary', 'LoadableModule'):
|
||||
try:
|
||||
update_scanner(env['BUILDERS'][builder_name])
|
||||
|
@ -51,6 +51,9 @@ debuggerEnv.Library(
|
||||
LIBDEPS=[
|
||||
# NOTE: You *must not* add any library dependencies to the debugger library
|
||||
],
|
||||
LIBDEPS_TAGS=[
|
||||
'init-no-global-side-effects',
|
||||
]
|
||||
)
|
||||
|
||||
env.Library(
|
||||
|
@ -340,6 +340,9 @@ env.Library(
|
||||
target='intel_decimal128',
|
||||
source=source_files,
|
||||
LIBS=libs,
|
||||
LIBDEPS_TAGS=[
|
||||
'init-no-global-side-effects',
|
||||
]
|
||||
)
|
||||
|
||||
readtest = env.Program(
|
||||
|
Loading…
Reference in New Issue
Block a user