linux/diagnostic: fix rpath returning nil.

Fixes #13762.

There's still a bug in the GCC linkage check, but I'll need a bit more
time to work on a fix. This at least makes sure `brew doctor` will not
return the error in the issue linked above.
This commit is contained in:
Carlo Cabrera 2022-08-26 22:23:02 +08:00
parent 7617109d43
commit ab696cbbb7
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0
2 changed files with 3 additions and 2 deletions

View File

@ -144,6 +144,7 @@ module Homebrew
gcc_dependents = Formula.installed.select do |formula| gcc_dependents = Formula.installed.select do |formula|
next false unless formula.tap&.core_tap? next false unless formula.tap&.core_tap?
# FIXME: This includes formulae that have no runtime dependency on GCC.
formula.recursive_dependencies.map(&:name).include? "gcc" formula.recursive_dependencies.map(&:name).include? "gcc"
rescue TapFormulaUnavailableError rescue TapFormulaUnavailableError
false false
@ -153,7 +154,7 @@ module Homebrew
badly_linked = gcc_dependents.select do |dependent| badly_linked = gcc_dependents.select do |dependent|
keg = Keg.new(dependent.prefix) keg = Keg.new(dependent.prefix)
keg.binary_executable_or_library_files.any? do |binary| keg.binary_executable_or_library_files.any? do |binary|
paths = binary.rpath.split(":") paths = binary.rpaths
versioned_linkage = paths.any? { |path| path.match?(%r{lib/gcc/\d+$}) } versioned_linkage = paths.any? { |path| path.match?(%r{lib/gcc/\d+$}) }
unversioned_linkage = paths.any? { |path| path.match?(%r{lib/gcc/current$}) } unversioned_linkage = paths.any? { |path| path.match?(%r{lib/gcc/current$}) }

View File

@ -97,7 +97,7 @@ module ELFShim
# An array of runtime search path entries, such as: # An array of runtime search path entries, such as:
# ["/lib", "/usr/lib", "/usr/local/lib"] # ["/lib", "/usr/lib", "/usr/local/lib"]
def rpaths def rpaths
rpath.split(":") rpath&.split(":").to_a
end end
def interpreter def interpreter