build: Add a compiler minimum version check #34580

pull polespinasa wants to merge 5 commits into bitcoin:master from polespinasa:clang_min_version_check changing 2 files +76 −0
  1. polespinasa commented at 11:31 am on February 13, 2026: member

    Adds a compiler minimum version check. If failed, it returns a fatal error. This early stop at configure time will avoid contributors losing time trying to fix compilation errors because of not fitting the requirements.

    Example of the output for GCC: Version requirement satisfied:

    0sliv3r@sliv3r-tuxedo:~/Documentos/Projectes/BitcoinCore/bitcoin$ cmake -B BUILD
    1-- The CXX compiler identification is GNU 13.3.0
    2-- Detecting CXX compiler ABI info
    3-- Detecting CXX compiler ABI info - done
    4....
    

    Version requirement not satisfied:

     0$ cmake -B build -S .   -DCMAKE_C_COMPILER=/usr/bin/gcc-11   -DCMAKE_CXX_COMPILER=/usr/bin/g++-11
     1-- The CXX compiler identification is GNU 11.5.0
     2-- Detecting CXX compiler ABI info
     3-- Detecting CXX compiler ABI info - done
     4-- Check for working CXX compiler: /usr/bin/g++-11 - skipped
     5-- Detecting CXX compile features
     6-- Detecting CXX compile features - done
     7CMake Error at CMakeLists.txt:91 (message):
     8  GCC >= 12.1 required.
     9
    10
    11-- Configuring incomplete, errors occurred!
    

    Example of the output for Clang: Version requirement satisfied:

    0sliv3r@sliv3r-tuxedo:~/Documentos/Projectes/BitcoinCore/bitcoin$ cmake -B build
    1-- The CXX compiler identification is Clang 18.1.3
    2-- Detecting CXX compiler ABI info
    3-- Detecting CXX compiler ABI info - done
    4...
    

    Version requirement not satisfied:

     0$ cmake -B build -DCMAKE_C_COMPILER=clang-16       -DCMAKE_CXX_COMPILER=clang++-16
     1-- The CXX compiler identification is Clang 16.0.6
     2-- Detecting CXX compiler ABI info
     3-- Detecting CXX compiler ABI info - done
     4-- Check for working CXX compiler: /usr/bin/clang++-16 - skipped
     5-- Detecting CXX compile features
     6-- Detecting CXX compile features - done
     7CMake Error at CMakeLists.txt:86 (message):
     8  Clang >= 17.0 required.
     9
    10
    11-- Configuring incomplete, errors occurred!
    
  2. DrahtBot added the label Build system on Feb 13, 2026
  3. DrahtBot commented at 11:31 am on February 13, 2026: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    Stale ACK w0xlt, vasild

    If your review is incorrectly listed, please copy-paste <!–meta-tag:bot-skip–> into the comment that the bot should ignore.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #33974 (cmake: Check dependencies after build option interaction by hebasto)
    • #32367 (cmake: Check user-defined APPEND_*FLAGS variables early by hebasto)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  4. polespinasa force-pushed on Feb 13, 2026
  5. DrahtBot added the label CI failed on Feb 13, 2026
  6. polespinasa commented at 11:35 am on February 13, 2026: member

    Friendly ping @vasild @fanquake I assume you are interested because of our IRC conversation.

    Note: the MSVC check was not tested, I don’t have rn an available environment to test it.

  7. polespinasa force-pushed on Feb 13, 2026
  8. polespinasa force-pushed on Feb 13, 2026
  9. w0xlt commented at 2:49 am on February 14, 2026: contributor
    Concept ACK
  10. fanquake marked this as a draft on Feb 16, 2026
  11. fanquake commented at 11:03 am on February 16, 2026: member

    https://github.com/bitcoin/bitcoin/actions/runs/21985815150/job/63519602237?pr=34580#step:9:434:

     0+ eval 'CMAKE_ARGS=(-DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DBUILD_BENCH=ON -DBUILD_FUZZ_BINARY=ON -DCMAKE_INSTALL_PREFIX=/Users/runner/work/bitcoin/bitcoin/repo_archive/ci/scratch/out -Werror=dev   --preset=dev-mode   -DWITH_USDT=OFF   -DREDUCE_EXPORTS=ON   -DCMAKE_EXE_LINKER_FLAGS='\''-Wl,-stack_size -Wl,0x80000'\'' )'
     1++ CMAKE_ARGS=(-DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DBUILD_BENCH=ON -DBUILD_FUZZ_BINARY=ON -DCMAKE_INSTALL_PREFIX=/Users/runner/work/bitcoin/bitcoin/repo_archive/ci/scratch/out -Werror=dev --preset=dev-mode -DWITH_USDT=OFF -DREDUCE_EXPORTS=ON -DCMAKE_EXE_LINKER_FLAGS='-Wl,-stack_size -Wl,0x80000')
     2+ cmake -S /Users/runner/work/bitcoin/bitcoin/repo_archive -B /Users/runner/work/bitcoin/bitcoin/repo_archive/ci/scratch/build-aarch64-apple-darwin24.6.0 -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DBUILD_BENCH=ON -DBUILD_FUZZ_BINARY=ON -DCMAKE_INSTALL_PREFIX=/Users/runner/work/bitcoin/bitcoin/repo_archive/ci/scratch/out -Werror=dev --preset=dev-mode -DWITH_USDT=OFF -DREDUCE_EXPORTS=ON '-DCMAKE_EXE_LINKER_FLAGS=-Wl,-stack_size -Wl,0x80000'
     3-- The CXX compiler identification is AppleClang 16.0.0.16000026
     4-- Detecting CXX compiler ABI info
     5-- Detecting CXX compiler ABI info - done
     6-- Check for working CXX compiler: /usr/bin/c++ - skipped
     7-- Detecting CXX compile features
     8-- Detecting CXX compile features - done
     9CMake Error at CMakeLists.txt:86 (message):
    10  Clang >= 17.0 required.
    11-- Configuring incomplete, errors occurred!
    
  12. in CMakeLists.txt:86 in a902bd955c outdated
    81+  # VS 18.x uses 19.50-19.59 as MSVC version values
    82+  # https://cmake.org/cmake/help/latest/variable/MSVC_VERSION.html
    83+
    84+if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
    85+  if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS MIN_CLANG_VERSION)
    86+    message(FATAL_ERROR "Clang >= ${MIN_CLANG_VERSION} required.")
    


    vasild commented at 12:14 pm on February 16, 2026:
    Would be useful to print also the detected compiler version. E.g. if it is detected wrong or the user thinks they have clang 17, it is not the best experience to get a message like “minimum is 17”.

    fanquake commented at 12:25 pm on February 16, 2026:
    The detected compiler version is already printed by CMake

    polespinasa commented at 5:08 pm on February 18, 2026:
    The compiler version is printed by CMake in the first line of the output, and the error appears in line ~6. I don’t think there’s a need to repeat the version number.
  13. in CMakeLists.txt:83 in a902bd955c outdated
    74@@ -75,6 +75,30 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_HOST_APPLE)
    75   set(CMAKE_PLATFORM_HAS_INSTALLNAME FALSE)
    76 endif()
    77 enable_language(CXX)
    78+set(MIN_CLANG_VERSION 17.0)
    79+set(MIN_GCC_VERSION 12.1)
    80+set(MIN_MSVC_VERSION 19.50)
    81+  # VS 18.x uses 19.50-19.59 as MSVC version values
    82+  # https://cmake.org/cmake/help/latest/variable/MSVC_VERSION.html
    83+
    


    vasild commented at 12:18 pm on February 16, 2026:
    It is common to put the comments before the code they are relating to. I.e. move those two comment lines before the MSVC version set and remove the leading spaces.

    polespinasa commented at 5:05 pm on February 18, 2026:
    Done
  14. in CMakeLists.txt:92 in a902bd955c outdated
    87+  endif()
    88+endif()
    89+
    90+if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
    91+  if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS MIN_GCC_VERSION)
    92+    message(FATAL_ERROR "GCC >= ${MIN_GCC_VERSION} required.")
    


    vasild commented at 12:19 pm on February 16, 2026:
    It would be useful to also print the detected compiler version, even though it is printed somewhere earlier.

    fanquake commented at 12:25 pm on February 16, 2026:
    The detected compiler version is already printed by CMake.

    polespinasa commented at 5:06 pm on February 18, 2026:
    Resolving this, keeping conversation in #34580 (review)
  15. vasild commented at 12:22 pm on February 16, 2026: contributor

    Approach ACK a902bd955c

    I guess the AppleClang needs some exception. What is the deal with it? We support minimum Clang 17 and minimum AppleClang 16? Or is it that the CI uses unsupported compiler (appleclang 16)?

  16. hebasto commented at 12:30 pm on February 16, 2026: member

    Approach ACK a902bd9

    I guess the AppleClang needs some exception. What is the deal with it? We support minimum Clang 17 and minimum AppleClang 16? Or is it that the CI uses unsupported compiler (appleclang 16)?

    AppleClang 16.0.0.16000026 is based on LLVM 17.0.6, which is OK. That’s another reason to test compiler features, not versions.

  17. fanquake commented at 12:34 pm on February 16, 2026: member

    That’s another reason to test compiler fetaures, not versions.

    Yea. This was my initial feedback (in IRC) as well.

  18. sedited commented at 12:37 pm on February 16, 2026: contributor
    I’m tending to Concept~0 here. We should be checking features, not version strings that might have exceptions, or be brittle to match against. This might also make it more difficult to test with weird compiler/standard library pairings.
  19. maflcko commented at 12:41 pm on February 16, 2026: member
    If you want to extract the clang feature check, it is currently in src/util/overloaded.h. See commit faed118fb30fbc303e9d4c70569abfee397f1759
  20. maflcko commented at 12:45 pm on February 16, 2026: member
    For GCC, I think it is some ranges/view stuff in the kernel tests. The gcc-12 fix from fa3854e43295f71f5dad8557dd621f0f799b0ee0 was actually backported to gcc-11, so in theory one could use gcc11.3 just fine, if disabling the kernel tests.
  21. vasild commented at 12:57 pm on February 16, 2026: contributor

    I agree that it is more robust to check for features instead of compiler versions. However, then doc/dependencies.md would be at odds with the code - it mentions clang 17 and the code checks for std::xyz availability. Getting them in line would mean rewording doc/dependencies.md to say something like “you need a compiler which supports feature1, feature2 and feature3” - that would not be very useful.

    Further, if we check for features, e.g. std::xyz availability and the check fails, then what would be the error message? “find a compiler that supports std::xyz”, hmm?

    Maybe use a wording like “Need a compiler with support for feature1, feature2, etc, like clang 17 or gcc 12.1” in both doc/dependencies.md and in the error messages?

  22. maflcko commented at 2:20 pm on February 16, 2026: member

    I think doc/dependencies.md is just the scope for what is tested in CI in this repo and for what users are encouraged to report bugs against. Similar to https://github.com/bitcoin/bitcoin/blob/35e6444fdc4068adc79082648f9889ad593e623b/doc/release-notes-empty-template.md#L35-L43

    Of course, anyone is free to use whatever compiler/OS they want (at their own risk).

    It should be trivial to replace requires with is supported and tested with in doc/dependencies.md.

    Further, if we check for features, e.g. std::xyz availability and the check fails, then what would be the error message? “find a compiler that supports std::xyz”, hmm?

    Why not? Maybe the error message can be improved to say “Your current compiler with the current version failed to compile foobar. You may try the next major version of this compiler, or a different supported and tested compiler, according to doc/dependencies.md”

    Maybe use a wording like “Need a compiler with support for feature1, feature2, etc, like clang 17 or gcc 12.1” in both doc/dependencies.md and in the error messages?

    Seems fine as well, but I don’t think there is a need to keep the build system features check in sync with dependencies.md. I think it is enough to have the features check in the build system only.

  23. vasild commented at 4:05 pm on February 16, 2026: contributor
    So, check for features and print a message like “your compiler does not support xyz, Bitcoin Core has been tested to compile with clang >=17 …”?
  24. polespinasa force-pushed on Feb 17, 2026
  25. polespinasa marked this as ready for review on Feb 17, 2026
  26. polespinasa commented at 12:39 pm on February 17, 2026: member

    Just opened as ready to review to make the CI run and see if the change avoid crashing for Apple. Will check the check features approach.

     0
     1$ git diff a902bd955cba72c618269b0481fe6f9d5e23801e..62559d00bdbfa3dd38016d7e7a13df83bba54f0d
     2diff --git a/CMakeLists.txt b/CMakeLists.txt
     3index 5636f641a0..00676a2ed2 100644
     4--- a/CMakeLists.txt
     5+++ b/CMakeLists.txt
     6@@ -81,7 +81,7 @@ set(MIN_MSVC_VERSION 19.50)
     7   # VS 18.x uses 19.50-19.59 as MSVC version values
     8   # https://cmake.org/cmake/help/latest/variable/MSVC_VERSION.html
     9 
    10-if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
    11+if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
    12   if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS MIN_CLANG_VERSION)
    13     message(FATAL_ERROR "Clang >= ${MIN_CLANG_VERSION} required.")
    14   endif()
    
  27. DrahtBot removed the label CI failed on Feb 17, 2026
  28. build: Add minimum versions for CLANG, GCC and MSVC
    This minimum version is used in future commits to check for minimum compiler versions
    and to be verbose when aborting building with a compiler missing some needed features.
    67dc89e3c1
  29. polespinasa force-pushed on Feb 18, 2026
  30. polespinasa commented at 4:58 pm on February 18, 2026: member

    I’ve been researching a bit on how to do the features check and I think is not as trivial as I initially thought.

    Disclaimer: It’s the first time I actually play with CMake files so I don’t actually know at all how it works. I’ve used AI to help me generating the features check CMake file.

    From the different options I’ve seen and tried this approach is the only one that actually worked.

    To summarize the solution, cmake will try to compile a piece of code that uses the feature we need. If compilation fails, it returns an error marking the missing feature.

    I don’t know if there’s another cleaner way to check these features. If there is not, I am not sure at all that checking features is a good option, maybe the work to maintaing this extra code and updating it it is not worth at all and just checking compiler versions should be good enough.

    At the end the version check that this PR proposes is not restrictive on which compiler to use. It just forces the users, in case they use one of the three “main” compilers that we recommend, to use at least the older known supported version, but it will not fail if a user tries to use a different compiler. The check will just not apply.

    Updating that version number should be easy and not much extra work to do in a PR like #33555 and probably is not something that will happen regularly.

    Personally if the work to maintain the feature check is considered to be ok and not a big deal I think keeping both approaches, version check (for easy verbose) + feature check (for other compilers) is not a bad idea.

    The last commit (760b8c2219) adds a feature check following what we have in src/util/overloaded.h. So using a compiler that does not implement a feature would return something like:

     0$ cmake -B build -DCMAKE_C_COMPILER=clang-16       -DCMAKE_CXX_COMPILER=clang++-16
     1-- The CXX compiler identification is Clang 16.0.6
     2-- Detecting CXX compiler ABI info
     3-- Detecting CXX compiler ABI info - done
     4-- Check for working CXX compiler: /usr/bin/clang++-16 - skipped
     5-- Detecting CXX compile features
     6-- Detecting CXX compile features - done
     7-- Checking for required C++20 features...
     8CMake Error at cmake/module/CheckCXX20Features.cmake:35 (message):
     9  Compiler lacks Class Template Argument Deduction (CTAD) for aggregates.
    10
    11  This C++20 feature is required for src/util/overloaded.h.
    12
    13  Recomended compiler versions:
    14
    15    - GCC >= 12.1
    16    - Clang >= 17.0
    17    - MSVC >= 19.50
    18Call Stack (most recent call first):
    19  CMakeLists.txt:97 (check_cxx20_features)
    20
    21
    22-- Configuring incomplete, errors occurred!
    

    Note: This output appears like this because I dropped the three version check commits before compiling, if the whole PR is tested it will first exit because of the Clang version check. To reach this state without dropping commits, a compiler different from GCC, Clang or MSVC that does not implement CTAD should be used.

    Other approaches that I tested and don’t work are using target_compile_features.

    To clarify the personal motivation for this PR again; this was open after me having an error when building and not understanding why (see IRC logs). As a user not really familiar with compilers and CMake, the output being something like clang min version is 17 and you are using 16 would have avoided me loosing time checking why the code was not compiling and would have avoid me bothering on IRC. Also that message would have been more helpful and straightforward than something like: your compiler doesn't implement xyz. At that moment I don’t really care about the features, I just need the code to compile so the version check tells me update the compiler and I will work which is exactly what I needed at that moment.

    Again I am not really familiar with CMake and maybe I am missing some cleaner way to do this feature check, help, and approach ideas are more than welcome :)

  31. polespinasa force-pushed on Feb 18, 2026
  32. DrahtBot added the label CI failed on Feb 18, 2026
  33. polespinasa commented at 5:11 pm on February 18, 2026: member

    This might also make it more difficult to test with weird compiler/standard library pairings.

    This doesn’t force users to use a specific compiler, only forces to, if you used Clang, GCC or MSVC, use at least the older required version. But users can still use weird compilers and this checks will be skipped.

  34. polespinasa force-pushed on Feb 18, 2026
  35. polespinasa commented at 5:27 pm on February 18, 2026: member

    Force pushed to solve a linter issue and to change the status message from cmake to make it consistent with how other messages look like.

    https://github.com/bitcoin/bitcoin/compare/45155845be755d6430e5fcb24f492e15dbca2e32..760b8c2219c0d3f832c890f18603d72c6b886a6b

  36. DrahtBot removed the label CI failed on Feb 18, 2026
  37. in CMakeLists.txt:98 in 760b8c2219 outdated
    93+  endif()
    94+endif()
    95+
    96+if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
    97+  if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS MIN_MSVC_VERSION)
    98+    message(FATAL_ERROR "MSVC >= ${MIN_MSVC_VERSION} required.")
    


    maflcko commented at 8:46 pm on February 18, 2026:
    This is still checking the version, not a feature

    polespinasa commented at 8:51 pm on February 18, 2026:

    Yes, the version check still here, I did not remove it.

    Last commit is the only different thing (feature check) since the first approach. I explained in #34580 (comment) the status of the PR.


    maflcko commented at 6:51 am on February 19, 2026:

    nack on having a hard version check, as already explained this has many issues:

    • Providing a patched gcc 11 will fail the version check for no reason
    • Providing a Apple clang will fail the clang version check, because they are on different versioning schemes
    • Alternatively, the version check is skipped for Apple clang and will thus be incomplete anyway
    • We don’t want to enumerate all possible compiler “user agents”, just recall the browser user agent hell

    I don’t see what value this provides over simply checking a feature

  38. in CMakeLists.txt:114 in 760b8c2219
    109+# C++20 Feature Detection
    110+#=============================
    111+# In case the compiler is not GCC, Clang or MSVC this provides extra checks
    112+# that verifies that some feaatures are available in the standard library.
    113+include(CheckCXX20Features)
    114+check_cxx20_features()
    


    vasild commented at 9:02 am on February 19, 2026:
    CXX20 might be too narrowing. In the future we may append e.g. c++23 features to it. I guess check_cxx_features() is good enough.

    polespinasa commented at 3:49 pm on February 23, 2026:
    done
  39. in CMakeLists.txt:112 in 760b8c2219
    107+
    108+#=============================
    109+# C++20 Feature Detection
    110+#=============================
    111+# In case the compiler is not GCC, Clang or MSVC this provides extra checks
    112+# that verifies that some feaatures are available in the standard library.
    


    vasild commented at 9:02 am on February 19, 2026:
    0# that verifies that some features are available in the standard library.
    

    polespinasa commented at 3:49 pm on February 23, 2026:
    done thanks
  40. in cmake/module/CheckCXXFeatures.cmake:11 in 760b8c2219 outdated
     6+
     7+include(CheckCXXSourceCompiles)
     8+
     9+function(check_cxx20_features)
    10+  set(CMAKE_REQUIRED_STANDARD 20)
    11+  set(CMAKE_REQUIRED_STANDARD_REQUIRED ON)
    


    vasild commented at 9:06 am on February 19, 2026:

    I cannot find docs for CMAKE_REQUIRED_STANDARD and CMAKE_REQUIRED_STANDARD_REQUIRED, such variables do not exist?

    There is already this in top-level CMakeLists.txt:

    https://github.com/bitcoin/bitcoin/blob/4933d1fbbada035c42f15006f8373a45f3c51753/CMakeLists.txt#L78-L79

    Maybe drop lines 10,11 here?


    polespinasa commented at 4:04 pm on February 23, 2026:
    you are right, thanks
  41. in CMakeLists.txt:79 in 760b8c2219 outdated
    74@@ -75,11 +75,44 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_HOST_APPLE)
    75   set(CMAKE_PLATFORM_HAS_INSTALLNAME FALSE)
    76 endif()
    77 enable_language(CXX)
    78+set(MIN_CLANG_VERSION 17.0)
    79+set(MIN_GCC_VERSION 12.1)
    


    vasild commented at 9:30 am on February 19, 2026:

    FWIW here is a list of compilers and their versions that support “class template argument deduction for aggregates”:

    https://en.cppreference.com/w/cpp/compiler_support/20.html#cpp_deduction_guides_201907L


    polespinasa commented at 3:49 pm on February 23, 2026:
    red means unsupported? Apple clang does support this in theory…
  42. in cmake/module/CheckCXXFeatures.cmake:29 in 760b8c2219 outdated
    24+      return std::visit(Overloaded{
    25+        [](int) { return 0; },
    26+        [](double) { return 1; }
    27+      }, v);
    28+    }
    29+  " HAVE_CTAD_FOR_AGGREGATES)
    


    vasild commented at 9:48 am on February 19, 2026:

    In theory, according to https://en.cppreference.com/w/cpp/experimental/feature_test.html#cpp_deduction_guides it should be possible to replace this with:

    0#if !(defined(__cpp_deduction_guides) && __cpp_deduction_guides >= 201907L)
    1#error no support whatever
    2#endif
    

    however in practice my clang 19 and 22 have __cpp_deduction_guides equal to 201703 but they do compile our code just fine, hmm?


    hebasto commented at 5:01 pm on February 23, 2026:
    Should we add a comment to remind our future selves to keep this check as is?

    polespinasa commented at 6:46 pm on February 23, 2026:

    however in practice my clang 19 and 22 have __cpp_deduction_guides equal to 201703 but they do compile our code just fine, hmm?

    My clang 16, 18. 19 and 20 all show __cpp_deduction_guides equal to 201703. GCC 13.3 has __cpp_deduction_guides equal to 201907.

    In https://clang.llvm.org/cxx_status it says:

    Maybe this is not a good metric to check the features.

  43. vasild commented at 9:52 am on February 19, 2026: contributor

    this was open after me having an error when building and not understanding why (see IRC logs). As a user not really familiar with compilers and CMake, the output being something like clang min version is 17 and you are using 16 would have avoided me loosing time checking why the code was not compiling and would have avoid me bothering on IRC. Also that message would have been more helpful and straightforward than something like: your compiler doesn’t implement xyz. At that moment I don’t really care about the features, I just need the code to compile so the version check tells me update the compiler and I will work which is exactly what I needed at that moment.

    Exactly!

    I am fine either way (compiler version check vs feature check) as long as the above is resolved.

  44. polespinasa force-pushed on Feb 23, 2026
  45. polespinasa force-pushed on Feb 23, 2026
  46. DrahtBot added the label CI failed on Feb 23, 2026
  47. DrahtBot removed the label CI failed on Feb 24, 2026
  48. vasild approved
  49. vasild commented at 2:21 pm on February 24, 2026: contributor

    ACK 803bd92feec47f2b32db18bb81592ab32924d547

    I guess you can reorder the commits from:

    0build: Add CTAD feature check
    1build: Add MSVC minimum version check
    2build: Add GCC minimum version check
    3build: Add Clang minimum version check
    4build: Add minimum versions for CLANG, GCC and MSVC
    

    to

    0build: Add MSVC minimum version check
    1build: Add GCC minimum version check
    2build: Add Clang minimum version check
    3build: Add CTAD feature check
    4build: Add minimum versions for CLANG, GCC and MSVC
    

    So that people who frown against compiler version checks can ACK the second commit id. If you get enough ACKs like that, then you just drop the last 3 commits, leaving the ACKed commits 1 and 2 unchanged.

  50. polespinasa force-pushed on Feb 24, 2026
  51. DrahtBot added the label CI failed on Feb 24, 2026
  52. w0xlt commented at 6:57 pm on February 24, 2026: contributor

    Maybe it is better to place the check_cxx_features() after the APPEND_CPPFLAGS/APPEND_CXXFLAGS/APPEND_LDFLAGS are applied.

    A user passing for example, -stdlib=libc++ (and corresponding link flags) or a custom sysroot passed via APPEND_* flags could get a false negative — the feature check fails, but the real build would have succeeded.

     0diff --git a/CMakeLists.txt b/CMakeLists.txt
     1index 287771b3ea..25f2a9fd2a 100644
     2--- a/CMakeLists.txt
     3+++ b/CMakeLists.txt
     4@@ -105,14 +105,6 @@ set(CMAKE_CXX_EXTENSIONS OFF)
     5 
     6 list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/module)
     7 
     8-#=============================
     9-# C++ Feature Detection
    10-#=============================
    11-# In case the compiler is not GCC, Clang or MSVC this provides extra checks
    12-# that verifies that some features are available in the standard library.
    13-include(CheckCXXFeatures)
    14-check_cxx_features()
    15-
    16 include(ProcessConfigurations)
    17 
    18 # Flatten static lib dependencies.
    19@@ -218,6 +210,15 @@ string(APPEND CMAKE_CXX_COMPILE_OBJECT " ${APPEND_CPPFLAGS} ${APPEND_CXXFLAGS}")
    20 string(APPEND CMAKE_CXX_CREATE_SHARED_LIBRARY " ${APPEND_LDFLAGS}")
    21 string(APPEND CMAKE_CXX_LINK_EXECUTABLE " ${APPEND_LDFLAGS}")
    22 
    23+#=============================
    24+# C++ Feature Detection
    25+#=============================
    26+# In case the compiler is not GCC, Clang or MSVC this provides extra checks
    27+# that verifies that some features are available in the standard library.
    28+# Run after APPEND_* flags are added so try-compiles use the effective toolchain.
    29+include(CheckCXXFeatures)
    30+check_cxx_features()
    31+
    32 set(configure_warnings)
    33 
    34 include(CheckLinkerSupportsPIE)
    
  53. polespinasa force-pushed on Feb 27, 2026
  54. polespinasa commented at 5:39 pm on February 27, 2026: member

    Thanks @w0xlt, nice catch. Force pushed to move where the check is called in order to take into account flags.

    https://github.com/bitcoin/bitcoin/compare/ef122591b03afaacbc3f503c4e7ff7a8b74f45d4..1ccc0750e34e37675e2dc3d019cab2d417bd6bb8

  55. DrahtBot removed the label CI failed on Feb 27, 2026
  56. in cmake/module/CheckCXXFeatures.cmake:5 in 1ccc0750e3 outdated
    0@@ -0,0 +1,42 @@
    1+# Copyright (c) 2026-present The Bitcoin Core developers
    2+# Distributed under the MIT software license, see the accompanying
    3+# file COPYING or https://opensource.org/license/mit/.
    4+
    5+#Checks for C++ features required to compile Bitcoin Core.
    


    w0xlt commented at 5:04 am on February 28, 2026:

    Matches the convention in every other cmake module (CheckSourceCompilesWithFlags.cmake, ProcessConfigurations.cmake, TryAppendCXXFlags.cmake, etc.).

    0include_guard(GLOBAL)
    1
    2# Checks for C++ features required to compile Bitcoin Core.
    

    polespinasa commented at 12:56 pm on March 3, 2026:
    Done
  57. in CMakeLists.txt:78 in 1ccc0750e3 outdated
    74@@ -75,6 +75,30 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_HOST_APPLE)
    75   set(CMAKE_PLATFORM_HAS_INSTALLNAME FALSE)
    76 endif()
    77 enable_language(CXX)
    78+set(MIN_CLANG_VERSION 17.0)
    


    w0xlt commented at 5:08 am on February 28, 2026:
    0set(MIN_CLANG_VERSION 17.0)
    1set(MIN_APPLE_CLANG_VERSION 16.0)
    

    AppleClang uses a different versioning scheme from upstream Clang (see https://en.wikipedia.org/wiki/Xcode#Toolchain_versions). But I couldn’t find the specific version mapping (the suggested number above is from the Wiki page, but I am not sure).

    If that’s the case the code below is also necessary:

    0   if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS MIN_CLANG_VERSION)
    1     message(FATAL_ERROR "Clang >= ${MIN_CLANG_VERSION} required.")
    2   endif()
    3+  elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
    4+   if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS MIN_APPLE_CLANG_VERSION)
    5+     message(FATAL_ERROR "AppleClang >= ${MIN_APPLE_CLANG_VERSION} required.")
    6+  endif()
    7 endif()
    

    polespinasa commented at 12:52 pm on March 3, 2026:
    I think I will not add it for now because I cannot test it and I guess that I will be dropping the version check due to lack of support.
  58. in cmake/module/CheckCXXFeatures.cmake:33 in 1ccc0750e3
    28+
    29+  if(NOT HAVE_CTAD_FOR_AGGREGATES)
    30+    message(FATAL_ERROR
    31+      "Compiler lacks Class Template Argument Deduction (CTAD) for aggregates.\n"
    32+      "This C++ feature is required for src/util/overloaded.h.\n"
    33+      "Recomended compiler versions:\n"
    


    vasild commented at 11:07 am on March 3, 2026:
    0      "Recommended compiler versions:\n"
    

    polespinasa commented at 12:58 pm on March 3, 2026:
    Done
  59. vasild approved
  60. vasild commented at 11:12 am on March 3, 2026: contributor

    ACK 1ccc0750e34e37675e2dc3d019cab2d417bd6bb8 (full PR) ACK 91e64c95116d4d1ca3f7176a9d83dcc339c4481b (just first two commits)

    Would be nice to get some feedback from @hebasto, @fanquake, @sedited and @maflcko - are the first two commits what you liked to see (checking for features, instead of compiler version numbers)?

  61. DrahtBot requested review from w0xlt on Mar 3, 2026
  62. maflcko commented at 11:32 am on March 3, 2026: member

    ACK 1ccc075 (full PR) ACK 91e64c9 (just first two commits)

    Would be nice to get some feedback from @hebasto, @fanquake, @sedited and @maflcko - are the first two commits what you liked to see (checking for features, instead of compiler version numbers)?

    I’ve already provided my feedback in #34580 (review), but I haven’t seen a reply so far, so I am not sure what else I can do here?

  63. polespinasa commented at 12:51 pm on March 3, 2026: member

    I’ve already provided my feedback in #34580 (comment), but I haven’t seen a reply so far, so I am not sure what else I can do here? @maflcko in order to address the feedback features check was implemented too. The order of the commits was also changed to make it easy to only review the features check.

    Feel free to only review the first two commits and NACK or ignore the last three. If there’s consensus among the reviewers, I will be happy to drop the last commits (version check).

  64. build: Add CTAD feature check eca0c31c13
  65. build: Add Clang minimum version check f7a3b0b900
  66. build: Add GCC minimum version check febcb15de1
  67. build: Add MSVC minimum version check 2bff5f1a3e
  68. polespinasa force-pushed on Mar 3, 2026
  69. polespinasa commented at 12:59 pm on March 3, 2026: member

    Force pushed to fix two small comments:

     0$ git diff 91e64c95116d4d1ca3f7176a9d83dcc339c4481b..eca0c31c130c3deb68acd98325580052950981b5
     1diff --git a/cmake/module/CheckCXXFeatures.cmake b/cmake/module/CheckCXXFeatures.cmake
     2index c1f91d79d8..9ebb769104 100644
     3--- a/cmake/module/CheckCXXFeatures.cmake
     4+++ b/cmake/module/CheckCXXFeatures.cmake
     5@@ -2,6 +2,8 @@
     6 # Distributed under the MIT software license, see the accompanying
     7 # file COPYING or https://opensource.org/license/mit/.
     8 
     9+include_guard(GLOBAL)
    10+
    11 #Checks for C++ features required to compile Bitcoin Core.
    12 
    13 include(CheckCXXSourceCompiles)
    14@@ -30,7 +32,7 @@ function(check_cxx_features)
    15     message(FATAL_ERROR
    16       "Compiler lacks Class Template Argument Deduction (CTAD) for aggregates.\n"
    17       "This C++ feature is required for src/util/overloaded.h.\n"
    18-      "Recomended compiler versions:\n"
    19+      "Recommended compiler versions:\n"
    20       "  - GCC >= ${MIN_GCC_VERSION}\n"
    21       "  - Clang >= ${MIN_CLANG_VERSION}\n"
    22       "  - MSVC >= ${MIN_MSVC_VERSION}"
    
  70. w0xlt commented at 4:03 pm on March 3, 2026: contributor

    ACK eca0c31c130c3deb68acd98325580052950981b5 (just first two commits) ACK 2bff5f1a3ead6f361c39cb27af773d44cf5b3762 (full PR)

    I suggest splitting the PR in two parts so the first two commits can be merged first and the last three can be discussed separately.

  71. vasild approved
  72. vasild commented at 2:41 pm on March 4, 2026: contributor
    ACK eca0c31c130c3deb68acd98325580052950981b5 (just first two commits) ACK 2bff5f1a3ead6f361c39cb27af773d44cf5b3762 (full PR)

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-03-10 09:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me