cmake: Show error instead of invoking cross-compiled mpgen binary #171

pull ryanofsky wants to merge 1 commits into bitcoin-core:master from ryanofsky:pr/cross changing 2 files +32 −6
  1. ryanofsky commented at 8:08 pm on April 14, 2025: collaborator

    Idea here is to avoid potentially confusing errors if cross compiling and forgetting to set the MPGEN_EXECUTABLE.

    Idea came from theuni in https://github.com/bitcoin/bitcoin/pull/31741#discussion_r2040214663 with suggestion to show a warning whenever CMAKE_CROSSCOMPILING was set and MPGEN_EXECUTABLE wasn’t set, but this would show a warning in the default build which excludes tests and examples and does not need to run the code generator. Also it could warn spuriously if cross-compiled binaries were actually executable.

    Avoid these problems by using check_cxx_source_runs instead of CMAKE_CROSSCOMPILING to see if binaries can run and triggering an error at build time instead of configure time to avoid showing warnings when code generator is not actually needed.

    This is currently a draft PR, because I haven’t tested it on a cross-compiled system so not actually sure it is a significant improvement. Also not sure if this is the best approach.

  2. cmake: Show error instead of invoking cross-compiled mpgen binary
    Suggested by Cory Fields <cory-nospam-@coryfields.com> in
    https://github.com/bitcoin/bitcoin/pull/31741#discussion_r2040214663
    8abe089482
  3. in CMakeLists.txt:43 in 8abe089482
    34@@ -35,6 +35,17 @@ include(GNUInstallDirs)
    35 # to avoid "error: Import failed: /mp/proxy.capnp" failures from capnproto.
    36 set_property(GLOBAL PROPERTY MP_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
    37 
    38+# Set MP_NO_GENERATE as a global property if cross compiling and
    39+# MPGEN_EXECUTABLE not set and cross compiled executables can not run. This
    40+# should trigger a more readable attempting to run a cross compiled executable.
    41+if(CMAKE_CROSSCOMPILING AND NOT MPGEN_EXECUTABLE)
    42+  include(CheckCXXSourceRuns)
    43+  check_cxx_source_runs("int main() { return 0; }" EXECUTABLES_CAN_RUN)
    


    theuni commented at 8:50 pm on April 14, 2025:
    Nice. While looking for something like this, I stumbled upon try_run which takes CMAKE_CROSSCOMPILING into account, which is why I suggested just testing against the var itself. But it seems check_cxx_source_runs is more sane.
  4. DrahtBot commented at 11:21 am on June 23, 2025: none

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

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #184 (Add CI jobs and fix clang-tidy and iwyu errors 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.

  5. DrahtBot added the label Needs rebase on Jun 26, 2025
  6. DrahtBot commented at 7:10 pm on June 26, 2025: none
    🐙 This pull request conflicts with the target branch and needs rebase.
  7. DrahtBot commented at 0:47 am on September 23, 2025: none

    ⌛ There hasn’t been much activity lately and the patch still needs rebase. What is the status here?

    • Is it still relevant? ➡️ Please solve the conflicts to make it ready for review and to ensure the CI passes.
    • Is it no longer relevant? ➡️ Please close.
    • Did the author lose interest or time to work on this? ➡️ Please close it and mark it ‘Up for grabs’ with the label, so that it can be picked up in the future.

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/libmultiprocess. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-12-04 19:30 UTC

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