Merge pull request #5894 from sjackman/macos-rpath

fix_dynamic_linkage: Check HOMEBREW_RELOCATE_METAVARS
This commit is contained in:
Shaun Jackman 2019-03-19 09:25:55 -07:00 committed by GitHub
commit 15495f0bde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -72,7 +72,8 @@ class Keg
# If none of the install names reference RPATH(s), then we can safely
# remove all RPATHs from the file.
if file.dynamically_linked_libraries.none? { |lib| lib.start_with?("@rpath") }
if ENV["HOMEBREW_RELOCATE_METAVARS"] &&
file.dynamically_linked_libraries.none? { |lib| lib.start_with?("@rpath") }
# Note: This could probably be made more efficient by reverse-sorting
# the RPATHs by offset and calling MachOFile#delete_command
# with repopulate: false.
@ -120,6 +121,7 @@ class Keg
def each_install_name_for(file, &block)
dylibs = file.dynamically_linked_libraries
dylibs.reject! { |fn| fn =~ /^@(loader|executable)_path/ }
dylibs.reject! { |fn| fn =~ /^@rpath/ } unless ENV["HOMEBREW_RELOCATE_METAVARS"]
dylibs.each(&block)
end