Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,12 @@ linux64-build:
variables:
BUILD_TARGET: linux64

linux64_cxx17-build:
linux64_cxx20-build:
extends: .build-template
needs:
- x86_64-unknown-linux-gnu-debug
variables:
BUILD_TARGET: linux64_cxx17
BUILD_TARGET: linux64_cxx20

linux64_nowallet-build:
extends:
Expand Down
27 changes: 24 additions & 3 deletions build-aux/m4/ax_cxx_compile_stdcxx.m4
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
#
# Check for baseline language coverage in the compiler for the specified
# version of the C++ standard. If necessary, add switches to CXX and
# CXXCPP to enable support. VERSION may be '11' (for the C++11 standard)
# or '14' (for the C++14 standard).
# CXXCPP to enable support. VERSION may be '11' (for the C++11 standard),
# '14' (for the C++14 standard), '17' (for the C++17 standard) or
# '20' (for the C++20 standard)
#
# The second argument, if specified, indicates whether you insist on an
# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
Expand Down Expand Up @@ -46,10 +47,14 @@
dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro
dnl (serial version number 13).

dnl Modifications:
dnl Add support for C++20, with no new tests

AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"],
[$1], [14], [ax_cxx_compile_alternatives="14 1y"],
[$1], [17], [ax_cxx_compile_alternatives="17 1z"],
[$1], [20], [ax_cxx_compile_alternatives="20 2a"],
[m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl
m4_if([$2], [], [],
[$2], [ext], [],
Expand Down Expand Up @@ -154,6 +159,22 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_17
)


dnl Test body for checking C++20 support: R modification
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_20],
#ifndef __cplusplus
#error "This is not a C++ compiler"
dnl value from 2020-01-14 draft, clang 11 has 202002L
#elif __cplusplus < 201703L
#error "This is not a C++20 compiler"
#else
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
_AX_CXX_COMPILE_STDCXX_testbody_new_in_17
#endif
)


dnl Tests for new features in C++11

m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[
Expand Down Expand Up @@ -251,7 +272,7 @@ namespace cxx11
}

int
test(const int c, volatile int v)
test(const int c, volatile int v) // 'volatile is deprecated in C++20'
{
static_assert(is_same<int, decltype(0)>::value == true, "");
static_assert(is_same<int, decltype(c)>::value == false, "");
Expand Down
4 changes: 2 additions & 2 deletions ci/matrix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ elif [ "$BUILD_TARGET" = "linux64" ]; then
export BITCOIN_CONFIG="--enable-zmq --enable-reduce-exports --enable-crash-hooks --with-sanitizers=undefined"
export CPPFLAGS="-DDEBUG_LOCKORDER -DENABLE_DASH_DEBUG -DARENA_DEBUG"
export PYZMQ=true
elif [ "$BUILD_TARGET" = "linux64_cxx17" ]; then
elif [ "$BUILD_TARGET" = "linux64_cxx20" ]; then
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should also tweak .gitlab-ci.yml

export HOST=x86_64-unknown-linux-gnu
export DEP_OPTS="NO_UPNP=1 DEBUG=1"
export BITCOIN_CONFIG="--enable-zmq --enable-reduce-exports --enable-crash-hooks --enable-c++17 --enable-suppress-external-warnings --enable-werror --with-sanitizers=undefined"
export BITCOIN_CONFIG="--enable-zmq --enable-reduce-exports --enable-crash-hooks --enable-c++20 --enable-suppress-external-warnings --enable-werror --with-sanitizers=undefined"
export CPPFLAGS="-DDEBUG_LOCKORDER -DENABLE_DASH_DEBUG -DARENA_DEBUG"
export PYZMQ=true
export RUN_INTEGRATIONTESTS=false
Expand Down
14 changes: 12 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,18 @@ case $host in
;;
esac

dnl Require C++17 compiler (no GNU extensions)
AX_CXX_COMPILE_STDCXX([17], [noext], [mandatory])
AC_ARG_ENABLE([c++20],
[AS_HELP_STRING([--enable-c++20],
[enable compilation in c++20 mode (disabled by default)])],
[use_cxx20=$enableval],
[use_cxx20=no])

dnl Require C++17 or C++20 compiler (no GNU extensions)
if test "x$use_cxx20" = xyes; then
AX_CXX_COMPILE_STDCXX([20], [noext], [mandatory])
else
AX_CXX_COMPILE_STDCXX([17], [noext], [mandatory])
fi

dnl Check if -latomic is required for <std::atomic>
CHECK_ATOMIC
Expand Down
4 changes: 2 additions & 2 deletions src/leveldb/util/env_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ class SingletonEnv {
public:
SingletonEnv() {
#if !defined(NDEBUG)
env_initialized_.store(true, std::memory_order::memory_order_relaxed);
env_initialized_.store(true, std::memory_order_relaxed);
#endif // !defined(NDEBUG)
static_assert(sizeof(env_storage_) >= sizeof(EnvType),
"env_storage_ will not fit the Env");
Expand All @@ -867,7 +867,7 @@ class SingletonEnv {

static void AssertEnvNotInitialized() {
#if !defined(NDEBUG)
assert(!env_initialized_.load(std::memory_order::memory_order_relaxed));
assert(!env_initialized_.load(std::memory_order_relaxed));
#endif // !defined(NDEBUG)
}

Expand Down