New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
linkage_checker: ignore broken linkage with LLVM libc++. #13833
Conversation
Review period will end on 2022-09-12 at 04:52:28 UTC. |
Library/Homebrew/linkage_checker.rb
Outdated
# this search procedure. If this succeeds, the formula is unlikely | ||
# to be broken. | ||
@system_dylibs << basename | ||
elsif (dep = dylib_to_dep(dylib)) | ||
@broken_deps[dep] |= [dylib] | ||
elsif MacOS.version >= :big_sur && dylib_found_via_dlopen(dylib) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part is still necessary, since System Frameworks typically cannot be found by their basename.
Library/Homebrew/linkage_checker.rb
Outdated
@@ -196,7 +196,14 @@ def check_dylibs(rebuild_cache:) | |||
rescue Errno::ENOENT | |||
next if harmless_broken_link?(dylib) | |||
|
|||
if (dep = dylib_to_dep(dylib)) | |||
basename = File.basename(dylib) | |||
if dylib_found_via_dlopen(basename) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing this first does change the output of brew linkage
slightly. System dylibs (e.g. libSystem.B.dylib
) will typically be reported with only their basename, but system frameworks (e.g. CoreServices
) need to be found via an absolute path so one will be reported.
This is probably more meaningful anyway, since these paths are no longer on-disk.
Review period ended. |
This makes sense for libc++ (if nothing was compiled with While yes dyld technically may work this way and the executable may "run", if something is (for example) linking to Homebrew curl but ends up using system curl, there could be problems later on and we will want to know about it, even if it's just for the automatic formula reinstall. I would be ok special casing this for libc++ at the moment though, as long as we note down which formulae are affected by it. |
Yea, I initially started with a special case for I'll switch it back. |
This linkage will be broken in LLVM 15, but this is typically harmless since dyld will load `/usr/lib/libc++.1.dylib` instead.
8eaa33b
to
957c2c9
Compare
dlopen
before reporting broken linkage.
Scoped this to only LLVM This will report no linkage with I'm punting on that since I'd like to get this in along with the tag for the Glibc fixes. |
In the long term, we'll phase out using LLVM's libc++ in our formulae. |
This should already be phased out in Homebrew/homebrew-core#106925. I'm just thinking of formulae in external taps that declare an LLVM dependency and inadvertently link with LLVM's |
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?When
dyld
is not able to find a library at its install name, itattempts to find it inside its default search path.
This means that for libraries we ship that are also provided by the
system (e.g.
libc++
),brew linkage
can fail even if the formulastill works (i.e.
brew test
succeeds).Given this, it makes sense to attempt to
dlopen
the library firstbefore deciding the linkage is broken. This will be useful when we ship
Homebrew/homebrew-core#106925, which will move the install location of
libc++
, causingbrew linkage
to fail for any formula that links withthat
libc++
.Those formulae that link with LLVM's
libc++
will fall back to Apple'slibc++
, which is why we see multiplebrew test
s succeed even whenbrew linkage
failed in the LLVM PR linked above.This change helps avoid unnecessary source rebuilds for formulae that
link with LLVM's
libc++
after LLVM 15 ships.