Merge bitcoin/bitcoin#36036: build: Bump clang minimum supported version to 19
What changed, and why it matters
This commit raises the minimum supported version of the Clang compiler used to build Bitcoin Core from version 17 to version 19. It also removes some old workarounds that were only needed for older compiler versions. There is no change to how Bitcoin Core processes transactions, network messages, wallets, or consensus rules. It is a routine build-system maintenance change.
No security action required. Builders and CI maintainers should ensure Clang 19 or later (or GCC 12.1 or later) is available for builds targeting this branch.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The merge commit bumps the minimum Clang toolchain requirement to 19.0, updates CI images and package lists to clang-19/llvm-19/libc++-19, removes the clang-17-specific -Wno-c++23-extensions workaround, drops libc++-15/16 workarounds in src/test/fuzz/vecdeque.cpp and src/compat/byteswap.h, switches the CTAD feature check from aggregate CTAD to alias-template CTAD, and sets clang-format Standard to Latest. No runtime security-sensitive code paths are modified.
Changed components
Build system / compiler requirementsCMakeLists.txtcmake/module/CheckCXXFeatures.cmakeCI configuration (.github/workflows/ci.yml, ci/test/00_setup_env_native_nowallet.sh)Documentation (doc/dependencies.md, doc/release-notes-36036.md, depends/README.md)src/.clang-formatsrc/compat/byteswap.hsrc/test/fuzz/vecdeque.cppInspect captured patch +21 / −35
### .github/workflows/ci.yml
@@ -29,7 +29,7 @@ defaults:
jobs:
test-each-commit:
name: 'test ancestor commits'
- runs-on: ${{ github.repository == 'bitcoin/bitcoin' && 'warp-ubuntu-latest-x64-8x' || 'ubuntu-latest' }}
+ runs-on: ${{ github.repository == 'bitcoin/bitcoin' && 'warp-ubuntu-2604-x64-8x' || 'ubuntu-26.04' }}
env:
TEST_RUNNER_PORT_MIN: "14000" # Use a larger port range to avoid colliding with other CI services.
if: github.event_name == 'pull_request' && github.event.pull_request.commits != 1
### CMakeLists.txt
@@ -522,11 +522,6 @@ try_append_cxx_flags("-Wunused-parameter" TARGET warn_interface SKIP_LINK
try_append_cxx_flags("-Wc++23-lambda-attributes" TARGET warn_interface SKIP_LINK
IF_CHECK_PASSED "-Wno-c++23-lambda-attributes"
)
-# Older clang versions (e.g. clang-17) do not recognize -Wc++23-lambda-attributes
-# but emit the same diagnostic under the broader -Wc++23-extensions flag instead.
-try_append_cxx_flags("-Wc++23-extensions" TARGET warn_interface SKIP_LINK
- IF_CHECK_PASSED "-Wno-c++23-extensions"
-)
configure_file(cmake/script/Coverage.cmake Coverage.cmake USE_SOURCE_PERMISSIONS COPYONLY)
configure_file(cmake/script/CoverageFuzz.cmake CoverageFuzz.cmake USE_SOURCE_PERMISSIONS COPYONLY)
### ci/test/00_setup_env_native_nowallet.sh
@@ -7,10 +7,10 @@
export LC_ALL=C.UTF-8
export CI_IMAGE_NAME_TAG="mirror.gcr.io/ubuntu:24.04"
-# Use minimum supported python3.10 (or best-effort 3.12) and clang-17, see doc/dependencies.md
-export PACKAGES="python3-zmq python3-pip clang-17 llvm-17 libc++abi-17-dev libc++-17-dev"
+# Use minimum supported python3.10 (or best-effort 3.12) and clang-19, see doc/dependencies.md
+export PACKAGES="python3-zmq python3-pip clang-19 llvm-19 libc++abi-19-dev libc++-19-dev"
export PIP_PACKAGES="--break-system-packages pycapnp"
-export DEP_OPTS="NO_WALLET=1 CC=clang-17 CXX='clang++-17 -stdlib=libc++'"
+export DEP_OPTS="NO_WALLET=1 CC=clang-19 CXX='clang++-19 -stdlib=libc++'"
printf -v BITCOIN_CONFIG "%q " \
--preset=dev-mode \
-DREDUCE_EXPORTS=ON \
### cmake/module/CheckCXXFeatures.cmake
@@ -13,25 +13,20 @@ function(check_cxx_features)
message(STATUS "Checking for required C++ features")
- # Checks for Class Template Argument Deduction for aggregate types - used in src/util/overloaded.h
+ # Checks for Class Template Argument Deduction for alias templates.
check_cxx_source_compiles("
- #include <variant>
-
- template<class... Ts> struct Overloaded : Ts... { using Ts::operator()...; };
+ template<class T> struct Template { Template(T) {} };
+ template<class T> using Alias = Template<T>;
int main() {
- std::variant<int, double> v = 42;
- return std::visit(Overloaded{
- [](int) { return 0; },
- [](double) { return 1; }
- }, v);
+ Alias value{42};
+ return sizeof(value);
}
- " HAVE_CTAD_FOR_AGGREGATES)
+ " HAVE_CTAD_FOR_ALIAS_TEMPLATES)
- if(NOT HAVE_CTAD_FOR_AGGREGATES)
+ if(NOT HAVE_CTAD_FOR_ALIAS_TEMPLATES)
message(FATAL_ERROR
- "Compiler lacks Class Template Argument Deduction (CTAD) for aggregates.\n"
- "This C++ feature is required for src/util/overloaded.h.\n"
+ "Compiler lacks Class Template Argument Deduction (CTAD) for alias templates.\n"
"You are probably using an old compiler version\n"
"The recommended compiler versions can be checked in\n"
"doc/dependencies.md#compiler.\n"
### depends/README.md
@@ -154,7 +154,7 @@ The paths are automatically configured and no other options are needed.
apt install clang lld llvm zip
-Clang 18 or later is required. You must also obtain the macOS SDK before
+Obtaining the macOS SDK is required before
proceeding with a cross-compile. Under the depends directory, create a
subdirectory named `SDKs`. Then, place the extracted SDK under this new directory.
For more information, see [SDK Extraction](../contrib/macdeploy/README.md#sdk-extraction).
### doc/dependencies.md
@@ -10,7 +10,7 @@ Bitcoin Core requires one of the following compilers.
| Toolchain | Minimum required |
| --- | --- |
-| [Clang](https://clang.llvm.org) | [17.0](https://github.com/bitcoin/bitcoin/pull/33555) |
+| [Clang](https://clang.llvm.org) | [19.0](https://github.com/bitcoin/bitcoin/pull/36036) |
| [GCC](https://gcc.gnu.org) | [12.1](https://github.com/bitcoin/bitcoin/pull/33842) |
| [Xcode CLT](/doc/build-osx.md) | [26.3](https://github.com/bitcoin/bitcoin/pull/36287) |
| [Visual Studio (with clang-cl)](/doc/build-windows-native.md) | [18.7](https://github.com/bitcoin/bitcoin/pull/31507) |
### doc/release-notes-36036.md
@@ -0,0 +1,5 @@
+Build System
+------------
+
+- The minimum supported Clang compiler version has been raised to 19.0
+ (#36036).
### src/.clang-format
@@ -213,7 +213,7 @@ SpacesInLineCommentPrefix:
Maximum: -1
SpacesInParentheses: false
SpacesInSquareBrackets: false
-Standard: c++20
+Standard: Latest
StatementAttributeLikeMacros:
- Q_EMIT
StatementMacros:
### src/compat/byteswap.h
@@ -6,10 +6,6 @@
#define BITCOIN_COMPAT_BYTESWAP_H
#include <cstdint>
-#ifdef _MSC_VER
-#include <cstdlib>
-#endif
-
// All internal_bswap_* functions can be replaced with std::byteswap once we
// require c++23. Both libstdc++ and libc++ implement std::byteswap via these
### src/test/fuzz/vecdeque.cpp
@@ -456,12 +456,7 @@ class TrackedObj
friend std::strong_ordering operator<=>(const TrackedObj& a, const TrackedObj& b)
{
- // Libc++ 15 & 16 do not support std::optional<T>::operator<=> yet. See
- // https://reviews.llvm.org/D146392.
- if (!a.Deref().has_value() || !b.Deref().has_value()) {
- return a.Deref().has_value() <=> b.Deref().has_value();
- }
- return *a.Deref() <=> *b.Deref();
+ return a.Deref() <=> b.Deref();
}
static void CheckNoneExist()Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.