[WIP] mac/keg_relocate: Emulate dylinker behavior
Instead of assuming that #{lib} is the correct RPATH expansion,
test all RPATHS and substitute the first one that works.
This commit is contained in:
parent
618c5cd01a
commit
27d6cfb12e
@ -75,6 +75,20 @@ class Keg
|
|||||||
generic_fix_dynamic_linkage
|
generic_fix_dynamic_linkage
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def expand_rpath(file, bad_name)
|
||||||
|
suffix = bad_name.sub(/^@rpath/, "")
|
||||||
|
|
||||||
|
# short circuit: we expect lib to be usually correct, so we try it first
|
||||||
|
return (lib + suffix) if (lib + suffix).exist?
|
||||||
|
|
||||||
|
file.rpaths.each do |rpath|
|
||||||
|
return (rpath + suffix) if (rpath + suffix).exist?
|
||||||
|
end
|
||||||
|
|
||||||
|
opoo "Could not expand an RPATH in #{file}"
|
||||||
|
bad_name
|
||||||
|
end
|
||||||
|
|
||||||
# If file is a dylib or bundle itself, look for the dylib named by
|
# If file is a dylib or bundle itself, look for the dylib named by
|
||||||
# bad_name relative to the lib directory, so that we can skip the more
|
# bad_name relative to the lib directory, so that we can skip the more
|
||||||
# expensive recursive search if possible.
|
# expensive recursive search if possible.
|
||||||
@ -88,7 +102,7 @@ class Keg
|
|||||||
elsif file.mach_o_executable? && (lib + bad_name).exist?
|
elsif file.mach_o_executable? && (lib + bad_name).exist?
|
||||||
"#{lib}/#{bad_name}"
|
"#{lib}/#{bad_name}"
|
||||||
elsif bad_name.start_with? "@rpath"
|
elsif bad_name.start_with? "@rpath"
|
||||||
bad_name.sub("@rpath", lib)
|
expand_rpath bad_name
|
||||||
elsif (abs_name = find_dylib(bad_name)) && abs_name.exist?
|
elsif (abs_name = find_dylib(bad_name)) && abs_name.exist?
|
||||||
abs_name.to_s
|
abs_name.to_s
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user