Skip to content

build: suggest -DENABLE_IPC=OFF when missing capnp - #33290

Closed
Sjors wants to merge 1 commit into
bitcoin:masterfrom
Sjors:2025/08/missing_capnp
Closed

Sjors wants to merge 1 commit into
bitcoin:masterfrom
Sjors:2025/08/missing_capnp

Conversation

@Sjors

@Sjors Sjors commented Sep 3, 2025 •

Copy link
Copy Markdown
Member

Since #31802, when existing users upgrade to a recent version of master, or the upcoming v30 release, they'll be treated by an error that CapnProto is missing. Unless they read the release notes :-)

This error is generated by src/ipc/libmultiprocess/CMakeLists.txt which is a git subtree and so it doesn't have context of our project, and doesn't know about the -DENABLE_IPC option.

This pull request adds a simple pre-check in own CMake file to see if Cap'n Proto is missing. For ease of maintenance it doesn't check the version.

The new warning is shown in yellow, the (unchanged) error in red:

Scherm­afbeelding 2025-09-03 om 14 30 03

@DrahtBot

DrahtBot commented Sep 3, 2025 •

Copy link
Copy Markdown
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/33290.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK janb84
Concept ACK ismaelsadeeq, l0rinc

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

@Sjors

Sjors commented Sep 3, 2025

Copy link
Copy Markdown
Member Author

Very strange CI errors:

03:45:32.525] -- Configuring incomplete, errors occurred!
[03:45:32.543] ++ cmake -P /ci_container_base/ci/test/GetCMakeLogFiles.cmake
[03:45:32.586] + cat CMakeFiles/CMakeConfigureLog.yaml
[03:45:32.587] cat: CMakeFiles/CMakeConfigureLog.yaml: No such file or directory
[03:45:32.621] Command '['./ci/test/02_run_container.sh']' returned non-zero exit status 1.

@hebasto

hebasto commented Sep 3, 2025 •

Copy link
Copy Markdown
Member

Very strange CI errors:

03:45:32.525] -- Configuring incomplete, errors occurred!
[03:45:32.543] ++ cmake -P /ci_container_base/ci/test/GetCMakeLogFiles.cmake
[03:45:32.586] + cat CMakeFiles/CMakeConfigureLog.yaml
[03:45:32.587] cat: CMakeFiles/CMakeConfigureLog.yaml: No such file or directory
[03:45:32.621] Command '['./ci/test/02_run_container.sh']' returned non-zero exit status 1.

It seems a behaviour change overlooked in #32880.

@hebasto

hebasto commented Sep 3, 2025

Copy link
Copy Markdown
Member

Very strange CI errors:

03:45:32.525] -- Configuring incomplete, errors occurred!
[03:45:32.543] ++ cmake -P /ci_container_base/ci/test/GetCMakeLogFiles.cmake
[03:45:32.586] + cat CMakeFiles/CMakeConfigureLog.yaml
[03:45:32.587] cat: CMakeFiles/CMakeConfigureLog.yaml: No such file or directory
[03:45:32.621] Command '['./ci/test/02_run_container.sh']' returned non-zero exit status 1.

Suggesting this patch for a quick fix:

