-
-
Notifications
You must be signed in to change notification settings - Fork 36
Delete rpaths one at a time #362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The alternative to this is probably to be more like |
Yeah, I'm of two minds on this:
Overall, I'm inclined to say that |
Another idea: I'm not opposed to a |
Either of those is fine, but I think if rpaths are presented as they are contained in the parsed Mach-O, then they should probably also be acted on in the way they are presented. i.e. Said differently, if |
Yep, fully agree. What do you think about this?
|
Makes sense to me! I think this brings things closer in line with How do we want to do There might also be room here for an extra command: |
Yeah, changing dupes one at a time sounds good to me 🙂
Absolutely! |
Sounds good to me. I think all this can be done in three steps:
I'll rework this PR to do the first step. |
New commit pushed. Not sure how much we want to change the test for rpath deletion here. |
Hmm, perhaps unroll the loop, and assert that the count is what we expect at each step? |
Tweaked the test a bit. |
Awesome. I'll take a look tonight. |
lib/macho/macho_file.rb
Outdated
@@ -419,7 +419,7 @@ def delete_rpath(path, _options = {}) | |||
raise RpathUnknownError, path if rpath_cmds.empty? | |||
|
|||
# delete the commands in reverse order, offset descending. | |||
rpath_cmds.reverse_each { |cmd| delete_command(cmd) } | |||
delete_command(rpath_cmds.last) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, now that we're only deleting one at a time, maybe we should delete the first instead of the last (since that's what I suspect install_name_tool
does).
That in turn makes everything a little more efficient, since we can switch from #select
to #find
for finding the first RPATH. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, makes sense to me. Let me fix that up.
This aligns `ruby-macho`'s behaviour more closely with `install_name_tool`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! LGTM.
Continuation of Homebrew#362.
Continuation of Homebrew#362.
Continuation of Homebrew#362.
Continuation of Homebrew#362.
Since
delete_rpath
differs from the behaviour ofotool
in thatduplicate rpaths are deleted in a single invocation, we should be
consistent with that and not report duplicates even when they exist.
Otherwise, this can break workflows that iterate through a macho-o
file's rpaths and does something with each of them. I currently have a
workaround for this in brew [1], but I realised this should actually
probably be fixed here.
[1] Homebrew/brew#11392