[stable-33.0] keep sync dylib install_name as @rpath through cmake --install#9848
Merged
Conversation
…stall
Fixes a dyld failure at launch ("Library not loaded:
.../build/macos-clang-arm64/lib/libnextcloudsync.0.dylib") that reliably
reproduced after any rebuild, incremental or clean.
Symptom
-------
/Applications/NextcloudDev.app crashes immediately on launch:
dyld: Library not loaded:
/Users/<user>/.../build/macos-clang-arm64/lib/libnextcloudsync.0.dylib
Referenced from: .../NextcloudDev.app/Contents/MacOS/NextcloudDev
Reason: tried: '.../build/macos-clang-arm64/lib/libnextcloudsync.0.dylib'
(no such file)
otool confirms the installed binary carries an absolute reference to a
file nothing ever installs:
$ otool -L /Applications/NextcloudDev.app/Contents/MacOS/NextcloudDev
...
/Users/<user>/.../build/macos-clang-arm64/lib/libnextcloudsync.0.dylib
The dylibs actually live in Contents/MacOS (via `install(TARGETS)`) and
Contents/Frameworks (via macdeployqt), never under build/.../lib.
Cause
-----
Each build writes this into work/build/src/gui/cmake_install.cmake:
install_name_tool \
-change @rpath/libnextcloud_csync.0.dylib \
/<prefix>/lib/libnextcloud_csync.0.dylib \
-change @rpath/libnextcloudsync.0.dylib \
/<prefix>/lib/libnextcloudsync.0.dylib \
.../NextcloudDev.app/Contents/MacOS/NextcloudDev
CMake derives the replacement from each library target's install_name.
When INSTALL_NAME_DIR is unset, CMake defaults to
${CMAKE_INSTALL_PREFIX}/lib/libfoo.dylib regardless of where the target
is actually installed. The build-tree bundle in work/build/bin is fine
(macdeployqt keeps @rpath and adds @loader_path/../Frameworks to RPATH);
it is cmake --install that corrupts the references as it copies the
bundle into image-Debug-master and on to /Applications.
The previous BUILD_WITH_INSTALL_RPATH fix only suppressed RPATH churn,
not the install_name rewrite.
Why the first launch "worked" was situational -- a stale dylib left at
that path from a prior build, an older cached binary, or the install
step having aborted earlier. Every fresh cmake --install produces the
broken absolute reference; nothing makes it self-healing.
Fix
---
Set INSTALL_NAME_DIR "@rpath" on nextcloudsync and nextcloud_csync.
cmake --install now keeps the dylib install_name as
@rpath/libfoo.dylib, and the -change against the executable becomes a
no-op against its existing @rpath/... reference. The nextcloud
binary's @loader_path/../Frameworks rpath then resolves the dylibs
macdeployqt placed in Contents/Frameworks.
Signed-off-by: Iva Horn <iva.horn@nextcloud.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Backport of PR #9844