SERVER-62997 Start building everything with c++20

This commit is contained in:
Alexander Neben 2023-04-18 17:31:42 +00:00 committed by Evergreen Agent
parent 24c09afa20
commit 0905f3ed79
11 changed files with 20 additions and 415 deletions

View File

@ -593,8 +593,8 @@ add_option(
add_option(
"cxx-std",
choices=["17", "20"],
default="17",
choices=["20"],
default="20",
help="Select the C++ language standard to build with",
)
@ -3860,37 +3860,18 @@ def doConfigure(myenv):
conf.Finish()
if myenv.ToolchainIs('msvc'):
if get_option('cxx-std') == "17":
myenv.AppendUnique(CCFLAGS=['/std:c++17',
'/Zc:lambda']) # /Zc:lambda is implied by /std:c++20
elif get_option('cxx-std') == "20":
if get_option('cxx-std') == "20":
myenv.AppendUnique(CCFLAGS=['/std:c++20'])
else:
if get_option('cxx-std') == "17":
if not myenv.AddToCXXFLAGSIfSupported('-std=c++17'):
myenv.ConfError('Compiler does not honor -std=c++17')
elif get_option('cxx-std') == "20":
if get_option('cxx-std') == "20":
if not myenv.AddToCXXFLAGSIfSupported('-std=c++20'):
myenv.ConfError('Compiler does not honor -std=c++20')
if not myenv.AddToCFLAGSIfSupported('-std=c11'):
myenv.ConfError("C++17 mode selected for C++ files, but can't enable C11 for C files")
myenv.ConfError("C++20 mode selected for C++ files, but can't enable C11 for C files")
if using_system_version_of_cxx_libraries():
print('WARNING: System versions of C++ libraries must be compiled with C++17 support')
def CheckCxx17(context):
test_body = """
#if __cplusplus < 201703L
#error
#endif
namespace NestedNamespaceDecls::AreACXX17Feature {};
"""
context.Message('Checking for C++17... ')
ret = context.TryCompile(textwrap.dedent(test_body), ".cpp")
context.Result(ret)
return ret
print('WARNING: System versions of C++ libraries must be compiled with C++20 support')
def CheckCxx20(context):
test_body = """
@ -3910,15 +3891,12 @@ def doConfigure(myenv):
myenv,
help=False,
custom_tests={
'CheckCxx17': CheckCxx17,
'CheckCxx20': CheckCxx20,
},
)
if get_option('cxx-std') == "17" and not conf.CheckCxx17():
myenv.ConfError('C++17 support is required to build MongoDB')
elif get_option('cxx-std') == "20" and not conf.CheckCxx20():
myenv.ConfError('C++20 support was not detected')
if get_option('cxx-std') == "20" and not conf.CheckCxx20():
myenv.ConfError('C++20 support is required to build MongoDB')
conf.Finish()

View File

@ -7,7 +7,7 @@ way to get started, rather than building from source.
To build MongoDB, you will need:
* A modern C++ compiler capable of compiling C++17. One of the following is required:
* A modern C++ compiler capable of compiling C++20. One of the following is required:
* GCC 11.3 or newer
* Clang 12.0 (or Apple XCode 13.0 Clang) or newer
* Visual Studio 2022 version 17.0 or newer (See Windows section below for details)

View File

@ -390,120 +390,6 @@ buildvariants:
tasks:
- name: tla_plus
- &enterprise-rhel80-dynamic-gcc-debug-experimental-template
name: &enterprise-rhel80-dynamic-gcc-cxx20-debug-experimental enterprise-rhel80-dynamic-gcc-cxx20-debug-experimental
display_name: "~ Shared Library Enterprise RHEL 8.0 Toolchain GCC C++20 DEBUG"
cron: "0 4 * * *" # From the ${project_nightly_cron} parameter.
modules:
- enterprise
run_on:
- rhel80-small
expansions: &enterprise-rhel80-dynamic-gcc-debug-experimental-expansions
additional_package_targets: >-
archive-mongocryptd
archive-mongocryptd-debug
archive-mh
archive-mh-debug
compile_flags: >-
--dbg=on
--opt=on
-j$(grep -c ^processor /proc/cpuinfo)
--link-model=dynamic
--variables-files=etc/scons/mongodbtoolchain_stable_gcc.vars
--variables-files=etc/scons/scons_experimental_scheduler.vars
--cxx-std=20
has_packages: false
scons_cache_scope: shared
scons_cache_mode: all
large_distro_name: rhel80-medium
num_scons_link_jobs_available: 0.99
compile_variant: *enterprise-rhel80-dynamic-gcc-cxx20-debug-experimental
tasks: &enterprise-rhel80-dynamic-gcc-debug-experimental-tasks
- name: compile_test_and_package_parallel_core_stream_TG
distros:
- rhel80-xlarge
- name: compile_test_and_package_parallel_unittest_stream_TG
distros:
- rhel80-xlarge
- name: compile_test_and_package_parallel_dbtest_stream_TG
distros:
- rhel80-xlarge
- name: compile_integration_and_test_parallel_stream_TG
distros:
- rhel80-large
- name: test_api_version_compatibility
- name: .aggfuzzer !.multiversion !.feature_flag_guarded
- name: .aggregation !.multiversion !.feature_flag_guarded
- name: audit
- name: .auth !.multiversion
- name: .causally_consistent !.sharding
- name: .change_streams !.multiversion
- name: .misc_js !.multiversion
- name: .concurrency !.large !.ubsan !.no_txns !.debug_only !.multiversion
- name: .concurrency .large !.ubsan !.no_txns !.debug_only !.multiversion
distros:
- rhel80-xlarge
- name: disk_wiredtiger
- name: .encrypt !.multiversion
- name: idl_tests
- name: jsCore
distros:
- rhel80-xlarge
- name: .jscore .common !jsCore !.multiversion
- name: jsCore_min_batch_repeat_queries_ese_gsm
- name: jsCore_txns_large_txns_format
- name: json_schema
- name: libunwind_tests
- name: mqlrun
- name: .multi_shard !.multiversion
- name: multi_stmt_txn_jscore_passthrough_with_migration_gen
- name: .read_write_concern .large !.multiversion
distros:
- rhel80-xlarge
- name: .read_write_concern !.large !.multiversion
- name: .replica_sets !.encrypt !.auth !.multiversion
distros:
- rhel80-xlarge
- name: replica_sets_api_version_jscore_passthrough_gen
- name: replica_sets_reconfig_jscore_passthrough_gen
- name: retryable_writes_jscore_passthrough_gen
- name: .read_only !.multiversion
- name: sasl
- name: search
- name: search_auth
- name: search_pinned_connections_auth
- name: search_ssl
- name: session_jscore_passthrough
- name: .sharding .jscore !.wo_snapshot !.multi_stmt !.multiversion
- name: sharding_api_version_jscore_passthrough_gen
- name: .sharding .txns !.multiversion
- name: .sharding .common !.multiversion !.jstestfuzz
- name: .stitch
- name: secondary_reads_passthrough_gen
- name: server_discovery_and_monitoring_json_test_TG
- name: .serverless !.multiversion
distros:
- rhel80-xlarge
- name: server_selection_json_test_TG
distros:
- rhel80-xlarge
- name: generate_buildid_to_debug_symbols_mapping
- <<: *enterprise-rhel80-dynamic-gcc-debug-experimental-template
name: &enterprise-rhel80-dynamic-clang-cxx20-debug-experimental enterprise-rhel80-dynamic-clang-cxx20-debug-experimental
display_name: "~ Shared Library Enterprise RHEL 8.0 Toolchain Clang C++20 DEBUG"
expansions:
<<: *enterprise-rhel80-dynamic-gcc-debug-experimental-expansions
compile_flags: >-
--dbg=on
--opt=on
-j$(grep -c ^processor /proc/cpuinfo)
--link-model=dynamic
--variables-files=etc/scons/mongodbtoolchain_stable_clang.vars
--variables-files=etc/scons/scons_experimental_scheduler.vars
--cxx-std=20
compile_variant: *enterprise-rhel80-dynamic-clang-cxx20-debug-experimental
- name: &enterprise-rhel-80-64-bit-coverage enterprise-rhel-80-64-bit-coverage
display_name: "~ Enterprise RHEL 8.0 DEBUG Code Coverage"
modules:
@ -603,141 +489,6 @@ buildvariants:
tasks:
*enterprise-rhel-80-64-bit-coverage-tasks
- <<: *enterprise-rhel80-dynamic-gcc-debug-experimental-template
name: enterprise-rhel80-dynamic-gcc-cxx20-debug-pm-1328-experimental
display_name: "~ Shared Library Enterprise RHEL 8.0 GCC C++20 DEBUG + PM-1328"
cron: "0 4 * * 0" # From the ${project_weekly_cron} parameter
expansions:
<<: *enterprise-rhel80-dynamic-gcc-debug-experimental-expansions
compile_flags: >-
--dbg=on
--opt=on
-j$(grep -c ^processor /proc/cpuinfo)
--link-model=dynamic
--variables-files=etc/scons/mongodbtoolchain_stable_gcc.vars
--cxx-std=20
--experimental-optimization=*
--experimental-runtime-hardening=*
--disable-warnings-as-errors
- <<: *enterprise-rhel80-dynamic-gcc-debug-experimental-template
name: &enterprise-rhel80-dynamic-clang-cxx20-debug-pm-1328-experimental enterprise-rhel80-dynamic-clang-cxx20-debug-pm-1328-experimental
display_name: "~ Shared Library Enterprise RHEL 8.0 Clang C++20 DEBUG + PM-1328"
cron: "0 4 * * 0" # From the ${project_weekly_cron} parameter
expansions:
<<: *enterprise-rhel80-dynamic-gcc-debug-experimental-expansions
compile_flags: >-
--dbg=on
--opt=on
-j$(grep -c ^processor /proc/cpuinfo)
--link-model=dynamic
--variables-files=etc/scons/mongodbtoolchain_stable_clang.vars
--cxx-std=20
--experimental-optimization=*
--experimental-runtime-hardening=*
compile_variant: *enterprise-rhel80-dynamic-clang-cxx20-debug-pm-1328-experimental
- <<: *enterprise-rhel80-dynamic-gcc-debug-experimental-template
name: &enterprise-rhel80-gcc-cxx20-pm-1328-experimental enterprise-rhel80-gcc-cxx20-pm-1328-experimental
display_name: "~ Enterprise RHEL 8.0 Toolchain GCC C++20 + PM-1328"
cron: "0 4 * * 0" # From the ${project_weekly_cron} parameter
expansions:
<<: *enterprise-rhel80-dynamic-gcc-debug-experimental-expansions
compile_flags: >-
--opt=on
-j$(grep -c ^processor /proc/cpuinfo)
--variables-files=etc/scons/mongodbtoolchain_stable_gcc.vars
--cxx-std=20
--experimental-optimization=*
--experimental-runtime-hardening=*
--disable-warnings-as-errors
--link-model=dynamic
compile_variant: *enterprise-rhel80-gcc-cxx20-pm-1328-experimental
tasks: &enterprise-rhel80-dynamic-gcc-debug-experimental-tasks-no-unittests
- name: compile_test_and_package_parallel_core_stream_TG
distros:
- rhel80-xlarge
- name: compile_test_and_package_parallel_dbtest_stream_TG
distros:
- rhel80-xlarge
- name: compile_integration_and_test_parallel_stream_TG
distros:
- rhel80-large
- name: test_api_version_compatibility
- name: .aggfuzzer !.multiversion !.feature_flag_guarded
- name: .aggregation !.multiversion !.feature_flag_guarded
- name: audit
- name: .auth !.multiversion
- name: .causally_consistent !.sharding
- name: .change_streams !.multiversion
- name: .misc_js !.multiversion
- name: .concurrency !.large !.ubsan !.no_txns !.debug_only !.multiversion
- name: .concurrency .large !.ubsan !.no_txns !.debug_only !.multiversion
distros:
- rhel80-xlarge
- name: disk_wiredtiger
- name: .encrypt !.multiversion
- name: idl_tests
- name: jsCore
distros:
- rhel80-xlarge
- name: .jscore .common !jsCore !.multiversion
- name: jsCore_min_batch_repeat_queries_ese_gsm
- name: jsCore_txns_large_txns_format
- name: json_schema
- name: libunwind_tests
- name: mqlrun
- name: .multi_shard !.multiversion
- name: multi_stmt_txn_jscore_passthrough_with_migration_gen
- name: .read_write_concern .large !.multiversion
distros:
- rhel80-xlarge
- name: .read_write_concern !.large !.multiversion
- name: .replica_sets !.encrypt !.auth !.multiversion
distros:
- rhel80-xlarge
- name: replica_sets_api_version_jscore_passthrough_gen
- name: replica_sets_reconfig_jscore_passthrough_gen
- name: retryable_writes_jscore_passthrough_gen
- name: .read_only !.multiversion
- name: sasl
- name: search
- name: search_auth
- name: search_pinned_connections_auth
- name: search_ssl
- name: session_jscore_passthrough
- name: .sharding .jscore !.wo_snapshot !.multi_stmt !.multiversion
- name: sharding_api_version_jscore_passthrough_gen
- name: .sharding .txns !.multiversion
- name: .sharding .common !.multiversion
- name: .stitch
- name: secondary_reads_passthrough_gen
- name: server_discovery_and_monitoring_json_test_TG
- name: .serverless !.multiversion
distros:
- rhel80-xlarge
- name: server_selection_json_test_TG
distros:
- rhel80-xlarge
- name: generate_buildid_to_debug_symbols_mapping
- <<: *enterprise-rhel80-dynamic-gcc-debug-experimental-template
name: &enterprise-rhel80-clang-cxx20-pm-1328-experimental enterprise-rhel80-clang-cxx20-pm-1328-experimental
display_name: "~ Enterprise RHEL 8.0 Toolchain Clang C++20 + PM-1328"
cron: "0 4 * * 0" # From the ${project_weekly_cron} parameter
expansions:
<<: *enterprise-rhel80-dynamic-gcc-debug-experimental-expansions
compile_flags: >-
--opt=on
-j$(grep -c ^processor /proc/cpuinfo)
--variables-files=etc/scons/mongodbtoolchain_stable_clang.vars
--cxx-std=20
--experimental-optimization=*
--experimental-runtime-hardening=*
compile_variant: *enterprise-rhel80-clang-cxx20-pm-1328-experimental
tasks: *enterprise-rhel80-dynamic-gcc-debug-experimental-tasks-no-unittests
- name: &stm-daily-cron stm-daily-cron
modules:
- enterprise
@ -981,74 +732,6 @@ buildvariants:
- name: telemetry_passthrough
- name: unittest_shell_hang_analyzer_gen
- name: &enterprise-windows-cxx20-debug-experimental enterprise-windows-cxx20-debug-experimental
display_name: "~ Enterprise Windows C++20 DEBUG"
cron: "0 4 * * *" # From the ${project_nightly_cron} parameter.
modules:
- enterprise
run_on:
- windows-vsCurrent-small
expansions:
exe: ".exe"
compile_variant: *enterprise-windows-cxx20-debug-experimental
additional_package_targets: >-
archive-mongocryptd
archive-mongocryptd-debug
msi
archive-mh
archive-mh-debug
content_type: application/zip
compile_flags: >-
--dbg=on
--opt=on
--ssl
MONGO_DISTMOD=windows
CPPPATH="c:/sasl/include"
LIBPATH="c:/sasl/lib"
-j$(bc <<< "$(grep -c '^processor' /proc/cpuinfo) / 1.5")
--win-version-min=win10
--cxx-std=20
num_scons_link_jobs_available: 0.25
python: '/cygdrive/c/python/python37/python.exe'
ext: zip
scons_cache_scope: shared
multiversion_platform: windows
multiversion_edition: enterprise
jstestfuzz_num_generated_files: 35
target_resmoke_time: 20
max_sub_suites: 3
large_distro_name: windows-vsCurrent-large
test_flags: *windows_common_test_excludes
exec_timeout_secs: 14400 # 3 hour timeout
tasks:
- name: compile_test_and_package_serial_TG
distros:
- windows-vsCurrent-large
- name: .aggfuzzer !.feature_flag_guarded
- name: .aggregation !.auth !.encrypt !.unwind !.feature_flag_guarded
- name: auth_gen
- name: causally_consistent_jscore_txns_passthrough
- name: .misc_js
# Some concurrency workloads require a lot of memory, so we use machines
# with more RAM for these suites.
- name: .concurrency !.ubsan !.no_txns !.kill_terminate !.common !.debug_only
distros:
- windows-vsCurrent-large
- name: .concurrency .common
- name: disk_wiredtiger
- name: .jscore .common !.auth
- name: json_schema
- name: .query_fuzzer
- name: .read_write_concern
- name: replica_sets_gen
- name: replica_sets_jscore_passthrough_gen
- name: .sharding .jscore !.wo_snapshot !.multi_stmt !.multiversion
- name: .sharding .txns !.multiversion
- name: .sharding .common !.csrs !.multiversion !.gcm
- name: .ssl
- name: .stitch
- name: .updatefuzzer !.multiversion
- name: &enterprise-windows-debug-unoptimized enterprise-windows-debug-unoptimized
display_name: "Enterprise Windows DEBUG (Unoptimized)"
cron: "0 4 * * *" # From the ${project_nightly_cron} parameter.
@ -1166,15 +849,15 @@ buildvariants:
- name: .crypt
- name: generate_buildid_to_debug_symbols_mapping
- name: &enterprise-macos-cxx20 enterprise-macos-cxx20
display_name: "Enterprise macOS C++20 DEBUG"
- name: &enterprise-macos enterprise-macos
display_name: "Enterprise macOS DEBUG"
cron: "0 4 * * *" # From the ${project_nightly_cron} parameter.
modules:
- enterprise
run_on:
- macos-1100
expansions:
compile_variant: *enterprise-macos-cxx20
compile_variant: *enterprise-macos
test_flags: --excludeWithAnyTags=incompatible_with_macos,requires_gcm
compile_env: DEVELOPER_DIR=/Applications/Xcode13.app
compile_flags: >-
@ -1184,7 +867,6 @@ buildvariants:
-j$(sysctl -n hw.logicalcpu)
--libc++
--variables-files=etc/scons/xcode_macosx.vars
--cxx-std=20
resmoke_jobs_max: 6
num_scons_link_jobs_available: 0.99
tasks:

View File

@ -14,7 +14,6 @@ build_variant_large_distro_exceptions:
- enterprise-linux-64-amazon-ami
- enterprise-macos
- enterprise-macos-rosetta-2
- enterprise-macos-cxx20
- enterprise-macos-arm64
- enterprise-rhel-67-s390x
- enterprise-rhel-70-64-bit

View File

@ -248,22 +248,22 @@ bool operator!=(const Status& status, const StatusWith<T>& sw) {
//
template <typename T>
bool operator==(const StatusWith<T>& sw, const ErrorCodes::Error code) {
bool operator==(const StatusWith<T>& sw, ErrorCodes::Error code) {
return sw.getStatus() == code;
}
template <typename T>
bool operator==(const ErrorCodes::Error code, const StatusWith<T>& sw) {
bool operator==(ErrorCodes::Error code, const StatusWith<T>& sw) {
return code == sw.getStatus();
}
template <typename T>
bool operator!=(const StatusWith<T>& sw, const ErrorCodes::Error code) {
bool operator!=(const StatusWith<T>& sw, ErrorCodes::Error code) {
return !(sw == code);
}
template <typename T>
bool operator!=(const ErrorCodes::Error code, const StatusWith<T>& sw) {
bool operator!=(ErrorCodes::Error code, const StatusWith<T>& sw) {
return !(code == sw);
}

View File

@ -29,6 +29,7 @@
#pragma once
#include <s2.h>
#include <s2cap.h>
#include <s2cell.h>
#include <s2loop.h>
@ -37,8 +38,6 @@
#include <s2region.h>
#include <vector>
#include "mongo/db/geo/s2.h"
namespace mongo {
// Simple GeoJSON polygon with a custom CRS identifier as having a strict winding order.

View File

@ -1,45 +0,0 @@
/**
* Copyright (C) 2018-present MongoDB, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the Server Side Public License, version 1,
* as published by MongoDB, Inc.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Server Side Public License for more details.
*
* You should have received a copy of the Server Side Public License
* along with this program. If not, see
* <http://www.mongodb.com/licensing/server-side-public-license>.
*
* As a special exception, the copyright holders give permission to link the
* code of portions of this program with the OpenSSL library under certain
* conditions as described in each individual source file and distribute
* linked combinations including the program with the OpenSSL library. You
* must comply with the Server Side Public License in all respects for
* all of the code used other than as permitted herein. If you modify file(s)
* with this exception, you may extend this exception to your version of the
* file(s), but you are not obligated to do so. If you do not wish to do so,
* delete this exception statement from your version. If you delete this
* exception statement from all source files in the program, then also delete
* it in the license file.
*/
#pragma once
/*
* This file's purpose is to confine the suppression of the Clang warning for
* mismatched-tags (struct vs class) in only the s2.h file
*/
#ifdef __clang__
#pragma GCC diagnostic ignored "-Wmismatched-tags"
#endif
#include <s2.h>
#ifdef __clang__
#pragma GCC diagnostic pop
#endif

View File

@ -30,6 +30,7 @@
#pragma once
#include <cmath>
#include <s2.h>
#include <s2cap.h>
#include <s2cell.h>
#include <s2latlng.h>
@ -40,7 +41,6 @@
#include "mongo/base/clonable_ptr.h"
#include "mongo/db/geo/big_polygon.h"
#include "mongo/db/geo/s2.h"
#include "mongo/db/jsobj.h"
#ifndef M_PI

View File

@ -30,6 +30,7 @@
#include "mongo/db/index/expression_keys_private.h"
#include <s2.h>
#include <s2cell.h>
#include <s2regioncoverer.h>
#include <utility>
@ -43,7 +44,6 @@
#include "mongo/db/geo/geoconstants.h"
#include "mongo/db/geo/geometry_container.h"
#include "mongo/db/geo/geoparser.h"
#include "mongo/db/geo/s2.h"
#include "mongo/db/index/2d_common.h"
#include "mongo/db/index/s2_common.h"
#include "mongo/db/index_names.h"

View File

@ -32,13 +32,13 @@
#include <cmath>
#include <limits>
#include <s2.h>
#include <s2cell.h>
#include <s2regioncoverer.h>
#include "mongo/base/string_data.h"
#include "mongo/bson/bsontypes.h"
#include "mongo/db/geo/geoconstants.h"
#include "mongo/db/geo/s2.h"
#include "mongo/db/index/expression_params.h"
#include "mongo/db/index/s2_common.h"
#include "mongo/db/matcher/expression_geo.h"

View File

@ -199,14 +199,6 @@ inline uint_fast8_t CountTrailingZeroes64(uint64_t aValue) {
#elif defined(__clang__) || defined(__GNUC__)
# if defined(__clang__)
# if !__has_builtin(__builtin_ctz) || !__has_builtin(__builtin_clz)
# error "A clang providing __builtin_c[lt]z is required to build"
# endif
# else
// gcc has had __builtin_clz and friends since 3.4: no need to check.
# endif
inline uint_fast8_t CountLeadingZeroes32(uint32_t aValue) {
return static_cast<uint_fast8_t>(__builtin_clz(aValue));
}