cmake: Check user-defined APPEND_*FLAGS variables early #32367

pull hebasto wants to merge 3 commits into bitcoin:master from hebasto:250428-enable-lang changing 4 files +56 −20
  1. hebasto commented at 4:35 pm on April 28, 2025: member

    For the purpose of checks performed by the build system, we strive to handle user-defined APPEND_*FLAGS in the same way as flags provided by other standard means. In particular, they are considered when the try_compile() command is used.

    However, these flags are not considered during enable_language() command invocation due to design limitations, which might cause issues, such as #32323.

    This PR addresses the issue by introducing an additional compiler check that does consider the user-defined APPEND_*FLAGS.

    Fixes #32323:

     0$ cmake -B build -DAPPEND_CXXFLAGS="-ftrivial-auto-var-init"
     1-- The CXX compiler identification is GNU 14.2.0
     2-- Detecting CXX compiler ABI info
     3-- Detecting CXX compiler ABI info - done
     4-- Check for working CXX compiler: /usr/bin/c++ - skipped
     5-- Detecting CXX compile features
     6-- Detecting CXX compile features - done
     7-- Performing Test CXX_COMPILER_WORKS
     8-- Performing Test CXX_COMPILER_WORKS - Failed
     9CMake Error at cmake/module/EnableLanguage.cmake:42 (message):
    10  The CXX compiler is not able to compile a simple test program.
    11
    12  Check that the "APPEND_*FLAGS" variables are set correctly.
    13
    14
    15
    16Call Stack (most recent call first):
    17  CMakeLists.txt:71 (bitcoincore_enable_language)
    18
    19
    20-- Configuring incomplete, errors occurred!
    21hebasto@TS-P340:~/dev/bitcoin$ cmake -B build -DAPPEND_CXXFLAGS="-ftrivial-auto-var-init=zero"
    22-- Performing Test CXX_COMPILER_WORKS
    23-- Performing Test CXX_COMPILER_WORKS - Success
    24...
    
  2. hebasto added the label Build system on Apr 28, 2025
  3. DrahtBot commented at 4:35 pm on April 28, 2025: contributor

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

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32367.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    Stale ACK janb84, BrandonOdiwuor

    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:

    • #34591 (cmake: Improve install_name_tool workaround by hebasto)
    • #34580 (build: Add a compiler minimum version check by polespinasa)
    • #33974 (cmake: Check dependencies after build option interaction 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. hebasto marked this as a draft on Apr 28, 2025
  5. hebasto force-pushed on Apr 28, 2025
  6. hebasto marked this as ready for review on Apr 28, 2025
  7. hebasto force-pushed on Apr 28, 2025
  8. janb84 commented at 9:16 am on April 29, 2025: contributor

    ACK eb2a943

    • PR fixes #32323 (reproduced on main, checked it was solved by this PR) ✅
    • Code review looks good to me. Adds a new macro with additional checks and some optimisations.✅ (There is one reference to enable_languages() in secp256k1 but that is separate and not relevant to this PR )

    Main:

    Configure with faulty flag: cmake -B build -DAPPEND_CXXFLAGS="-ftrivial-auto-var-init"

    expected config BREAK

    Configure with correct flag: cmake -B build -DAPPEND_CXXFLAGS="-ftrivial-auto-var-init=zero" not expected: STILL BREAKS

    This PR:

    Configure with faulty flag cmake -B build -DAPPEND_CXXFLAGS="-ftrivial-auto-var-init" expected BREAK

    Configure with correct flag cmake -B build -DAPPEND_CXXFLAGS="-ftrivial-auto-var-init=zero" config WORKS

  9. DrahtBot added the label CI failed on Jul 30, 2025
  10. DrahtBot removed the label CI failed on Jul 30, 2025
  11. DrahtBot added the label Needs rebase on Aug 6, 2025
  12. BrandonOdiwuor commented at 10:43 am on August 21, 2025: contributor

    ACK eb2a9435044ac91442fafc606c5af2f473bff3c5

    Confirmed that the new bitcoincore_enable_language(...) macro properly validates user-defined APPEND_*FLAGS early via check_source_compiles(...), fixing #32323 by catching bad flags during enable_language(…), and removing the need a clean build directory.

    (system: macOS 15.6)

    (branch: master)

    (commit: eb2a9435044ac91442fafc606c5af2f473bff3c5)

  13. hebasto marked this as a draft on Oct 6, 2025
  14. fanquake commented at 11:43 am on February 13, 2026: member
    @hebasto was this drafted for any particular reason?
  15. cmake: Wrap `enable_language()` command in macro
    This change introduces the `bitcoincore_enable_language()` macro to wrap
    CMake’s `enable_language()` command, applying Bitcoin Core-specific
    settings and checks.
    d5faf1d6f9
  16. cmake: Move `APPEND_*` variables logic to `bitcoincore_enable_language`
    This change is required for the following commit.
    f4f29d5c26
  17. cmake: Check user-defined `APPEND_*` variables early
    This change improves usability in cases where the user provides
    `APPEND_*` variables that are incompatible with the compiler for some
    reason.
    98b5edf5b3
  18. hebasto force-pushed on Feb 13, 2026
  19. hebasto marked this as ready for review on Feb 13, 2026
  20. hebasto commented at 12:12 pm on February 13, 2026: member

    @hebasto was this drafted for any particular reason?

    Rebased and undrafted.

  21. DrahtBot removed the label Needs rebase on Feb 13, 2026

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-02-21 00:13 UTC

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