Skip to content
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

keg_relocate: add HOMEBREW_PREFIX/lib to rpaths #15721

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions Library/Homebrew/extend/os/mac/keg_relocate.rb
Expand Up @@ -73,6 +73,12 @@ def fix_dynamic_linkage
end
end
end

next if HOMEBREW_PREFIX.to_s == "/usr/local"
next if file.rpaths.include?("#{HOMEBREW_PREFIX}/lib")

loader_name = loader_name_for(file, "#{HOMEBREW_PREFIX}/lib")
add_rpath(loader_name, file)
end
end

Expand Down
12 changes: 12 additions & 0 deletions Library/Homebrew/os/mac/keg.rb
Expand Up @@ -50,6 +50,18 @@
raise
end

def add_rpath(rpath, file)
@require_relocation = rpath.start_with?(HOMEBREW_PREFIX.to_s)
odebug "Adding rpath #{rpath} in #{file}"
file.add_rpath(rpath, strict: false)
codesign_patched_binary(file)
rescue MachO::MachOError
onoe <<~EOS

Check warning on line 59 in Library/Homebrew/os/mac/keg.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/os/mac/keg.rb#L59

Added line #L59 was not covered by tests
Failed adding rpath #{rpath} in #{file}
EOS
raise

Check warning on line 62 in Library/Homebrew/os/mac/keg.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/os/mac/keg.rb#L62

Added line #L62 was not covered by tests
end

def delete_rpath(rpath, file)
odebug "Deleting rpath #{rpath} in #{file}"
file.delete_rpath(rpath, strict: false)
Expand Down
5 changes: 5 additions & 0 deletions Library/Homebrew/os/mac/mach.rb
Expand Up @@ -59,6 +59,11 @@ def mach_data

# TODO: See if the `#write!` call can be delayed until
# we know we're not making any changes to the rpaths.
def add_rpath(rpath, **options)
macho.add_rpath(rpath, options)
macho.write!
end

def delete_rpath(rpath, **options)
macho.delete_rpath(rpath, options)
macho.write!
Expand Down