linkage_checker: handle system libraries on Big Sur

This commit is contained in:
Bo Anderson 2020-06-24 16:24:39 +01:00
parent 176c85d42c
commit 9c4aaa9719

View File

@ -3,6 +3,7 @@
require "keg"
require "formula"
require "linkage_cache_store"
require "fiddle"
class LinkageChecker
attr_reader :undeclared_deps
@ -125,6 +126,11 @@ class LinkageChecker
if (dep = dylib_to_dep(dylib))
@broken_deps[dep] |= [dylib]
elsif MacOS.version >= :big_sur && dylib_found_via_dlopen(dylib)
# If we cannot associate the dylib with a dependency, then it may be a system library.
# In macOS Big Sur and later, system libraries do not exist on-disk and instead exist in a cache.
# If dlopen finds the dylib, then the linkage is not broken.
@system_dylibs << dylib
else
@broken_dylibs << dylib
end
@ -151,6 +157,13 @@ class LinkageChecker
end
alias generic_check_dylibs check_dylibs
def dylib_found_via_dlopen(dylib)
Fiddle.dlopen(dylib).close
true
rescue Fiddle::DLError
false
end
def check_formula_deps
filter_out = proc do |dep|
next true if dep.build?