From 59ee097f8d3dc60f1aa543a74b99da2e18ee66ac Mon Sep 17 00:00:00 2001 From: Shaun Jackman Date: Tue, 19 Mar 2019 07:40:27 -0700 Subject: [PATCH] fix_dynamic_linkage: Check HOMEBREW_RELOCATE_METAVARS Only remove RPATH when HOMEBREW_RELOCATE_METAVARS is set. See PR https://github.com/Homebrew/brew/pull/5413 --- Library/Homebrew/extend/os/mac/keg_relocate.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/extend/os/mac/keg_relocate.rb b/Library/Homebrew/extend/os/mac/keg_relocate.rb index 5139d2494a..8fed56b88e 100644 --- a/Library/Homebrew/extend/os/mac/keg_relocate.rb +++ b/Library/Homebrew/extend/os/mac/keg_relocate.rb @@ -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