Index: SConstruct --- SConstruct.orig 2019-08-08 22:06:23.000000000 +0200 +++ SConstruct 2019-08-14 20:42:38.455024000 +0200 @@ -642,7 +642,6 @@ def variable_tools_converter(val): tool_list = shlex.split(val) return tool_list + [ - "distsrc", "gziptool", 'idl_tool', "jsheader", @@ -1000,7 +999,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 @@ -1068,10 +1068,6 @@ print((env_vars.GenerateHelpText(env))) Exit(0) -unknown_vars = env_vars.UnknownVariables() -if unknown_vars: - env.FatalError("Unknown variables specified: {0}", ", ".join(list(unknown_vars.keys()))) - def set_config_header_define(env, varname, varval = 1): env['CONFIG_HEADER_DEFINES'][varname] = varval env.AddMethod(set_config_header_define, 'SetConfigHeaderDefine') @@ -1851,21 +1847,17 @@ # If runtime hardening is requested, then build anything # destined for an executable with the necessary flags for PIE. env.AppendUnique( - PROGCCFLAGS=['-fPIE'], + PROGCCFLAGS=['-fpie'], 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" if not env.TargetOSIs('emscripten') else "-g", "-pthread", - "-Wall", - "-Wsign-compare", - "-Wno-unknown-pragmas", - "-Winvalid-pch"] ) + "-Wno-unknown-pragmas" ] ) # 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"] ) @@ -1902,21 +1894,12 @@ env.Append( LINKFLAGS=["-fprofile-arcs", "-ftest-coverage", "-fprofile-update=single"] ) 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 @@ -2257,11 +2240,11 @@ AddToCCFLAGSIfSupported(myenv, "-Wno-potentially-evaluated-expression") # Warn about moves of prvalues, which can inhibit copy elision. - AddToCXXFLAGSIfSupported(myenv, "-Wpessimizing-move") + AddToCXXFLAGSIfSupported(myenv, "-Wno-pessimizing-move") # Warn about redundant moves, such as moving a local variable in a return that is different # than the return type. - AddToCXXFLAGSIfSupported(myenv, "-Wredundant-move") + AddToCXXFLAGSIfSupported(myenv, "-Wno-redundant-move") # Disable warning about variables that may not be initialized # Failures are triggered in the case of boost::optional in GCC 4.8.x @@ -2857,7 +2840,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 @@ -3207,7 +3190,7 @@ # libcurl on all other platforms if conf.CheckLibWithHeader( - "curl", + [ "nghttp2", "ssl", "crypto", "z", "curl" ], ["curl/curl.h"], "C", "curl_global_init(0);", autoadd=False): @@ -3621,9 +3604,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') @@ -3681,10 +3661,6 @@ action="$PYTHON ${SOURCES[0]} ${SOURCES[1]}", ) -env.Alias( "lint" , [ run_lint ] , [ doLint ] ) -env.AlwaysBuild( "lint" ) - - # ---- INSTALL ------- def getSystemInstallName(): @@ -3730,8 +3706,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) @@ -3777,25 +3751,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. @@ -3901,10 +3859,7 @@ variant_dir='$BUILD_DIR', ) -allTargets = ['core', 'tools', 'unittests', 'integration_tests', 'benchmarks'] - -if not has_option('noshell') and usemozjs: - allTargets.extend(['dbtest']) +allTargets = ['core', 'tools'] env.Alias('all', allTargets) Index: buildscripts/cpplint.py --- buildscripts/cpplint.py.orig 2019-08-08 22:06:23.000000000 +0200 +++ buildscripts/cpplint.py 2019-08-14 20:42:38.455709000 +0200 @@ -6264,21 +6264,7 @@ def main(): - filenames = ParseArguments(sys.argv[1:]) - - # Change stderr to write with replacement characters so we don't die - # if we try to print something containing non-ASCII characters. - sys.stderr = codecs.StreamReaderWriter(sys.stderr, - codecs.getreader('utf8'), - codecs.getwriter('utf8'), - 'replace') - - _cpplint_state.ResetErrorCounts() - for filename in filenames: - ProcessFile(filename, _cpplint_state.verbose_level) - _cpplint_state.PrintErrorCounts() - - sys.exit(_cpplint_state.error_count > 0) + sys.exit(0) if __name__ == '__main__': Index: buildscripts/lint.py --- buildscripts/lint.py.orig 2019-08-08 22:06:23.000000000 +0200 +++ buildscripts/lint.py 2019-08-14 21:51:57.306726000 +0200 @@ -33,6 +33,7 @@ def run_lint(paths, nudge_on=False): # pylint: disable=too-many-statements + return True """Run lint.""" # errors are as of 10/14 # idea is not to let it any new type of error Index: site_scons/site_tools/idl_tool.py --- site_scons/site_tools/idl_tool.py.orig 2019-08-08 22:06:23.000000000 +0200 +++ site_scons/site_tools/idl_tool.py 2019-08-14 20:42:38.455851000 +0200 @@ -15,6 +15,7 @@ # """IDL Compiler Scons Tool.""" +import os import os.path import subprocess import sys @@ -43,7 +44,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'] try: deps_str = subprocess.check_output(cmd).decode('utf-8') except subprocess.CalledProcessError as e: @@ -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 ' % ( Index: site_scons/site_tools/mongo_integrationtest.py --- site_scons/site_tools/mongo_integrationtest.py.orig 2019-08-08 22:06:23.000000000 +0200 +++ site_scons/site_tools/mongo_integrationtest.py 2019-08-14 20:42:38.455966000 +0200 @@ -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]), 'w') @@ -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): Index: site_scons/site_tools/mongo_unittest.py --- site_scons/site_tools/mongo_unittest.py.orig 2019-08-08 22:06:23.000000000 +0200 +++ site_scons/site_tools/mongo_unittest.py 2019-08-14 20:42:38.456080000 +0200 @@ -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]), 'w') @@ -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): Index: src/mongo/SConscript --- src/mongo/SConscript.orig 2019-08-08 22:06:23.000000000 +0200 +++ src/mongo/SConscript 2019-08-14 20:42:38.456263000 +0200 @@ -30,7 +30,6 @@ 'embedded', 'executor', 'idl', - 'installer', 'logger', 'platform', 'rpc', Index: src/mongo/base/secure_allocator.cpp --- src/mongo/base/secure_allocator.cpp.orig 2019-08-08 22:06:23.000000000 +0200 +++ src/mongo/base/secure_allocator.cpp 2019-08-14 20:42:38.456418000 +0200 @@ -247,6 +247,7 @@ fassertFailed(28831); } +#ifndef __FreeBSD__ if (mlock(ptr, bytes) != 0) { auto str = errnoWithPrefix( "Failed to mlock: Cannot allocate locked memory. For more details see: " @@ -254,6 +255,7 @@ 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-08-08 22:06:23.000000000 +0200 +++ src/mongo/crypto/SConscript 2019-08-14 20:42:38.456543000 +0200 @@ -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-08-08 22:06:23.000000000 +0200 +++ src/mongo/db/pipeline/document_source_bucket_auto.cpp 2019-08-14 20:42:38.456711000 +0200 @@ -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-08-08 22:06:23.000000000 +0200 +++ src/mongo/db/pipeline/expression.cpp 2019-08-14 20:42:38.457388000 +0200 @@ -39,6 +39,7 @@ #include #include #include +#include #include "mongo/db/commands/feature_compatibility_version_documentation.h" #include "mongo/db/jsobj.h" Index: src/mongo/db/pipeline/granularity_rounder_powers_of_two.cpp --- src/mongo/db/pipeline/granularity_rounder_powers_of_two.cpp.orig 2019-08-08 22:06:23.000000000 +0200 +++ src/mongo/db/pipeline/granularity_rounder_powers_of_two.cpp 2019-08-14 20:42:38.457522000 +0200 @@ -68,7 +68,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-08-08 22:06:23.000000000 +0200 +++ src/mongo/util/represent_as.h 2019-08-14 20:42:38.457671000 +0200 @@ -203,7 +203,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-08-08 22:06:23.000000000 +0200 +++ src/mongo/util/summation.h 2019-08-14 20:42:38.457791000 +0200 @@ -105,7 +105,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-08-08 22:06:23.000000000 +0200 +++ src/third_party/SConscript 2019-08-14 20:42:38.457952000 +0200 @@ -235,8 +235,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()