Set install RPATH on macOS so binaries find libopenscap#2348
Merged
Mab879 merged 1 commit intoOpenSCAP:mainfrom May 4, 2026
Merged
Set install RPATH on macOS so binaries find libopenscap#2348Mab879 merged 1 commit intoOpenSCAP:mainfrom
Mab879 merged 1 commit intoOpenSCAP:mainfrom
Conversation
After `make install`, oscap referenced @rpath/libopenscap.<ver>.dylib but had no LC_RPATH entries, so dyld failed with "no LC_RPATH's found" unless DYLD_LIBRARY_PATH was set. Add CMAKE_INSTALL_RPATH (@loader_path/../lib plus the absolute install prefix) and CMAKE_INSTALL_NAME_DIR=@rpath so installed binaries resolve the dylib in-place and remain relocatable. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.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.



Summary
After
make installon macOS,oscapreferenced@rpath/libopenscap.<ver>.dylibbut the binary had noLC_RPATHentries, sodyldfailed at startup:The library was installed correctly to
/usr/local/lib/libopenscap.33.dylib; the binary just had no way to locate it withoutDYLD_LIBRARY_PATH. CMake on macOS strips the build-tree RPATH at install time and provides nothing in its place unlessCMAKE_INSTALL_RPATHis set.This adds, inside the existing
if(APPLE)block in the rootCMakeLists.txt:CMAKE_MACOSX_RPATH ONCMAKE_INSTALL_NAME_DIR "@rpath"CMAKE_INSTALL_RPATH "@loader_path/../lib;${CMAKE_INSTALL_PREFIX}/lib"@loader_path/../libkeeps the install relocatable; the absolute prefix path is a fallback. Linux and Windows are unaffected — the block isAPPLE-only.This is a follow-on to the macOS/FreeBSD portability work in #2326.
Test plan
DESTDIR=… make install):otool -l .../bin/oscapshows bothLC_RPATHentries (@loader_path/../liband/usr/local/lib)/usr/local:oscap --versionandoscap xccdf generate report …run withoutDYLD_LIBRARY_PATHAPPLE; no CMake variables Linux uses are touched)No new automated test — existing CI (
.github/workflows/) runs on Ubuntu and Fedora only, so an RPATH check wouldn't execute. The fix is verifiable manually withotool -lon macOS.