mirror of
https://github.com/dashpay/dash.git
synced 2024-12-23 19:12:47 +01:00
build: enable experimental Cxx20 support (#4600)
* build: Add optional c++20 compilation option * build: update ax_cxx_compile_stdcxx.m4 to be compatible with c++20 * fix: fix c++20 build error for undefined identifier * ci: enable c++20 build during ci * cxx17 -> cxx20 Signed-off-by: pasta <pasta@dashboost.org>
This commit is contained in:
parent
a490615a8b
commit
683be4086e
@ -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:
|
||||
|
@ -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.
|
||||
@ -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], [],
|
||||
@ -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], [[
|
||||
@ -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, "");
|
||||
|
@ -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
|
||||
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
|
||||
|
14
configure.ac
14
configure.ac
@ -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
|
||||
|
@ -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");
|
||||
@ -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)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user