build: exclude mptest target from compile commands #35418

pull Sanjana2906 wants to merge 1 commits into bitcoin:master from Sanjana2906:fix/iwyu-test-exclude changing 1 files +1 −1
  1. Sanjana2906 commented at 6:28 AM on May 30, 2026: contributor

    Fixes #35361

    The mptest target includes generated .capnp.h files that don't exist at CMake configure time. When IWYU reads compile_commands.json, it sees these non-existent files and fails.

    This PR excludes the mptest target from the compilation database by setting EXPORT_COMPILE_COMMANDS OFF, following the same pattern already applied to the mpcalculator, mpprinter, and mpexample targets in the same file.

    This change belongs in cmake/libmultiprocess.cmake (the integration layer).

  2. DrahtBot added the label Build system on May 30, 2026
  3. DrahtBot commented at 6:28 AM on May 30, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

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

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK ryanofsky

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #35454 (cmake: skip missing example targets in libmultiprocess.cmake by ryanofsky)

    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.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  4. DrahtBot added the label CI failed on Jun 1, 2026
  5. willcl-ark commented at 8:33 PM on June 1, 2026: member

    why not add this to line 37?

  6. Sanjana2906 commented at 4:45 AM on June 2, 2026: contributor

    @willcl-ark Thank You! I've updated the PR. mptest is now grouped with the existing EXPORT_COMPILE_COMMANDS OFF targets.

  7. maflcko commented at 9:25 AM on June 2, 2026: member
  8. Sanjana2906 force-pushed on Jun 2, 2026
  9. build: exclude mptest target from compile commands
    build: exclude mptest target from compile commands
    4731049ba4
  10. Sanjana2906 force-pushed on Jun 2, 2026
  11. Sanjana2906 commented at 10:17 AM on June 2, 2026: contributor

    @maflcko Thanks. I've squashed the commits and rebased the branch onto the latest upstream master.

  12. DrahtBot removed the label CI failed on Jun 2, 2026
  13. willcl-ark commented at 8:07 PM on June 2, 2026: member

    Should we add mputil and mpgen here too? I assume we want to keep multiprocess? or should that also be excluded?

  14. Sanjana2906 commented at 5:33 AM on June 3, 2026: contributor

    @willcl-ark I investigated mputil, mpgen, and multiprocess.

    mptest appears to be the only target in libmultiprocess that uses target_capnp_sources():

    target_capnp_sources(mptest ${CMAKE_CURRENT_SOURCE_DIR} mp/test/foo.capnp)
    

    I couldn't find similar generated Cap'n Proto sources for mputil or mpgen, and the issue report specifically mentions missing generated .capnp.* , so the IWYU issue seems specific to mptest.

  15. fanquake commented at 11:00 AM on June 4, 2026: member
  16. hebasto commented at 2:53 PM on June 4, 2026: member

    Should we add mputil and mpgen here too? I assume we want to keep multiprocess? or should that also be excluded?

    We consistently avoid linting code in all subtrees except for src/ipc/libmultiprocess. I vaguely recall the related discussion, but I can't track down the link right now.

    #35361#issue-4503305159:

    ... we shouldn't be trying to lint a subtree in the first place...

    I agree. This can be achieved in the same way it is done for src/secp256k1:

    --- a/cmake/libmultiprocess.cmake
    +++ b/cmake/libmultiprocess.cmake
    @@ -3,6 +3,7 @@
     # file COPYING or https://opensource.org/license/mit/.
     
     function(add_libmultiprocess subdir)
    +  set(CMAKE_EXPORT_COMPILE_COMMANDS OFF)
       # Set BUILD_TESTING to match BUILD_TESTS. BUILD_TESTING is a standard cmake
       # option that controls whether enable_testing() is called, but in the bitcoin
       # build a BUILD_TESTS option is used instead.
    @@ -29,10 +30,4 @@ function(add_libmultiprocess subdir)
         # Add tests to "all" target so ctest can run them
         set_target_properties(mptest PROPERTIES EXCLUDE_FROM_ALL OFF)
       endif()
    -  # Exclude examples from compilation database, because the examples are not
    -  # built by default, and they contain generated c++ code. Without this
    -  # exclusion, tools like clang-tidy and IWYU that make use of compilation
    -  # database would complain that the generated c++ source files do not exist. An
    -  # alternate fix could build "mpexamples" by default like "mptests" above.
    -  set_target_properties(mpcalculator mpprinter mpexample PROPERTIES EXPORT_COMPILE_COMMANDS OFF)
     endfunction()
    

    Fixes #35361

    Not the entire issue, but only its first part:

    /home/admin/actions-runner/_work/_temp/src/ipc/libmultiprocess/test/mp/test/test.cpp:5:10: fatal error: 'mp/test/foo.capnp.h' file not found 5 | #include <mp/test/foo.capnp.h> | ^~~~~~~~~~~~~~~~~~~~~

  17. DrahtBot added the label CI failed on Jun 5, 2026
  18. ryanofsky commented at 3:35 PM on June 5, 2026: contributor

    Code review ACK 4731049ba4f8a820cc4aa13a745e41bdfbee284a. Seems ok to exclude mptest from tidy & iwyu checks as this PR does. It also seems ok to go further and exclude all of libmultiprocess from tidy & iwyu checks as hebasto suggested #35418#pullrequestreview-4428862711

    re: #35418#pullrequestreview-4428862711

    #35361 (comment):

    ... we shouldn't be trying to lint a subtree in the first place...

    I agree. This can be achieved in the same way it is done for src/secp256k1:

    I don't agree, but it seems ok to disable some checks if they are too much trouble to maintain.

    (Specifically, I don't understand why IWYU and cmake are having so much trouble here and why the IWYU job shouldn't do make bitcoin_ipc_headers bitcoin_ipc_test_headers to generate missing files.)

    Generally, it seems to me like a good thing if subtrees are checked, to prevent things like remove_all from sneaking in, without other projects needing to duplicate all the same checks as bitcoin core.

  19. hebasto commented at 3:43 PM on June 5, 2026: member

    Generally, it seems to me like a good thing if subtrees are checked...

    It creates friction when upgrading a tool that requires accompanying code changes in a subtree.

  20. ryanofsky commented at 4:27 PM on June 5, 2026: contributor

    It creates friction when upgrading a tool that requires accompanying code changes in a subtree.

    Yes all tests and checks create friction. The question is whether the friction has more costs than benefits. I am objecting to the blanket statement that all linting should be disabled, not saying that every check needs to be enabled.

  21. willcl-ark commented at 8:34 AM on June 9, 2026: member

    I think we all agree that we should not lint vendored thirdy-party subtrees, but perhaps there is still a somewhat-open question here around: "should we lint subtrees we actively co-maintain" (libmultiprocess) that we should clarify.

    I think this PR is a fine minimal fix, and I'd be fine with a simple "never lint any subtrees" rule too, but there are potentially some benefits to some linting as Russ alludes to. As he points out, the lint in this case has arguably highlighed a cmake "bug" where it's not building the required files int he corretc order (or perhaps highlighting a dependency/order issue), and instead of fixing that we are disabling the check.

    The flip side is that we can surely run IWYU and friends on libmultiprocess in its own repo :)

  22. hebasto commented at 10:56 AM on June 9, 2026: member

    ... we can surely run IWYU and friends on libmultiprocess in its own repo :)

    +1

  23. DrahtBot removed the label CI failed on Jun 10, 2026
  24. fanquake commented at 11:35 AM on June 12, 2026: member

    I think this is fine to merge now, and we can continue with followups (#35454, #35468), of which either will be possible after the next subtree pull (need either https://github.com/bitcoin-core/libmultiprocess/pull/287 or https://github.com/bitcoin-core/libmultiprocess/pull/291).

  25. fanquake merged this on Jun 12, 2026
  26. fanquake closed this on Jun 12, 2026

  27. fanquake commented at 8:28 AM on June 13, 2026: member

    I was wrong about this being fine, it has just broken the build in some configurations (reported on IRC). Reverted for now in #35523. I guess we can fix this properly with the changes from the subtree.


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-06-21 02:51 UTC

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