-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
No in-build execution for CMake managed builds #22060
Comments
That behavior is a bit annoying, but there is a reason CMAKE_SKIP_BUILD_RPATH is set, as is explained on the comment above the line you referred. Specifically, cmake clears the rpath after the build if the SKIP option is not set, breaking all the dependencies that are set by nix. So it's not as easy as just not setting that flag. Did you have a specific solution in mind? |
Only if CMake would use RPATH for local and RUNPATH for global dependencies. But CMake uses put all the dependencies into RUNPATH. No I have no solution. |
cc @viric |
Are there any updates to this issue, please? |
I dug in the nixpkgs tree and found that some packages actually set -DCMAKE_SKIP_BUILD_RPATH=OFF, to reverse the effect of the setup hook and be able to run binaries from the build tree. Digging a bit more I found that -DCMAKE_SKIP_BUILD_RPATH=ON was added in 2009. Commit f3c2348 added it to the cmake setup hook after it having been manually set in a few packages earlier that year. In 2016 an attempt was made to change from -DCMAKE_SKIP_BUILD_RPATH=ON to -DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE, but it was reverted due to a blocking darwin issue: d5d4606. I'm not sure that commit would have fixed this issue, but the discussion that lead up the the revert is worth a read:#15881. After that revert, -DCMAKE_SKIP_BUILD_RPATH=OFF popped up in various package to workaround this issue. I wonder if we could try removing it again, possibly only for Linux? |
I'd highly appreciate that. I've had the same issue too. 😀 |
Hello, I'm a bot and I thank you in the name of the community for opening this issue. To help our human contributors focus on the most-relevant reports, I check up on old issues to see if they're still relevant. This issue has had no activity for 180 days, and so I marked it as stale, but you can rest assured it will never be closed by a non-human. The community would appreciate your effort in checking if the issue is still valid. If it isn't, please close it. If the issue persists, and you'd like to remove the stale label, you simply need to leave a comment. Your comment can be as simple as "still important to me". If you'd like it to get more attention, you can ask for help by searching for maintainers and people that previously touched related code and @ mention them in a comment. You can use Git blame or GitHub's web interface on the relevant files to find them. Lastly, you can always ask for help at our Discourse Forum or at #nixos' IRC channel. |
Still important to me. |
@LnL7 As this bit me again today while developing on a project, I'm wondering if you could help with fixing this issue. The previous attempt to fix this failed because of some issues on darwin, so you seem like the perfect person to turn to (being both maintainer of |
I marked this as stale due to inactivity. → More info |
This should simplify using `nix-shell -A` or `nix develop` to develop CMake based projects. CMake features a mechanism to use a different RPATH for all executables in the build directory and only rewrite these RPATHs on installation. This makes it possible to run executables already from the build directory without having to set LD_LIBRARY_PATH. This should simplify the checkPhase for cmake based projects and hopefully not break anything. Fixes: #22060
pr merged |
can someone add a section to @jtojnar's https://github.com/jtojnar/cmake-snips on how to fix this without the errors are example of a error https://hydra.nixos.org/build/183517097/log
|
What actually is the root cause of the |
AFAIK, it's due to bad cmake code in upstream projects. If the cmake code installs binaries with |
Issue description
I try to migrate a library written in C++ build via CMake to Nix. The test executables also written in C++ are part of this project. CMake allows in-build execution (and therefor in-build testing), because it sets the RPATH for the build executable.
Nixpkgs skips adding this RPATH by setting CMAKE_SKIP_BUILD_RPATH`. This behavior breaks the possibility to test the library or call built executables during build.
Workarounds
.../nixpkgs $ git grep -E "LD_LIBRARY_PATH.*pwd"
Proposal
The canonical behavior of CMake should be preserved and CMAKE_SKIP_BUILD_RPATH should not be set.
What do you think about this issue?
The text was updated successfully, but these errors were encountered: