fix macos rpath: use @executable_path instead of literal $executable_path#34
Closed
curusarn wants to merge 1 commit into
Closed
fix macos rpath: use @executable_path instead of literal $executable_path#34curusarn wants to merge 1 commit into
curusarn wants to merge 1 commit into
Conversation
…path The Apple branch was setting CMAKE_BUILD_RPATH/CMAKE_INSTALL_RPATH to "\$executable_path" — a literal directory name that dyld cannot resolve. macOS dyld uses @-prefixed tokens (@executable_path, @loader_path, @rpath), not $-prefixed ones like ELF's $ORIGIN. Symptom: helper executables that depend on @rpath/libcage-core.dylib (or any other neighboring dylib via the configured rpath) crash at launch with `Library not loaded: @rpath/libcage-core.dylib ... tried: '$executable_path/libcage-core.dylib' (no such file)`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Member
|
thanks |
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
cmake/cage_build_configuration.cmakesetsCMAKE_BUILD_RPATH/CMAKE_INSTALL_RPATHto the literal string$executable_pathon Apple platforms. macOSdylddoesn't recognize that — it uses@-prefixed tokens (@executable_path,@loader_path,@rpath), unlike ELF's$ORIGIN. The result is anLC_RPATHthat dyld can't resolve, so any binary that depends on a sibling dylib via@rpath/…fails to launch.Symptom
Helper executables built against cage crash at launch on macOS:
The main game executable can mask this if it's launched with a cwd or env that happens to satisfy the broken rpath, but spawned subprocesses (which inherit a hardened-runtime env on macOS) reliably crash in
dyldbeforemain().Discovered while debugging Unnatural Worlds — every spawned
unnatural-server/unnatural-ugc/unnatural-map-editordied at launch, generating 23.ipscrash reports across an 8-minute session and producing localhost connection timeouts from the client.Fix
Replace
\$executable_pathwith@executable_pathin theif(APPLE)branch. The Linux branch (\$ORIGIN) is correct and stays as-is — the leading\$escape is needed there because$is a CMake variable trigger;@is not, so no escape is needed on the macOS side.Test plan
install_name_tool -add_rpath @executable_path+codesign -fs -resolves the crash, confirming root cause.otool -l <target> | grep -A2 LC_RPATHshows@executable_path(not$executable_path).$ORIGINunchanged).🤖 Generated with Claude Code