--- a/ci/test/03_test_script.sh
+++ b/ci/test/03_test_script.sh
@@ -123,6 +123,7 @@ if [[ "${RUN_TIDY}" == "true" ]]; then
 fi
 
 bash -c "cmake -S $BASE_ROOT_DIR -B ${BASE_BUILD_DIR} $BITCOIN_CONFIG_ALL $BITCOIN_CONFIG" || (
+  cd "${BASE_BUILD_DIR}"
   # shellcheck disable=SC2046
   cat $(cmake -P "${BASE_ROOT_DIR}/ci/test/GetCMakeLogFiles.cmake")
   false

cc @maflcko

@Sjors
Sjors force-pushed the 2025/08/missing_capnp branch from 8ca7a3c to 1df094f Compare September 3, 2025 10:28
@Sjors

Sjors commented Sep 3, 2025

Copy link
Copy Markdown
Member Author

Thanks @hebasto, I added a commit here to try that fix.

@maflcko

maflcko commented Sep 3, 2025

Copy link
Copy Markdown
Member

Mind submitting ed95f4f095fecb0a6e5601199959db21e811dd71 as a separate pull?

@Sjors

Sjors commented Sep 3, 2025 •

Copy link
Copy Markdown
Member Author

@maflcko I prefer if someone else does it, as I don't really know what this part of CI is doing.

Also, those builds still break.

@maflcko

maflcko commented Sep 3, 2025

Copy link
Copy Markdown
Member

Also, those builds still break.

That is expected. ed95f4f must not interfere with unrelated issues. The reason why your build fails is because you are adding the targets twice. (You can see this by reading the log)

@Sjors

Sjors commented Sep 3, 2025

Copy link
Copy Markdown
Member Author

@maflcko the log is very verbose, but in indeed useful, so I opened #33291.

@Sjors
Sjors marked this pull request as draft September 3, 2025 12:27
@maflcko

maflcko commented Sep 3, 2025

Copy link
Copy Markdown
Member

@maflcko the log is very verbose, but in indeed useful, so I opened #33291.

for reference, this specific warning was also printed without the verbose log: https://cirrus-ci.com/task/4516741763563520?logs=ci#L894 :

...
[03:43:58.798] CMake Error at /usr/lib/x86_64-linux-gnu/cmake/CapnProto/CapnProtoTargets.cmake:213 (add_executable):
[03:43:58.798]   add_executable cannot create imported target "CapnProto::capnpc_cpp"
[03:43:58.798]   because another target with the same name already exists.
[03:43:58.798] Call Stack (most recent call first):
[03:43:58.798]   /usr/lib/x86_64-linux-gnu/cmake/CapnProto/CapnProtoConfig.cmake:112 (include)
[03:43:58.798]   src/ipc/libmultiprocess/CMakeLists.txt:16 (find_package)
[03:43:58.798] 
[03:43:58.798] 
[03:43:58.798] CMake Error at /usr/lib/x86_64-linux-gnu/cmake/CapnProto/CapnProtoTargets.cmake:218 (add_executable):
[03:43:58.798]   add_executable cannot create imported target "CapnProto::capnpc_capnp"
[03:43:58.798]   because another target with the same name already exists.
[03:43:58.798] Call Stack (most recent call first):
[03:43:58.798]   /usr/lib/x86_64-linux-gnu/cmake/CapnProto/CapnProtoConfig.cmake:112 (include)
[03:43:58.798]   src/ipc/libmultiprocess/CMakeLists.txt:16 (find_package)
[03:43:58.798] 
[03:43:58.798] 
[03:43:58.801] -- Performing Test HAVE_PTHREAD_GETNAME_NP
[03:43:59.084] -- Performing Test HAVE_PTHREAD_GETNAME_NP - Success
[03:43:59.084] -- Performing Test HAVE_PTHREAD_THREADID_NP
[03:43:59.221] -- Performing Test HAVE_PTHREAD_THREADID_NP - Failed
[03:43:59.221] -- Performing Test HAVE_PTHREAD_GETTHREADID_NP
[03:43:59.344] -- Performing Test HAVE_PTHREAD_GETTHREADID_NP - Failed
[03:43:59.357] 
[03:43:59.357] Configuring secp256k1 subtree...
[03:43:59.483] -- The C compiler identification is Clang 21.1.0
[03:43:59.530] -- Detecting C compiler ABI info
[03:43:59.791] -- Detecting C compiler ABI info - done
[03:43:59.803] -- Check for working C compiler: /usr/bin/clang - skipped
[03:43:59.804] -- Detecting C compile features
[03:43:59.804] -- Detecting C compile features - done
...

@Sjors
Sjors force-pushed the 2025/08/missing_capnp branch from fc2e3f5 to f39a782 Compare September 3, 2025 12:49
@Sjors

Sjors commented Sep 3, 2025

Copy link
Copy Markdown
Member Author

Using find_program instead of find_package as suggested by an AI overlord, seems to do the trick.

Another issue was that the depends build also threw this warning, which I added a check for.

@Sjors
Sjors marked this pull request as ready for review September 3, 2025 12:49

@janb84 janb84 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK f39a782

PR adds warning text to cmake configure step if CAPNP is not installed. The CAPNP dependency is new, and this warning helps people that do not read the Releasenotes how to solve the error.

Although I do not recommend to upgrade without reading the Release notes / changelog, this warning can reduce the number of issues and guides (non-technical) users to avoid errors .

  • code review ✅
  • build with and without capnp to test warning. ✅
Details

without capnp:

CMake Warning at cmake/libmultiprocess.cmake:12 (message):
  Cap'n Proto (capnp) not found.  Compile with -DENABLE_IPC=OFF if you do not
  need IPC functionality.
Call Stack (most recent call first):
  src/CMakeLists.txt:24 (add_libmultiprocess)

without capnp & -DENABLE_IPC=OFF:

  IPC ................................. OFF
  
-- Configuring done (4.8s)

with capnp:

  IPC ................................. ON
  
-- Configuring done (5.2s)

@maflcko maflcko removed the CI failed label Sep 3, 2025
@maflcko maflcko added this to the 30.0 milestone Sep 3, 2025
@ryanofsky

Copy link
Copy Markdown
Contributor

This is a nice idea and approach seems ok if it works in practice. I think a more general approach might to have the bitcoin build set a variable the libmultiprocess build can use to show better error messages like:

set(MP_SUBPROJECT_ERROR "Configure cmake with with -DENABLE_IPC=OFF if you do not need IPC functionality.")

It could append this message if it can't find the cap'n proto package, or doesn't find a compatible version (for bitcoin-core/libmultiprocess#199 and #33176).

@Sjors

Sjors commented Sep 3, 2025

Copy link
Copy Markdown
Member Author

@ryanofsky I like your approach better since it can be used under more circumstances, such as not having the right version. But we're close to branch-off so maybe this approach suffices for now.

@ismaelsadeeq ismaelsadeeq left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK

function(add_libmultiprocess subdir)
# Provide a more helpful message without pulling in CapnProtoConfig.cmake,
# which is included again by libmultiprocess. Skip the check when using the
# depends toolchain.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NACK to adding any depends specific code. CMAKE_TOOLCHAIN_FILE also doesn't necessarily mean a depends build; anyone can bring/use a toolchain file.

@ryanofsky ryanofsky Sep 4, 2025 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re: #33290 (comment)

NACK to adding any depends specific code. CMAKE_TOOLCHAIN_FILE also doesn't necessarily mean a depends build; anyone can bring/use a toolchain file.

Yeah I think it is clear this is not a good long term solution, but to be fair I don't think there is much actual harm done here if CMAKE_TOOLCHAIN_FILE is set, since this would just fail to print a warning that is likely to be irrelevant.

But I do think it could be nice to close this PR and extend @willcl-ark's approach as described in bitcoin-core/libmultiprocess#205 (comment) to handle this in libmultiprocess instead of of bitcoin core.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have extended bitcoin-core/libmultiprocess#205 to include more helpful error messages when the capnproto package is not found by cmake.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's go for that approach then.

hebasto added a commit that referenced this pull request Sep 4, 2025
9b76eef ci: cd into BASE_BUILD_DIR for GetCMakeLogFiles (Sjors Provoost)

Pull request description:

  When a bug is introduced in cmake, we render its logs, which was broken:
  #33290 (comment)

ACKs for top commit:
  maflcko:
    lgtm ACK 9b76eef 💽
  hebasto:
    ACK 9b76eef, [obviously](#33290 (comment)).

Tree-SHA512: 97a440efcaa058af1144d66257ac0157d499b66fd9a00fa01e0eaa013267af1643cb062ec6c74366fab88cb706c9cf9d5fb0316195e79582679c7ae8d39ec200

@l0rinc l0rinc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK

if(NOT (DEFINED CMAKE_TOOLCHAIN_FILE))
find_program(_CAPNP capnp)
if(NOT _CAPNP)
message(WARNING "Cap'n Proto (capnp) not found. Compile with -DENABLE_IPC=OFF if you do not need IPC functionality.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might also want to mention that doc/build-*.md contains instructions for installing this new dependency, should they choose to not add -DENABLE_IPC=OFF

@davidgumberg

davidgumberg commented Sep 4, 2025 •

Copy link
Copy Markdown
Contributor

Conceptual question:

Why not print a warning and set(ENABLE_IPC OFF) when missing capnp? This was generally the approach taken in the old autotools build system. Is it better to force the user to confront the warning and change their configuration than to just try to build something reasonable based on what dependencies the user has?

@sipa

sipa commented Sep 4, 2025

Copy link
Copy Markdown
Member

@davidgumberg I believe that's a philosophical difference between cmakeland and autotoolsland, and I think in the case of optional build dependencies, it's better not to autodetect them, to avoid build system configuration leaking into the build (which then might not work on the system you actually want to run it on).

@Sjors

Sjors commented Sep 5, 2025

Copy link
Copy Markdown
Member Author

Closing in favour of bitcoin-core/libmultiprocess#205.

@Sjors

Sjors commented Sep 5, 2025

Copy link
Copy Markdown
Member Author

#33315 could be added to the v30 milestone so we don't forget.

Kino1994 pushed a commit to Kino1994/bitcoin-full-history that referenced this pull request Jun 28, 2026
…ogFiles

bec10cc ci: cd into BASE_BUILD_DIR for GetCMakeLogFiles (Sjors Provoost)

Pull request description:

  When a bug is introduced in cmake, we render its logs, which was broken:
  bitcoin/bitcoin#33290 (comment)

ACKs for top commit:
  maflcko:
    lgtm ACK bec10cc 💽
  hebasto:
    ACK bec10cc, [obviously](bitcoin/bitcoin#33290 (comment)).

Tree-SHA512: 97a440efcaa058af1144d66257ac0157d499b66fd9a00fa01e0eaa013267af1643cb062ec6c74366fab88cb706c9cf9d5fb0316195e79582679c7ae8d39ec200
BigcoinBGC pushed a commit to BigcoinBGC/bigcoin that referenced this pull request Jun 30, 2026
…ogFiles

dd6af75 ci: cd into BASE_BUILD_DIR for GetCMakeLogFiles (Sjors Provoost)

Pull request description:

  When a bug is introduced in cmake, we render its logs, which was broken:
  bitcoin/bitcoin#33290 (comment)

ACKs for top commit:
  maflcko:
    lgtm ACK dd6af75 💽
  hebasto:
    ACK dd6af75, [obviously](bitcoin/bitcoin#33290 (comment)).

Tree-SHA512: 97a440efcaa058af1144d66257ac0157d499b66fd9a00fa01e0eaa013267af1643cb062ec6c74366fab88cb706c9cf9d5fb0316195e79582679c7ae8d39ec200
Kino1994 pushed a commit to Kino1994/bitcoin-full-history that referenced this pull request Aug 19, 2026
…ogFiles

9b76eef2d2b42703e2a30952d4c3474b533e360a ci: cd into BASE_BUILD_DIR for GetCMakeLogFiles (Sjors Provoost)

Pull request description:

  When a bug is introduced in cmake, we render its logs, which was broken:
  bitcoin/bitcoin#33290 (comment)

ACKs for top commit:
  maflcko:
    lgtm ACK 9b76eef2d2b42703e2a30952d4c3474b533e360a 💽
  hebasto:
    ACK 9b76eef2d2b42703e2a30952d4c3474b533e360a, [obviously](bitcoin/bitcoin#33290 (comment)).

Tree-SHA512: 97a440efcaa058af1144d66257ac0157d499b66fd9a00fa01e0eaa013267af1643cb062ec6c74366fab88cb706c9cf9d5fb0316195e79582679c7ae8d39ec200
@bitcoin bitcoin locked and limited conversation to collaborators Sep 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.