Index: SConstruct --- SConstruct.orig 2019-03-20 03:39:11.000000000 +0100 +++ SConstruct 2019-03-26 08:12:48.586483000 +0100 @@ -610,7 +610,6 @@ def variable_tools_converter(val): tool_list = shlex.split(val) return tool_list + [ - "distsrc", "gziptool", 'idl_tool', "jsheader", @@ -962,7 +961,8 @@ MODULE_INJECTORS=dict(), ARCHIVE_ADDITION_DIR_MAP={}, ARCHIVE_ADDITIONS=[], - PYTHON=utils.find_python(), + PYTHON=utils.which("python"), + PATH=os.environ.get("PATH"), SERVER_ARCHIVE='${SERVER_DIST_BASENAME}${DIST_ARCHIVE_SUFFIX}', UNITTEST_ALIAS='unittests', # TODO: Move unittests.txt to $BUILD_DIR, but that requires @@ -1013,9 +1013,9 @@ print(env_vars.GenerateHelpText(env)) Exit(0) -unknown_vars = env_vars.UnknownVariables() -if unknown_vars: - env.FatalError("Unknown variables specified: {0}", ", ".join(unknown_vars.keys())) +# unknown_vars = env_vars.UnknownVariables() +# if unknown_vars: +# env.FatalError("Unknown variables specified: {0}", ", ".join(unknown_vars.keys())) def set_config_header_define(env, varname, varval = 1): env['CONFIG_HEADER_DEFINES'][varname] = varval @@ -1752,21 +1752,19 @@ # If runtime hardening is requested, then build anything # destined for an executable with the necessary flags for PIE. env.AppendUnique( - PROGCCFLAGS=['-fPIE'], + PROGCCFLAGS=['-fpic'], PROGLINKFLAGS=['-pie'], ) # -Winvalid-pch Warn if a precompiled header (see Precompiled Headers) is found in the search path but can't be used. env.Append( CCFLAGS=["-fno-omit-frame-pointer", "-fno-strict-aliasing", - "-ggdb", "-pthread", - "-Wall", "-Wsign-compare", "-Wno-unknown-pragmas", "-Winvalid-pch"] ) # env.Append( " -Wconversion" ) TODO: this doesn't really work yet - if env.TargetOSIs('linux', 'darwin', 'solaris'): + if env.TargetOSIs('linux', 'darwin', 'solaris', 'freebsd'): if not has_option("disable-warnings-as-errors"): env.Append( CCFLAGS=["-Werror"] ) @@ -1803,21 +1801,12 @@ env.Append( LINKFLAGS=["-fprofile-arcs", "-ftest-coverage"] ) if optBuild and not optBuildForSize: - env.Append( CCFLAGS=["-O2"] ) + env.Append( CCFLAGS=["-O1"] ) elif optBuild and optBuildForSize: env.Append( CCFLAGS=["-Os"] ) else: env.Append( CCFLAGS=["-O0"] ) - # Promote linker warnings into errors. We can't yet do this on OS X because its linker considers - # noall_load obsolete and warns about it. - if not has_option("disable-warnings-as-errors"): - env.Append( - LINKFLAGS=[ - '-Wl,-fatal_warnings' if env.TargetOSIs('darwin') else "-Wl,--fatal-warnings", - ] - ) - mmapv1 = False if get_option('mmapv1') == 'auto': # The mmapv1 storage engine is only supported on x86 @@ -2751,7 +2740,7 @@ }} """ context.Message('Checking for storage class thread_local ') - ret = context.TryLink(textwrap.dedent(test_body), ".cpp") + ret = context.TryCompile(textwrap.dedent(test_body), ".cpp") context.Result(ret) return ret @@ -3081,7 +3070,7 @@ if not env.TargetOSIs("windows") \ and free_monitoring == "on" \ and not conf.CheckLibWithHeader( - "curl", + [ "nghttp2", "ssl", "crypto", "z", "curl" ], ["curl/curl.h"], "C", "curl_global_init(0);", autoadd=False): @@ -3455,9 +3444,6 @@ elif get_option('separate-debug') == "on": env.FatalError('Cannot use --separate-debug without --install-mode=hygienic') -# Now that we are done with configure checks, enable icecream, if available. -env.Tool('icecream') - # If the flags in the environment are configured for -gsplit-dwarf, # inject the necessary emitter. split_dwarf = Tool('split_dwarf') @@ -3562,8 +3548,6 @@ ) ) -env.AddDistSrcCallback(add_version_to_distsrc) - env['SERVER_DIST_BASENAME'] = env.subst('mongodb-%s-$MONGO_DISTNAME' % (getSystemInstallName())) module_sconscripts = moduleconfig.get_module_sconscripts(mongo_modules) @@ -3608,25 +3592,9 @@ vcxprojFile = env.Command( "mongodb.vcxproj", compileCommands, - r"$PYTHON buildscripts\make_vcxproj.py mongodb") + r"$PYTHON buildscripts/make_vcxproj.py mongodb") vcxproj = env.Alias("vcxproj", vcxprojFile) -distSrc = env.DistSrc("mongodb-src-${MONGO_VERSION}.tar") -env.NoCache(distSrc) -env.Alias("distsrc-tar", distSrc) - -distSrcGzip = env.GZip( - target="mongodb-src-${MONGO_VERSION}.tgz", - source=[distSrc]) -env.NoCache(distSrcGzip) -env.Alias("distsrc-tgz", distSrcGzip) - -distSrcZip = env.DistSrc("mongodb-src-${MONGO_VERSION}.zip") -env.NoCache(distSrcZip) -env.Alias("distsrc-zip", distSrcZip) - -env.Alias("distsrc", "distsrc-tgz") - # Defaults for SCons provided flags. SetOption only sets the option to our value # if the user did not provide it. So for any flag here if it's explicitly passed # the values below set with SetOption will be overwritten. @@ -3726,7 +3694,7 @@ variant_dir='$BUILD_DIR', ) -all = env.Alias('all', ['core', 'tools', 'dbtest', 'unittests', 'integration_tests', 'benchmarks']) +all = env.Alias('all', ['core', 'tools']) # run the Dagger tool if it's installed if should_dagger: Index: site_scons/site_tools/mongo_integrationtest.py --- site_scons/site_tools/mongo_integrationtest.py.orig 2019-03-20 03:39:11.000000000 +0100 +++ site_scons/site_tools/mongo_integrationtest.py 2019-03-26 08:11:36.757757000 +0100 @@ -7,9 +7,7 @@ _integration_tests = [] def register_integration_test(env, test): - installed_test = env.Install("#/build/integration_tests/", test) - _integration_tests.append(installed_test[0].path) - env.Alias('$INTEGRATION_TEST_ALIAS', installed_test) + return True def integration_test_list_builder_action(env, target, source): ofile = open(str(target[0]), 'wb') @@ -21,15 +19,7 @@ ofile.close() def build_cpp_integration_test(env, target, source, **kwargs): - libdeps = kwargs.get('LIBDEPS', []) - libdeps.append( '$BUILD_DIR/mongo/unittest/integration_test_main' ) - - kwargs['LIBDEPS'] = libdeps - kwargs['INSTALL_ALIAS'] = ['tests'] - - result = env.Program(target, source, **kwargs) - env.RegisterIntegrationTest(result[0]) - return result + return True def generate(env): env.Command('$INTEGRATION_TEST_LIST', env.Value(_integration_tests), Index: site_scons/site_tools/mongo_unittest.py --- site_scons/site_tools/mongo_unittest.py.orig 2019-03-20 03:39:11.000000000 +0100 +++ site_scons/site_tools/mongo_unittest.py 2019-03-26 08:11:36.757866000 +0100 @@ -7,8 +7,7 @@ _unittests = [] def register_unit_test(env, test): - _unittests.append(test.path) - env.Alias('$UNITTEST_ALIAS', test) + return True def unit_test_list_builder_action(env, target, source): ofile = open(str(target[0]), 'wb') @@ -20,18 +19,7 @@ ofile.close() def build_cpp_unit_test(env, target, source, **kwargs): - libdeps = kwargs.get('LIBDEPS', []) - libdeps.append( '$BUILD_DIR/mongo/unittest/unittest_main' ) - - kwargs['LIBDEPS'] = libdeps - kwargs['INSTALL_ALIAS'] = ['tests'] - - result = env.Program(target, source, **kwargs) - env.RegisterUnitTest(result[0]) - hygienic = env.GetOption('install-mode') == 'hygienic' - if not hygienic: - env.Install("#/build/unittests/", result[0]) - return result + return True def generate(env): env.Command('$UNITTEST_LIST', env.Value(_unittests), Index: src/mongo/SConscript --- src/mongo/SConscript.orig 2019-03-20 03:39:11.000000000 +0100 +++ src/mongo/SConscript 2019-03-26 08:11:36.758035000 +0100 @@ -29,7 +29,6 @@ 'embedded', 'executor', 'idl', - 'installer', 'logger', 'platform', 'rpc', Index: src/mongo/base/secure_allocator.cpp --- src/mongo/base/secure_allocator.cpp.orig 2019-03-20 03:39:11.000000000 +0100 +++ src/mongo/base/secure_allocator.cpp 2019-03-26 08:11:36.758186000 +0100 @@ -249,11 +249,13 @@ fassertFailed(28831); } +#ifndef __FreeBSD__ if (mlock(ptr, bytes) != 0) { auto str = errnoWithPrefix("Failed to mlock"); severe() << str; fassertFailed(28832); } +#endif #if defined(MADV_DONTDUMP) // We deliberately ignore the return value since if the Linux version is < 3.4, madvise @@ -270,10 +272,12 @@ (void)madvise(ptr, bytes, MADV_DODUMP); #endif +#ifndef __FreeBSD__ if (munlock(ptr, bytes) != 0) { severe() << errnoWithPrefix("Failed to munlock"); fassertFailed(28833); } +#endif if (munmap(ptr, bytes) != 0) { severe() << errnoWithPrefix("Failed to munmap"); Index: src/mongo/crypto/SConscript --- src/mongo/crypto/SConscript.orig 2019-03-20 03:39:11.000000000 +0100 +++ src/mongo/crypto/SConscript 2019-03-26 08:11:36.758308000 +0100 @@ -2,6 +2,10 @@ Import("env") +def has_option(name): + optval = GetOption(name) + return True if optval == () else bool(optval) + env = env.Clone() env.Library('sha1_block', @@ -46,7 +50,7 @@ ] ) -else: +elif has_option("ssl"): env.Library('sha_block_${MONGO_CRYPTO}', source=[ 'sha_block_${MONGO_CRYPTO}.cpp' Index: src/mongo/db/pipeline/document_source_bucket_auto.cpp --- src/mongo/db/pipeline/document_source_bucket_auto.cpp.orig 2019-03-20 03:39:11.000000000 +0100 +++ src/mongo/db/pipeline/document_source_bucket_auto.cpp 2019-03-26 08:11:36.758474000 +0100 @@ -207,7 +207,7 @@ // Calculate the approximate bucket size. We attempt to fill each bucket with this many // documents. - long long approxBucketSize = std::round(double(_nDocuments) / double(_nBuckets)); + long long approxBucketSize = round(double(_nDocuments) / double(_nBuckets)); if (approxBucketSize < 1) { // If the number of buckets is larger than the number of documents, then we try to make as Index: src/mongo/db/pipeline/expression.cpp --- src/mongo/db/pipeline/expression.cpp.orig 2019-03-20 03:39:11.000000000 +0100 +++ src/mongo/db/pipeline/expression.cpp 2019-03-26 08:11:36.759110000 +0100 @@ -37,6 +37,7 @@ #include #include #include +#include #include "mongo/db/commands/feature_compatibility_version_documentation.h" #include "mongo/db/jsobj.h" @@ -4806,7 +4807,7 @@ return Value(numericArg.getDecimal().quantize(Decimal128::kNormalizedZero, Decimal128::kRoundTowardZero)); case NumberDouble: - return Value(std::trunc(numericArg.getDouble())); + return Value(trunc(numericArg.getDouble())); default: return numericArg; } Index: src/mongo/db/pipeline/granularity_rounder_powers_of_two.cpp --- src/mongo/db/pipeline/granularity_rounder_powers_of_two.cpp.orig 2019-03-20 03:39:11.000000000 +0100 +++ src/mongo/db/pipeline/granularity_rounder_powers_of_two.cpp 2019-03-26 08:11:36.759243000 +0100 @@ -69,7 +69,7 @@ Value exp; if (value.getType() == BSONType::NumberDouble) { - exp = Value(static_cast(std::floor(std::log2(value.getDouble())) + 1.0)); + exp = Value(static_cast(std::floor(log2(value.getDouble())) + 1.0)); } else if (value.getType() == BSONType::NumberDecimal) { Decimal128 input = value.getDecimal(); exp = Value(Decimal128( @@ -94,7 +94,7 @@ Value exp; if (value.getType() == BSONType::NumberDouble) { - exp = Value(static_cast(std::ceil(std::log2(value.getDouble())) - 1.0)); + exp = Value(static_cast(std::ceil(log2(value.getDouble())) - 1.0)); } else if (value.getType() == BSONType::NumberDecimal) { Decimal128 input = value.getDecimal(); exp = Value(Decimal128( Index: src/mongo/util/represent_as.h --- src/mongo/util/represent_as.h.orig 2019-03-20 03:39:11.000000000 +0100 +++ src/mongo/util/represent_as.h 2019-03-26 08:11:36.759383000 +0100 @@ -204,7 +204,7 @@ // If Output is integral and number is a non-integral floating point value, // return a disengaged optional. if (std::is_floating_point::value && std::is_integral::value) { - if (!(std::trunc(number) == number)) { + if (!(trunc(number) == number)) { return {}; } } Index: src/mongo/util/summation.h --- src/mongo/util/summation.h.orig 2019-03-20 03:39:11.000000000 +0100 +++ src/mongo/util/summation.h 2019-03-26 08:11:36.759501000 +0100 @@ -106,7 +106,7 @@ * Returns whether the accumulated sum has a fractional part. */ bool isInteger() const { - return std::trunc(_sum) == _sum && std::trunc(_addend) == _addend; + return trunc(_sum) == _sum && trunc(_addend) == _addend; } /** Index: src/third_party/SConscript --- src/third_party/SConscript.orig 2019-03-20 03:39:11.000000000 +0100 +++ src/third_party/SConscript 2019-03-26 08:11:36.759636000 +0100 @@ -128,8 +128,8 @@ if use_system_version_of_library("pcre"): pcreEnv = env.Clone( SYSLIBDEPS=[ - env['LIBDEPS_PCRE_SYSLIBDEP'], env['LIBDEPS_PCRECPP_SYSLIBDEP'], + env['LIBDEPS_PCRE_SYSLIBDEP'], ]) else: pcreEnv = env.Clone() Index: site_scons/site_tools/idl_tool.py --- site_scons/site_tools/idl_tool.py.orig 2019-03-20 03:39:11.000000000 +0100 +++ site_scons/site_tools/idl_tool.py 2019-03-26 08:11:36.757649000 +0100 @@ -15,6 +15,7 @@ # """IDL Compiler Scons Tool.""" +import os import os.path import subprocess import sys @@ -42,7 +43,7 @@ def idl_scanner(node, env, path): # Use the import scanner mode of the IDL compiler to file imported files - cmd = [sys.executable, "buildscripts/idl/idlc.py", '--include','src', str(node), '--write-dependencies'] + cmd = [os.environ.get("PYTHON", "python"), "buildscripts/idl/idlc.py", '--include','src', str(node), '--write-dependencies'] deps_str = subprocess.check_output(cmd) deps_list = deps_str.splitlines() @@ -73,7 +74,7 @@ env['BUILDERS']['Idlc'] = bld - env['IDLC'] = sys.executable + " buildscripts/idl/idlc.py" + env['IDLC'] = os.environ.get("PYTHON", "python") + " buildscripts/idl/idlc.py" env['IDLCFLAGS'] = '' base_dir = env.subst('$BUILD_ROOT/$VARIANT_DIR').replace("#", "") env['IDLCCOM'] = '$IDLC --include src --base_dir %s --target_arch $TARGET_ARCH --header ${TARGETS[1]} --output ${TARGETS[0]} $SOURCES ' % (base_dir)