diff options
author | Mathew Robinson <mathew.robinson@mongodb.com> | 2020-01-06 17:22:37 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2020-01-06 17:22:37 +0000 |
commit | 3842544b5e534b87c9bfc46d9c67b8726fd6b27b (patch) | |
tree | a658df27ed395a7ca606d02e0084f782f440f83a /site_scons | |
parent | 7099b048c2a6f4b5900c32e46ef6ac6269449a42 (diff) | |
download | mongo-3842544b5e534b87c9bfc46d9c67b8726fd6b27b.tar.gz |
SERVER-45337 Speed up libdeps subst performance
Diffstat (limited to 'site_scons')
-rw-r--r-- | site_scons/libdeps.py | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/site_scons/libdeps.py b/site_scons/libdeps.py index 4dc818cb3d6..e3f05f6aa7b 100644 --- a/site_scons/libdeps.py +++ b/site_scons/libdeps.py @@ -369,6 +369,36 @@ def expand_libdeps_tags(source, target, env, for_signature): return results +def expand_libdeps_with_extraction_flags(source, target, env, for_signature): + result = [] + libs = get_libdeps(source, target, env, for_signature) + whole_archive_start = env.subst("$LINK_WHOLE_ARCHIVE_LIB_START") + whole_archive_end = env.subst("$LINK_WHOLE_ARCHIVE_LIB_END") + whole_archive_separator = env.get("LINK_WHOLE_ARCHIVE_SEP", " ") + for lib in libs: + if isinstance(lib, (str, SCons.Node.FS.File, SCons.Node.FS.Entry)): + lib_target = str(lib) + else: + lib_target = env.subst("$TARGET", target=lib) + + if "init-no-global-side-effects" in env.Entry(lib).get_env().get( + "LIBDEPS_TAGS", [] + ): + result.append(lib_target) + else: + whole_archive_flag = "{}{}{}".format( + whole_archive_start, whole_archive_separator, lib_target + ) + if whole_archive_end: + whole_archive_flag += "{}{}".format( + whole_archive_separator, whole_archive_end + ) + + result.extend(whole_archive_flag.split()) + + return result + + def setup_environment(env, emitting_shared=False): """Set up the given build environment to do LIBDEPS tracking.""" @@ -412,25 +442,6 @@ def setup_environment(env, emitting_shared=False): PROGEMITTER=make_indirect_emitter("LIBDEPS_PROGEMITTER"), ) - 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"] = ( |