Skip to content

Commit

Permalink
Merge bitcoin#28349: build: Require C++20 compiler
Browse files Browse the repository at this point in the history
fa6e50d fuzz: Use C++20 starts_with in rpc.cpp (MarcoFalke)
faa4838 Revert "tracepoints: Disables `-Wgnu-zero-variadic-macro-arguments` to compile without warnings" (MarcoFalke)
fae3b77 refactor: Drop unused _Pragma to ignore -Wgnu-zero-variadic-macro-arguments (MarcoFalke)
fa02fc0 refactor: modernize-use-default-member-init for bit-fields (C++20) (MarcoFalke)
fa67f09 build: Require C++20 compiler (MarcoFalke)

Pull request description:

  C++20 allows to write safer code, because it allows to enforce more stuff at compile time (`constinit`, `conteval`, `constexpr`, `std::span`, ...).

  Also, it allows to write less verbose and easier to understand code (C++ 20 Concepts).

  See bitcoin#23363 and https://en.cppreference.com/w/cpp/compiler_support#cpp20

  With g++-10 (bitcoin#28348) and clang-13 (bitcoin#28210), there is broad support for almost all features of C++20.

  It should be fine to require a C++20 compiler for Bitcoin Core 27.0 in 2024 (next year), not the soon upcoming 26.0 next month.

  This pull request includes three small cleanups to make use of C++20 features. If any issues are detected before or after merge, this should be easy to revert. If no issues arise, it should be fine to make use of more involved C++20 features later on.

ACKs for top commit:
  fanquake:
    ACK fa6e50d

Tree-SHA512: 244d79bfb0b750a4bdd713f40573b9ca33816fb84b6c84a58f027b9d7d4bb0cc4f18642959e4cf3d094808a69e5b8a327ca8521d7c0c08af27dacb5da3e78e71
  • Loading branch information
fanquake authored and PastaPastaPasta committed Apr 4, 2024
1 parent a224e46 commit 27a386e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion build-aux/m4/ax_cxx_compile_stdcxx.m4
Expand Up @@ -986,7 +986,7 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_20], [[
#error "This is not a C++ compiler"
#elif __cplusplus < 202002L
#elif __cplusplus < 201709L // Temporary patch on top of upstream to allow g++-10
#error "This is not a C++20 compiler"
Expand Down
14 changes: 2 additions & 12 deletions configure.ac
Expand Up @@ -66,18 +66,8 @@ case $host in
;;
esac

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 Require C++20 compiler (no GNU extensions)
AX_CXX_COMPILE_STDCXX([20], [noext], [mandatory])

dnl Check if -latomic is required for <std::atomic>
CHECK_ATOMIC
Expand Down
3 changes: 3 additions & 0 deletions depends/Makefile
Expand Up @@ -43,6 +43,9 @@ NO_NATPMP ?=
MULTIPROCESS ?=
FALLBACK_DOWNLOAD_PATH ?= https://bitcoincore.org/depends-sources

C_STANDARD ?= c11
CXX_STANDARD ?= c++20

BUILD = $(shell ./config.guess)
HOST ?= $(BUILD)
PATCHES_PATH = $(BASEDIR)/patches
Expand Down
2 changes: 2 additions & 0 deletions depends/README.md
Expand Up @@ -99,6 +99,8 @@ The following can be set when running make: `make FOO=bar`
- `BASE_CACHE`: Built packages will be placed here
- `SDK_PATH`: Path where SDKs can be found (used by macOS)
- `FALLBACK_DOWNLOAD_PATH`: If a source file can't be fetched, try here before giving up
- `C_STANDARD`: Set the C standard version used. Defaults to `c11`.
- `CXX_STANDARD`: Set the C++ standard version used. Defaults to `c++20`.
- `NO_QT`: Don't download/build/cache Qt and its dependencies
- `NO_QR`: Don't download/build/cache packages needed for enabling qrencode
- `NO_ZMQ`: Don't download/build/cache packages needed for enabling ZeroMQ
Expand Down
2 changes: 1 addition & 1 deletion depends/packages/qt.mk
Expand Up @@ -39,7 +39,7 @@ $(package)_config_opts_release += -silent
$(package)_config_opts_debug = -debug
$(package)_config_opts_debug += -optimized-tools
$(package)_config_opts += -bindir $(build_prefix)/bin
$(package)_config_opts += -c++std c++17
$(package)_config_opts += -c++std c++2a
$(package)_config_opts += -confirm-license
$(package)_config_opts += -hostprefix $(build_prefix)
$(package)_config_opts += -no-compile-examples
Expand Down

0 comments on commit 27a386e

Please sign in to comment.