diff options
-rw-r--r-- | SConstruct | 132 | ||||
-rw-r--r-- | etc/evergreen.yml | 177 | ||||
-rw-r--r-- | src/mongo/db/index/sort_key_generator_test.cpp | 32 | ||||
-rw-r--r-- | src/mongo/db/update/push_node.cpp | 26 |
4 files changed, 105 insertions, 262 deletions
diff --git a/SConstruct b/SConstruct index 499697acc29..6697b787ee9 100644 --- a/SConstruct +++ b/SConstruct @@ -475,8 +475,8 @@ add_option('cache-dir', ) add_option("cxx-std", - choices=["14", "17"], - default="14", + choices=["17"], + default="17", help="Select the C++ langauge standard to build with", ) @@ -1614,43 +1614,77 @@ elif env.TargetOSIs('windows'): env.Append( CPPDEFINES=[ "UNICODE" ] ) # Temporary fixes to allow compilation with VS2017 - env.Append( CPPDEFINES=[ "_SILENCE_FPOS_SEEKPOS_DEPRECATION_WARNING" ] ) + env.Append(CPPDEFINES=[ + "_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS", + "_SILENCE_FPOS_SEEKPOS_DEPRECATION_WARNING", + ]) # /EHsc exception handling style for visual studio # /W3 warning level env.Append(CCFLAGS=["/EHsc","/W3"]) - # some warnings we don't like: - # c4355 - # 'this' : used in base member initializer list - # The this pointer is valid only within nonstatic member functions. It cannot be used in the initializer list for a base class. - # c4800 - # 'type' : forcing value to bool 'true' or 'false' (performance warning) - # This warning is generated when a value that is not bool is assigned or coerced into type bool. - # c4267 - # 'var' : conversion from 'size_t' to 'type', possible loss of data - # When compiling with /Wp64, or when compiling on a 64-bit operating system, type is 32 bits but size_t is 64 bits when compiling for 64-bit targets. To fix this warning, use size_t instead of a type. - # c4244 - # 'conversion' conversion from 'type1' to 'type2', possible loss of data - # An integer type is converted to a smaller integer type. - # c4290 - # C++ exception specification ignored except to indicate a function is not __declspec(nothrow - # A function is declared using exception specification, which Visual C++ accepts but does not - # implement - # c4068 - # unknown pragma -- added so that we can specify unknown pragmas for other compilers - # c4351 - # on extremely old versions of MSVC (pre 2k5), default constructing an array member in a - # constructor's initialization list would not zero the array members "in some cases". - # since we don't target MSVC versions that old, this warning is safe to ignore. - # c4373 - # Older versions of MSVC would fail to make a function in a derived class override a virtual - # function in the parent, when defined inline and at least one of the parameters is made const. - # The behavior is incorrect under the standard. MSVC is fixed now, and the warning exists - # merely to alert users who may have relied upon the older, non-compliant behavior. Our code - # should not have any problems with the older behavior, so we can just disable this warning. - env.Append( CCFLAGS=["/wd4355", "/wd4800", "/wd4267", "/wd4244", - "/wd4290", "/wd4068", "/wd4351", "/wd4373"] ) + # Suppress some warnings we don't like, or find necessary to + # suppress. Please keep this list alphabetized and commented. + env.Append(CCFLAGS=[ + + # C4068: unknown pragma. added so that we can specify unknown + # pragmas for other compilers. + "/wd4068", + + # C4244: 'conversion' conversion from 'type1' to 'type2', + # possible loss of data. An integer type is converted to a + # smaller integer type. + "/wd4244", + + # C4267: 'var' : conversion from 'size_t' to 'type', possible + # loss of data. When compiling with /Wp64, or when compiling + # on a 64-bit operating system, type is 32 bits but size_t is + # 64 bits when compiling for 64-bit targets. To fix this + # warning, use size_t instead of a type. + "/wd4267", + + # C4290: C++ exception specification ignored except to + # indicate a function is not __declspec(nothrow). A function + # is declared using exception specification, which Visual C++ + # accepts but does not implement. + "/wd4290", + + # C4351: On extremely old versions of MSVC (pre 2k5), default + # constructing an array member in a constructor's + # initialization list would not zero the array members "in + # some cases". Since we don't target MSVC versions that old, + # this warning is safe to ignore. + "/wd4351", + + # C4355: 'this' : used in base member initializer list. The + # this pointer is valid only within nonstatic member + # functions. It cannot be used in the initializer list for a + # base class + "/wd4355", + + # C4373: Older versions of MSVC would fail to make a function + # in a derived class override a virtual function in the + # parent, when defined inline and at least one of the + # parameters is made const. The behavior is incorrect under + # the standard. MSVC is fixed now, and the warning exists + # merely to alert users who may have relied upon the older, + # non-compliant behavior. Our code should not have any + # problems with the older behavior, so we can just disable + # this warning. + "/wd4373", + + # C4800: 'type' : forcing value to bool 'true' or 'false' + # (performance warning). This warning is generated when a + # value that is not bool is assigned or coerced into type + # bool. + "/wd4800", + + # C5041: out-of-line definition for constexpr static data + # member is not needed and is deprecated in C++17. We still + # have these, but we don't want to fix them up before we roll + # over to C++17. + "/wd5041", + ]) # mozjs-60 requires the following # 'declaration' : no matching operator delete found; memory will not be freed if @@ -2373,15 +2407,10 @@ def doConfigure(myenv): if myenv.ToolchainIs('msvc'): myenv.AppendUnique(CXXFLAGS=['/Zc:__cplusplus']) - if get_option('cxx-std') == "14": - myenv.AppendUnique(CCFLAGS=['/std:c++14']) - elif get_option('cxx-std') == "17": + if get_option('cxx-std') == "17": myenv.AppendUnique(CCFLAGS=['/std:c++17']) else: - if get_option('cxx-std') == "14": - if not AddToCXXFLAGSIfSupported(myenv, '-std=c++14'): - myenv.ConfError('Compiler does not honor -std=c++14') - elif get_option('cxx-std') == "17": + if get_option('cxx-std') == "17": if not AddToCXXFLAGSIfSupported(myenv, '-std=c++17'): myenv.ConfError('Compiler does not honor -std=c++17') @@ -2391,21 +2420,6 @@ def doConfigure(myenv): if using_system_version_of_cxx_libraries(): print( 'WARNING: System versions of C++ libraries must be compiled with C++14/17 support' ) - def CheckCxx14(context): - test_body = """ - #if __cplusplus < 201402L - #error - #endif - auto DeducedReturnTypesAreACXX14Feature() { - return 0; - } - """ - - context.Message('Checking for C++14... ') - ret = context.TryCompile(textwrap.dedent(test_body), ".cpp") - context.Result(ret) - return ret - def CheckCxx17(context): test_body = """ #if __cplusplus < 201703L @@ -2420,15 +2434,11 @@ def doConfigure(myenv): return ret conf = Configure(myenv, help=False, custom_tests = { - 'CheckCxx14' : CheckCxx14, 'CheckCxx17' : CheckCxx17, }) - if not conf.CheckCxx14(): - myenv.ConfError('C++14 support is required to build MongoDB') - if get_option('cxx-std') == "17" and not conf.CheckCxx17(): - myenv.ConfError('C++17 was requested, but the compiler appears not to offer it') + myenv.ConfError('C++17 support is required to build MongoDB') conf.Finish() diff --git a/etc/evergreen.yml b/etc/evergreen.yml index ade4c5ea1a6..7dbd64a7a60 100644 --- a/etc/evergreen.yml +++ b/etc/evergreen.yml @@ -8334,91 +8334,6 @@ buildvariants: - name: publish_packages - name: push -- name: enterprise-ubuntu1804-64-gcc-cxx17 - display_name: ~ Enterprise Ubuntu 18.04 (System GCC 7.x C++17 DEBUG) - modules: - - enterprise - run_on: - - ubuntu1804-test - batchtime: 1440 # 1 day - expansions: - compile_flags: >- - --dbg=on - --opt=on - --ssl - -j$(grep -c ^processor /proc/cpuinfo) - CC=gcc-7 - CXX=g++-7 - --cxx-std=17 - --disable-warnings-as-errors - repo_edition: enterprise - scons_cache_scope: shared - tooltags: "ssl sasl" - build_mongoreplay: true - display_tasks: - - *dbtest - - *unittests - tasks: - - name: compile_all_run_unittests_TG - distros: - - ubuntu1804-build - - name: audit - - name: ese - - name: jsCore - - name: jsCore_auth - - name: jsCore_txns - - name: causally_consistent_jscore_txns_passthrough - - name: sasl - - name: snmp - - name: ssl - - name: sslSpecial - -- name: enterprise-ubuntu1804-64-clang-cxx17 - display_name: ~ Enterprise Ubuntu 18.04 (System clang 6.0 C++17 libc++ DEBUG) - modules: - - enterprise - run_on: - - ubuntu1804-test - batchtime: 1440 # 1 day - expansions: - compile_flags: >- - --dbg=on - --opt=on - --ssl - -j$(grep -c ^processor /proc/cpuinfo) - CC=clang-6.0 - CXX=clang++-6.0 - --libc++ - --cxx-std=17 - --disable-warnings-as-errors - CXXFLAGS="-Wno-register" - repo_edition: enterprise - scons_cache_scope: shared - tooltags: "ssl sasl" - build_mongoreplay: true - display_tasks: - - *dbtest - - *unittests - tasks: - - name: compile_all_run_unittests_TG - distros: - - ubuntu1804-build - - name: audit - - name: ese - - name: jsCore - - name: jsCore_auth - - name: jsCore_txns - - name: causally_consistent_jscore_txns_passthrough - - name: replica_sets_auth - - name: sasl - - name: sharding_auth - - name: snmp - - name: ssl - - name: sslSpecial - - name: stitch_support_lib_build_and_test - - name: stitch_support_lib_build_and_archive - - name: watchdog_wiredtiger - - name: ubuntu1604 display_name: SSL Ubuntu 16.04 run_on: @@ -10361,55 +10276,6 @@ buildvariants: distros: - rhel70-small -- name: enterprise-osx-1011-xcode-10-cxx17 - display_name: ~ Enterprise macOS 10.11 (XCode 10.1 C++17) - modules: - - enterprise - run_on: - - macos-1014 - batchtime: 1440 # 1 day - expansions: - test_flags: --excludeWithAnyTags=requires_ssl_mongo_tools - compile_env: DEVELOPER_DIR=/Applications/Xcode10.1.app - compile_flags: >- - --ssl - -j$(sysctl -n hw.logicalcpu) - --libc++ - --variables-files=etc/scons/xcode_macosx.vars - --cxx-std=17 - CXXFLAGS="-Wno-register" - resmoke_jobs_max: 1 - tooltags: "ssl sasl" - build_mongoreplay: true - display_tasks: - - *dbtest - - *unittests - tasks: - - name: compile_all_run_unittests_TG - - name: audit - - name: auth_audit - - name: ese - - name: jsCore - - name: jsCore_auth - - name: jsCore_txns - - name: causally_consistent_jscore_txns_passthrough - - name: jstestfuzz_gen - - name: jstestfuzz_concurrent_gen - - name: jstestfuzz_concurrent_replication_gen - - name: jstestfuzz_concurrent_sharded_gen - - name: jstestfuzz_replication_gen - - name: jstestfuzz_sharded_gen - - name: logical_session_cache_replication_1sec_refresh_jscore_passthrough - - name: logical_session_cache_sharding_1sec_refresh_jscore_passthrough - - name: logical_session_cache_standalone_1sec_refresh_jscore_passthrough - - name: replica_sets_auth - - name: replica_sets_jscore_passthrough - - name: sasl - - name: ssl - - name: sslSpecial - - name: stitch_support_lib_build_and_test - - name: stitch_support_lib_build_and_archive - - name: enterprise-osx-1010-openssl display_name: ~ Enterprise macOS 10.10 OpenSSL modules: @@ -10739,7 +10605,6 @@ buildvariants: -j$(grep -c ^processor /proc/cpuinfo) --toolchain-root=$(dirname $(pwd))/android_toolchain-arm-21 --variables-files=etc/scons/android_toolchain.vars - --cxx-std=17 LIBS=clang_rt.builtins-arm-android LIBPATH="$(dirname $($(dirname $(pwd))/android_toolchain-arm-21/bin/clang -print-file-name=libclang_rt.builtins-arm-android.a)) \$BUILD_ROOT/mongo-embedded-sdk-\$MONGO_VERSION/lib" --lto @@ -10782,7 +10647,6 @@ buildvariants: -j$(grep -c ^processor /proc/cpuinfo) --toolchain-root=$(dirname $(pwd))/android_toolchain-arm64-21 --variables-files=etc/scons/android_toolchain.vars - --cxx-std=17 LIBPATH="\$BUILD_ROOT/mongo-embedded-sdk-\$MONGO_VERSION/lib" --lto AR=$(dirname $(pwd))/android_toolchain-arm64-21/bin/llvm-ar @@ -10824,7 +10688,6 @@ buildvariants: -j$(grep -c ^processor /proc/cpuinfo) --toolchain-root=$(dirname $(pwd))/android_toolchain-x86_64-21 --variables-files=etc/scons/android_toolchain.vars - --cxx-std=17 LIBPATH="\$BUILD_ROOT/mongo-embedded-sdk-\$MONGO_VERSION/lib" --lto AR=$(dirname $(pwd))/android_toolchain-x86_64-21/bin/llvm-ar @@ -14419,43 +14282,3 @@ buildvariants: stepback: false tasks: - name: shared_scons_cache_pruning - -- name: windows-64-vs2017-cxx17 - display_name: "Windows VS2017 Canary C++17 Builder" - run_on: - - windows-64-vs2017-test - modules: - - enterprise - expansions: - platform_decompress: unzip - exe: ".exe" - content_type: application/zip - compile_flags: CPPPATH="c:/sasl/include c:/snmp/include" LIBPATH="c:/sasl/lib c:/snmp/lib" MSVC_VERSION=14.1 CXXFLAGS="/wd4834 /wd5033 /wd5041" CPPDEFINES="_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS" --cxx-std=17 --dynamic-windows --dbg=off --opt=on -j$(( $(grep -c ^processor /proc/cpuinfo) / 2 )) - # We invoke SCons using --jobs = (# of CPUs / 4) to avoid causing out of memory errors due to - # spawning a large number of linker processes. - num_scons_link_jobs_available: $(( $(grep -c ^processor /proc/cpuinfo) / 4 )) - python: python - python3: '/cygdrive/c/python/python36/python.exe' - ext: zip - use_scons_cache: true - multiversion_platform: windows - multiversion_edition: enterprise - tooltags: "" - build_mongoreplay: false - display_tasks: - - *dbtest - - *unittests - tasks: - - name: compile_all_run_unittests_TG - distros: - - windows-64-vs2017-compile - - name: audit - - name: ese - - name: jsCore - - name: jsCore_auth - - name: jsCore_txns - - name: causally_consistent_jscore_txns_passthrough - - name: sasl - - name: snmp - - name: ssl - - name: sslSpecial diff --git a/src/mongo/db/index/sort_key_generator_test.cpp b/src/mongo/db/index/sort_key_generator_test.cpp index 388eeb10f57..1618cb57495 100644 --- a/src/mongo/db/index/sort_key_generator_test.cpp +++ b/src/mongo/db/index/sort_key_generator_test.cpp @@ -136,35 +136,39 @@ TEST(SortKeyGeneratorTest, SortKeyGenerationForArraysRespectsCompoundOrdering) { DEATH_TEST(SortKeyGeneratorTest, SortPatternComponentWithStringIsFatal, "Invariant failure elt.type() == BSONType::Object") { - stdx::make_unique<SortKeyGenerator>(BSON("a" - << "foo"), - nullptr); + MONGO_COMPILER_VARIABLE_UNUSED auto ignored = + stdx::make_unique<SortKeyGenerator>(BSON("a" + << "foo"), + nullptr); } DEATH_TEST(SortKeyGeneratorTest, SortPatternComponentWhoseObjectHasMultipleKeysIsFatal, "Invariant failure elt.embeddedObject().nFields() == 1") { - stdx::make_unique<SortKeyGenerator>(BSON("a" << BSON("$meta" - << "textScore" - << "extra" - << 1)), - nullptr); + MONGO_COMPILER_VARIABLE_UNUSED auto ignored = + stdx::make_unique<SortKeyGenerator>(BSON("a" << BSON("$meta" + << "textScore" + << "extra" + << 1)), + nullptr); } DEATH_TEST(SortKeyGeneratorTest, SortPatternComponentWithNonMetaObjectSortIsFatal, "Invariant failure metaElem.fieldNameStringData() == \"$meta\"_sd") { - stdx::make_unique<SortKeyGenerator>(BSON("a" << BSON("$unknown" - << "textScore")), - nullptr); + MONGO_COMPILER_VARIABLE_UNUSED auto ignored = + stdx::make_unique<SortKeyGenerator>(BSON("a" << BSON("$unknown" + << "textScore")), + nullptr); } DEATH_TEST(SortKeyGeneratorTest, SortPatternComponentWithUnknownMetaKeywordIsFatal, "Invariant failure metaElem.valueStringData() == \"randVal\"_sd") { - stdx::make_unique<SortKeyGenerator>(BSON("a" << BSON("$meta" - << "unknown")), - nullptr); + MONGO_COMPILER_VARIABLE_UNUSED auto ignored = + stdx::make_unique<SortKeyGenerator>(BSON("a" << BSON("$meta" + << "unknown")), + nullptr); } DEATH_TEST(SortKeyGeneratorTest, diff --git a/src/mongo/db/update/push_node.cpp b/src/mongo/db/update/push_node.cpp index c881c882e93..e214b25b458 100644 --- a/src/mongo/db/update/push_node.cpp +++ b/src/mongo/db/update/push_node.cpp @@ -227,16 +227,22 @@ ModifierNode::ModifyResult PushNode::insertElementsWithPosition( result = ModifyResult::kNormalUpdate; } - // We insert all the rest of the elements after the one we just inserted. - std::accumulate(std::next(valuesToPush.begin()), - valuesToPush.end(), - firstElementToInsert, - [&document](auto& insertAfter, auto& valueToInsert) { - auto nextElementToInsert = - document.makeElementWithNewFieldName(StringData(), valueToInsert); - invariant(insertAfter.addSiblingRight(nextElementToInsert)); - return nextElementToInsert; - }); + // We insert all the rest of the elements after the one we just + // inserted. + // + // TODO: The use of std::accumulate here is maybe questionable + // given that we are ignoring the return value. MSVC flagged this, + // and we worked around by tagging the result as unused. + MONGO_COMPILER_VARIABLE_UNUSED auto ignored = + std::accumulate(std::next(valuesToPush.begin()), + valuesToPush.end(), + firstElementToInsert, + [&document](auto& insertAfter, auto& valueToInsert) { + auto nextElementToInsert = + document.makeElementWithNewFieldName(StringData(), valueToInsert); + invariant(insertAfter.addSiblingRight(nextElementToInsert)); + return nextElementToInsert; + }); return result; } |