Skip to content

Commit 8703aa6

Browse files
committed
SERVER-16784 only enable the minimum needed set of Scons Tools
1 parent 75ca260 commit 8703aa6

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

SConstruct

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,27 @@ v8suffix = '' if v8version == '3.12' else '-' + v8version
458458

459459
usePCH = has_option( "usePCH" )
460460

461+
# The Scons 'default' tool enables a lot of tools that we don't actually need to enable.
462+
# On platforms like Solaris, it actually does the wrong thing by enabling the sunstudio
463+
# toolchain first. As such it is simpler and more efficient to manually load the precise
464+
# set of tools we need for each platform.
465+
# If we aren't on a platform where we know the minimal set of tools, we fall back to loading
466+
# the 'default' tool.
467+
def decide_platform_tools():
468+
if windows:
469+
# we only support MS toolchain on windows
470+
return ['msvc', 'mslink', 'mslib']
471+
elif linux:
472+
return ['gcc', 'g++', 'gnulink', 'ar']
473+
elif solaris:
474+
return ['gcc', 'g++', 'gnulink', 'ar']
475+
elif darwin:
476+
return ['gcc', 'g++', 'applelink', 'ar']
477+
else:
478+
return ["default"]
479+
480+
tools = decide_platform_tools() + ["gch", "jsheader", "mergelib", "mongo_unittest", "textfile"]
481+
461482
# We defer building the env until we have determined whether we want certain values. Some values
462483
# in the env actually have semantics for 'None' that differ from being absent, so it is better
463484
# to build it up via a dict, and then construct the Environment in one shot with kwargs.
@@ -476,7 +497,7 @@ envDict = dict(BUILD_ROOT=buildDir,
476497
ARCHIVE_ADDITIONS=[],
477498
PYTHON=utils.find_python(),
478499
SERVER_ARCHIVE='${SERVER_DIST_BASENAME}${DIST_ARCHIVE_SUFFIX}',
479-
tools=["default", "gch", "jsheader", "mergelib", "mongo_unittest", "textfile"],
500+
tools=tools,
480501
UNITTEST_ALIAS='unittests',
481502
# TODO: Move unittests.txt to $BUILD_DIR, but that requires
482503
# changes to MCI.
@@ -533,20 +554,6 @@ if has_option("cache"):
533554
Exit(1)
534555
env.CacheDir(str(env.Dir(cacheDir)))
535556

536-
# This could be 'if solaris', but unfortuantely that variable hasn't been set yet.
537-
if "sunos5" == os.sys.platform:
538-
# SERVER-9890: On Solaris, SCons preferentially loads the sun linker tool 'sunlink' when
539-
# using the 'default' tools as we do above. The sunlink tool sets -G as the flag for
540-
# creating a shared library. But we don't want that, since we always drive our link step
541-
# through CC or CXX. Instead, we want to let the compiler map GCC's '-shared' flag to the
542-
# appropriate linker specs that it has compiled in. We could (and should in the future)
543-
# select an empty set of tools above and then enable them as appropriate on a per platform
544-
# basis. Until then the simplest solution, as discussed on the scons-users mailing list,
545-
# appears to be to simply explicitly run the 'gnulink' tool to overwrite the Environment
546-
# changes made by 'sunlink'. See the following thread for more detail:
547-
# http://four.pairlist.net/pipermail/scons-users/2013-June/001486.html
548-
env.Tool('gnulink')
549-
550557
if optBuild:
551558
env.Append( CPPDEFINES=["MONGO_OPTIMIZED_BUILD"] )
552559

0 commit comments

Comments
 (0)