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

Add macOS libs ahead of brewed llvm libs in lib search path #3840

Merged
merged 4 commits into from
Mar 7, 2018

Conversation

ts826848
Copy link
Contributor

@ts826848 ts826848 commented Feb 27, 2018

  • 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 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...

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++)
@@ -176,6 +176,8 @@ def determine_library_paths
PATH.new(
keg_only_deps.map(&:opt_lib),
HOMEBREW_PREFIX/"lib",
"#{MacOS.sdk_path}/usr/lib",
Copy link
Member

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?

Copy link
Member

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.

Copy link
Contributor

@ilovezfs ilovezfs Feb 27, 2018

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"

Copy link
Contributor

@ilovezfs ilovezfs Feb 27, 2018

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.

Copy link
Contributor Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

CLT

Copy link
Member

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?

Copy link
Contributor Author

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.

@@ -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 : ""),
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

Choose a reason for hiding this comment

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

Correct, thanks.

@ilovezfs
Copy link
Contributor

@aw1621107 if the goal is primarily to be able to use llvm's libomp.dylib, it may be sufficient to

depends_on "libomp"

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?

@ts826848
Copy link
Contributor Author

@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.

@MikeMcQuaid
Copy link
Member

@aw1621107 Out of interest: do you have any use for llvm_clang except OpenMP?

@ts826848
Copy link
Contributor Author

@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 <optional>, even with -std=c++1z, but I don't know how many formulae actually use it.

@fxcoudert
Copy link
Member

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.

@MikeMcQuaid
Copy link
Member

@aw1621107 Made some tweaks. Thanks again!

@MikeMcQuaid MikeMcQuaid merged commit eee6e98 into Homebrew:master Mar 7, 2018
@Homebrew Homebrew locked and limited conversation to collaborators May 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants