Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installing in ${HOME}/.local causes build error #134

Open
hebasto opened this issue Jan 24, 2025 · 2 comments
Open

Installing in ${HOME}/.local causes build error #134

hebasto opened this issue Jan 24, 2025 · 2 comments

Comments

@hebasto
Copy link
Contributor

hebasto commented Jan 24, 2025

On Ubuntu 24.04, with a patch from #133 applied:

# In Libmultiprocess repo
$ cmake -B build
$ cmake --build build
$ cmake --install build --prefix "${HOME}/.local"
# In Bitcoin Core repo
$ cmake -B build -DWITH_MULTIPROCESS=ON
$ cmake --build build -t bitcoin-node
[280/344] Generating capnp/common.capnp.c++, capnp/common.capnp.h, capnp/common....proxy-server.c++, capnp/common.capnp.proxy-types.c++, capnp/common.capnp.proxy.h
FAILED: src/ipc/capnp/common.capnp.c++ src/ipc/capnp/common.capnp.h src/ipc/capnp/common.capnp.proxy-client.c++ src/ipc/capnp/common.capnp.proxy-types.h src/ipc/capnp/common.capnp.proxy-server.c++ src/ipc/capnp/common.capnp.proxy-types.c++ src/ipc/capnp/common.capnp.proxy.h /home/hebasto/git/bitcoin/build/src/ipc/capnp/common.capnp.c++ /home/hebasto/git/bitcoin/build/src/ipc/capnp/common.capnp.h /home/hebasto/git/bitcoin/build/src/ipc/capnp/common.capnp.proxy-client.c++ /home/hebasto/git/bitcoin/build/src/ipc/capnp/common.capnp.proxy-types.h /home/hebasto/git/bitcoin/build/src/ipc/capnp/common.capnp.proxy-server.c++ /home/hebasto/git/bitcoin/build/src/ipc/capnp/common.capnp.proxy-types.c++ /home/hebasto/git/bitcoin/build/src/ipc/capnp/common.capnp.proxy.h 
cd /home/hebasto/git/bitcoin/build/src/ipc && /home/hebasto/.local/bin/mpgen /home/hebasto/git/bitcoin/src/ipc /home/hebasto/git/bitcoin /home/hebasto/git/bitcoin/src/ipc/capnp/common.capnp
/home/hebasto/git/bitcoin/src/ipc/capnp/common.capnp:10:22-39: error: Import failed: /mp/proxy.capnp
/home/hebasto/git/bitcoin/src/ipc/capnp/common.capnp:11:2-7: error: Not defined: Proxy
/home/hebasto/git/bitcoin/src/ipc/capnp/common.capnp:13:18-23: error: Not defined: Proxy
terminate called after throwing an instance of 'std::runtime_error'
  what():  Invoking /usr/bin/capnp failed
Aborted (core dumped)
ninja: build stopped: subcommand failed.
$ printenv PATH
/home/hebasto/.cargo/bin:/home/hebasto/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin
@ryanofsky
Copy link
Collaborator

ryanofsky commented Jan 24, 2025

Thanks for the bug report! This is interesting and I learned some things.

tl;dr: recommended fix is to use -DCMAKE_INSTALL_PREFIX=$HOME/.local earlier at configure time instead of using --prefix $HOME/.local install option later.

Few observations:

  • On my system in order to reproduce this I had to set CMAKE_PREFIX_PATH=$HOME/.local in the environment during the cmake -B build -DWITH_MULTIPROCESS=ON step, otherwise it would not find the package. I'm not sure if cmake uses $HOME/.local by default on other systems.

  • A slightly faster way for me to make the problem happen instead of running cmake --build build -t bitcoin-node was to run make -C build bitcoin_ipc

  • Cause of the problem is that paths to capnproto include directories currently get compiled into the mpgen executable. You can verify this by running strings ~/.local/bin/mpgen | grep /include. So if cmake does not know the install prefix at configure time it will not build the executable correctly.

  • Recommended fix would be run cmake -B build -DCMAKE_INSTALL_PREFIX=$HOME/.local

    • This will build mpgen executable correctly, and lets you more conveniently run cmake --install build or make -C build install without needing to repeat the install prefix, because it is saved in the configuration.
  • Possible follow-ups to address this issue might be:

    • Improving documentation to recommend using -DCMAKE_INSTALL_PREFIX, or configuring cmake graphically, instead of passing --prefix to the install command.

    • Maybe making it an error in the install script to specify a different --prefix value that does not match CMAKE_INSTALL_PREFIX. Not sure if this is possible with cmake scripting.

    • Changing mpgen executable to try to detect include paths at runtime instead of compile time. This might be challenging though. It should not be too difficult for it to find the libmultiprocess include directory (needed to import "/mp/proxy.capnp"). But I'm not sure how it could determine the capnproto include path at runtime (needed to import "/capnp/c++.capnp")

    • Maybe the target_capnp_sources function could automatically work around this issue, if it can determine the Libmultiprocess install path from cmake variables and add pass the include path as an extra argument to the mpgen command line.

  • For purposes of Bitcoin project, this problem might become mooted if Libmultiprocess can be a git subtree configured with add_subdirectory, since in that case there shouldn't be any installation step needed.

@ryanofsky
Copy link
Collaborator

Some of the followups listed in previous comment are probably still a good idea, but note that with the bitcoin/bitcoin#31741 there is probably less of a reason to want to install libmultiprocess as a separate package, so that makes it less likely someone would encounter problems using cmake --install --prefix. It is still pretty useful to install it as a separate package in order to be able to work with this git repository though, so I should at least document fact that that --prefix option can lead to problems and CMAKE_INSTALL_PREFIX should be preferred instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants