-
-
Notifications
You must be signed in to change notification settings - Fork 10k
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
Add macOS libs ahead of brewed llvm libs in lib search path #3840
Conversation
This ensures that libraries that are built with brewed LLVM but not included in the Command Line Tools/Xcode (e.g. libomp) can be found during a build, while still using system libraries for the essential stuff (e.g. libc++)
Library/Homebrew/extend/ENV/super.rb
Outdated
@@ -176,6 +176,8 @@ def determine_library_paths | |||
PATH.new( | |||
keg_only_deps.map(&:opt_lib), | |||
HOMEBREW_PREFIX/"lib", | |||
"#{MacOS.sdk_path}/usr/lib", |
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.
Are you 100% sure adding this isn't going to affect any other builds in any other way?
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.
Actually regardless: only do this on llvm_clang
being the compiler; it's not worth the risk.
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.
I think if CLT is installed we want "/usr/lib"
not "#{MacOS.sdk_path}/usr/lib"
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.
Also, I'm not sure what happens if we do that and have also set
ENV["SDKROOT"] = MacOS.sdk_path
in a formula, whether they're going to be competing with each other.
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.
@ilovezfs If both CLT and Xcode are installed, which should be preferred?
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.
CLT
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.
Isn't MacOS.sdk_path
empty or /
on CLT anyway?
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.
I just ended up splitting it into another if/else. Don't know if the nesting will be an issue.
Library/Homebrew/extend/ENV/super.rb
Outdated
@@ -176,6 +176,8 @@ def determine_library_paths | |||
PATH.new( | |||
keg_only_deps.map(&:opt_lib), | |||
HOMEBREW_PREFIX/"lib", | |||
"#{MacOS.sdk_path}/usr/lib", | |||
(compiler == :llvm_clang ? Formula["llvm"].opt_lib.to_s : ""), |
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.
Don't use a ternary here; split out this logic by building the PATH
differently.
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.
I'm guessing that a ternary also shouldn't be used for separate CLT/Xcode SDK include paths?
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.
Correct, thanks.
@aw1621107 if the goal is primarily to be able to use llvm's libomp.dylib, it may be sufficient to
if we merge Homebrew/homebrew-core#20589. Or is there some additional benefit/reason to actually build with llvm_clang at the same time as using libomp.dylib? |
@ilovezfs I'm not aware of a reason to require llvm_clang, but I'm not really familiar with OpenMP and if it requires the same version of the compiler/dylib. I figured that this might be more straightforward for users, since OpenMP support would be pretty much "invisible" in terms of special requirements, beyond using brew's llvm instead of Apple's. |
@aw1621107 Out of interest: do you have any use for |
@MikeMcQuaid Not yet, at least. I haven't had a need for OpenMP, but there's a chance that could change with one of the projects I'm looking into. In the past I also used it to try building formulae with LTO, since Apple's compiler didn't support it at the time, but I'd guess that that's not a use case that you guys are worried about, especially since Apple's Clang now supports LTO. My last guess would be for formulae which provide an option to build with the really new C++ language/library features, but I can't think of any that actually provide such an option. I know Apple's Clang is missing |
Regarding libomp specifically: I'm wary of using libomp from one version of upstream's llvm, with Apple's different version of clang. It might be tricky ABI incompatibility, and I have not found any definite statement on ABI compatibility between versions. I also don't know of any project actually using this and having done serious testing, so we would need to triple-check on an extensive testsuite before we use it for OpenMP support in our formulas. |
@aw1621107 Made some tweaks. Thanks again! |
brew style
with your changes locally?brew tests
with your changes locally?This ensures that libraries that are built with brewed LLVM but not
included in the Command Line Tools/Xcode (e.g. libomp) can be found
during a build, while still using system libraries for the essential
stuff (e.g. libc++)
Sorry it took me so long. Given how short this change is, I'm not sure why I haven't done this ages ago...
This should finally resolve homebrew-core/pull/10456 and #2234, and hopefully we can start using clang for OpenMP stuff too. Just got Fortran left...