Repository navigation
port(MachO): emit LC_RPATH load commands - #2679
Merged
Merged
Conversation
Emit one LC_RPATH command per -rpath value instead of ignoring the option. Repeated paths are dropped, as ld64 does.
jadenfix
force-pushed
the
macho-lc-rpath
branch
from
October 5, 2026 23:00
22e59fa to
51308cb
Compare
davidlattimore
approved these changes
Oct 6, 2026
marxin
requested changes
Oct 6, 2026
marxin
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for the contribution.
Note the option is commonly used with @ (e.g. -Wl,-rpath,@loader_path/../lib) and we should double check our save_dir.rs code can properly escape it (if needed).
-headerpad_max_install_names now leaves MAXPATHLEN of room for each LC_RPATH command as well as each LC_LOAD_DYLIB, so install_name_tool can rewrite an rpath in place.
With WILD_SAVE_DIR set, `-rpath @loader_path/../lib` failed the link because save-dir tried to read `loader_path/../lib` as a response file. Response files have already been read by the argument parser, so only treat an `@` argument as one if the file exists.
marxin
approved these changes
Oct 6, 2026
marxin
left a comment
Collaborator
There was a problem hiding this comment.
LGTM, thank you for your first contribution.
marxin
enabled auto-merge (squash)
October 6, 2026 18:38
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.
Closes #2677
-rpathwas parsed but ignored on Mach-O. Now each value gets its ownLC_RPATHcommand, written directly after theLC_LOAD_DYLIBcommands. Duplicates are dropped like ld64 does.Added a Mach-O
rpathtest that makes sure the paths end up in the binary. Also comparedotool -loutput against Apple's ld and confirmed the commands match. Tested with both Apple ld and lld 23.1.2;init-offsets2fails on my machine with or without this change.