Skip to content
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

audit: forbid links to libBLAS and libLAPACK #6174

Closed
wants to merge 1 commit into from
Closed

audit: forbid links to libBLAS and libLAPACK #6174

wants to merge 1 commit into from

Conversation

jonchang
Copy link
Contributor

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew tests with your changes locally?

This pull request partially reverts #6168 to be stricter about the types of undesirable links into Accelerate.framework that we would like to forbid in core formulae.
This diff may be more useful for review purposes.

As outlined in #6130, we would generally like to avoid linking against system Accelerate for core tap formulae as it includes outdated BLAS routines that are being dropped by packages in favor of OpenBLAS.

However, as we discovered in #6168 there are many other non-BLAS routines in Accelerate that can and are used in formula, so the original implementation was too restrictive.

Although many formulae just link to the base Accelerate library (#6168 (comment)), I've found that it's possible for some build systems to do "deep links" into Accelerate. That is, occasionally you see formula linking specifically to e.g. libLAPACK.dylib, contrary to the earlier comment. This pull request checks for that case.

There is a more precise solution, which is to enumerate symbols exported from libLAPACK and libBLAS specifically and ensure that formula that link against Accelerate.framework aren't using those symbols. This would catch more improper links to Accelerate, but would also be a lot more effort and complexity and would likely also be more fragile. I'm ok with a higher false negative rate if it means easier maintenance.

@jonchang jonchang requested a review from zbeekman May 24, 2019 22:10
@jonchang jonchang self-assigned this May 24, 2019
@zbeekman
Copy link
Contributor

I'm ok with a higher false negative rate if it means easier maintenance.

Yes, in this case I'd much rather have false negatives than false positives.

dlls = obj.dynamically_linked_libraries
# libBLAS and libLAPACK are superseded by functions in OpenBLAS
# This can be linked via multiple paths, so use a wildcard match
dlls.any? { |dll| %r{^/System/Library/Frameworks/Accelerate.framework/.*/(libBLAS|libLAPACK).dylib$}.match dll }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@zbeekman zbeekman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I added some suggestions for the message that I think would be improvements, but you're welcome to take them or leave them.

@jonchang
Copy link
Contributor Author

Updated per review comments.

object files were linked against system Accelerate
These object files link against outdated BLAS/LAPACK routines provided
by the system Accelerate framework. Core tap formulae should link
against OpenBLAS instead. Removing `depends_on "veclibfort"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given we already have a separate audit for this I'm not sure what this check specifically is resolving for us. What's the actual problem users are experiencing that will be solved with this check?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • The original audit for accelerate linkage was rolled back in Allow Accelerate linkage, deny veclibfort & lapack #6168 and replaced with a check for dependencies on veclibfort and lapack.
  • Some build systems (e.g., python packages according to @jonchang) link directly against BLAS/LAPACK dylibs within the Accelerate framework
  • This audit is catching those cases.
  • The actual problem would be degraded performance, and occasional build bugs due to out of date BLAS/LAPACK implementation...

FWIW, I think this check probably has marginal benefits in practice, but may still be worth doing to prevent some confusion if we end up tripping over a subtle BLAS/LAPACK bug in a formula in the future due to the antiquated implementation in Accelerate.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(So I'm 👍 to 🚢 but won't be devastated if we don', FWIW)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would anyone object to holding on this for e.g. a few weeks and see if we feel like we need it then? I'd like to knowingly avoid more false positives at this point.

@MikeMcQuaid
Copy link
Member

Assuming this is 💀

@MikeMcQuaid MikeMcQuaid closed this Jul 1, 2019
@lock lock bot added the outdated PR was locked due to age label Jan 1, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Jan 1, 2020
@jonchang jonchang deleted the accelerate-v2 branch July 3, 2020 13:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants