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

Link chpl with the same libc++ that built the Homebrew LLVM #19445

Merged
merged 3 commits into from Mar 15, 2022

Conversation

mppf
Copy link
Member

@mppf mppf commented Mar 14, 2022

Resolves #19217

This PR adds a workaround to solve #19217. The problem we were seeing is that the Homebrew LLVM is built with one C++ standard library, but it includes a different version of a C++ standard library that our include and link paths were picking up. This can be detected with comparing output of otool -L chpl vs otool -l libLLVM.dylib (with appropriate paths).

To fix it, this PR adjusts chpl_llvm.py to:

  • compute the sdk used when building the llvm/clang Homebrew package. The current strategy is to find the DEFAULT_SYSROOT define from clang/Config/config.h. This strategy relies on the Homebrew formula passing -DDEFAULT_SYSROOT=#{macos_sdk} when cmake'ing llvm and clang. The main alternative strategy that I know of for this is more complex and relies on running both otool and xcrun.
  • Put -I and -L paths based on this sdk first in the system compile options so that we find the sdk libc++ rather than one from the Homebrew package

While there, I fixed some problems in error reporting when checking an llvm-config.

Reviewed by @ronawho - thanks!

Testing:

  • thanks to @ronawho and @aconsroe-hpe for helping test some of these configs
  • full local testing
  • Ubuntu 21.10 system still works with system LLVM
  • Ubuntu 21.10 system with homebrew works with homebrew llvm@12
  • Monterey (12.2) ARM Mac with llvm@11, llvm@12, and llvm@13
  • Monterey (12.2) x86 Mac with llvm@11, llvm@12, and llvm@13
  • Big Sur (11.6) x86 Mac with llvm@12 and llvm@13
  • Catalina (10.15.7) x86 Mac with llvm@11, llvm@12, and llvm@13
  • some of the above Mac systems have xcode and some only have command line tools

---
Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
---
Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
---
Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
@mppf mppf mentioned this pull request Mar 14, 2022
@mppf mppf merged commit 4bd353c into chapel-lang:main Mar 15, 2022
@mppf mppf deleted the address-19217 branch March 15, 2022 14:20
mppf added a commit to mppf/chapel that referenced this pull request Mar 18, 2022
The environment variable enables the workaround from PR chapel-lang#19445
since that isn't coming up during the homebrew chapel formula build.

---
Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
mppf added a commit that referenced this pull request Mar 21, 2022
Minor build/printchplenv adjustments to support Homebrew

This PR fixes two problems I ran into when trying to get a linuxbrew
build of Chapel 1.26 working and one problem with trying the Homebrew (on
Mac OS X) formula

* don't `make -j` in gen_release to build the docs
  * this originated in #2709, potentially inadvertently
  * unbounded `make -j` can run out of memory
* allow `CHPL_LLVM_GCC_PREFIX` to be set in `chplconfig` and allow it to
  be set to `none`
  * so that the linuxbrew formula can leave out the `--gcc-toolchain`
    flag since it should not be necessary there
* Add `CHPL_HOST_USE_SYSTEM_LIBCXX` environment variable to enable the
  workaround from PR #19445. This environment variable is necessary
  (instead of just detecting the existence of `brew`) because otherwise
  the workaround is not applied when building the `chapel` formula
  itself.

Reviewed by @e-kayrakli, @tzinsky and @ronawho - thanks!

- [x] full local testing
- [x] hello works on Mac OS X with Homebrew LLVM 13
- [x] draft homebrew formula succeeds on Mac OS X
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

llvm@12 issues on mac
2 participants