Deduplicate @executable_path rpaths on macos #25
+16
−3
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.
Fixes an issue where duplicate
rpath
entries prevent dynamic library loading on macOS.Lots of hair-pulling involved here 😫
Change to
ld
behaviour on macOS SequoiaThis is really poorly documented, but on macOS 15.4 and later (may be related to an XCode version bump), there's been a change which prevents dynamically loading a library with duplicate
rpath
s.This means when linking against more than one SDL library, the resulting artefact can't itself be loaded as a shared library.
(Same issue as NixOS/nixpkgs#395169)
The Problem
In the following configuration:
mygame
) linking toSDL2_image
andSDL2_ttf
mygame-host
) which renders a window usingSDL2
and loads the above dylibBecause both
link_SDL2_image
andlink_SDL2_ttf
contain the following line:We end up having a library
mygame
with multiple RPATHaddRPathSpecial("@executable_path")
entries.Manual Fix
We can look at the built library:
Fixing manually:
Proper Fix?
The only way I could think of (acknowledging that other zig dependencies could also set an rpath) was to check whether an rpath exists first before adding our own. It's a bit convoluted, but works well in my testing.