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

Fix problem with static link order with static clang and llvm #19272

Merged
merged 1 commit into from
Feb 22, 2022

Conversation

mppf
Copy link
Member

@mppf mppf commented Feb 18, 2022

This resolves a problem on CentOS 7 which has an error like this:

: CommandLine Error: Option 'enable-vfe' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options

We have some evidence that this error was caused by statically linking LLVM libraries but dynamically linking clang-cpp. For one thing, on that system, changing to statically linking both solved this issue.

This PR changes chpl_llvm.py to ask llvm-config if it has shared libraries available (with llvm-config --shared-mode) and if not it will use the static linking approach for both the LLVM and clang dependencies.

Additionally, when using static linking for LLVM and clang, on CentOS 7, the linker was picky about the order. Since the link line should have the things depended upon later, this PR puts the -l flags for clang libraries before the -l flags for LLVM libraries. On Mac OS X with Homebrew LLVM, we were using the same (arguably incorrect) -l ordering but for some reason the linker there did not complain.

Note that we statically link both LLVM and clang on Mac OS X (since PR #18727). This PR leaves it this way. Historically, there have been problems with upstream LLVM and Homebrew in building a dynamic library that works with llvm-config (in particular the versioned file, like libLLVM-11.dylib, is missing). See this LLVM bug report. I expect that we will be able to allow dynamic linking on Mac OS X once we are able to establish that the issue is resolved.

We are statically linking with CHPL_LLVM=bundled and this PR does not change that.

Reviewed by @Maxrimus - thanks!

  • 'hello' builds and runs with system LLVM on Ubuntu 21
  • 'hello' builds and runs with system LLVM on SLES 12
  • 'hello' builds and runs with system LLVM on Mac OS X with Homebrew
  • 'hello' builds and runs with bundled LLVM on Ubuntu 21
  • full local testing

---
Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
@mppf mppf requested a review from Maxrimus February 18, 2022 15:51
Copy link
Contributor

@Maxrimus Maxrimus left a comment

Choose a reason for hiding this comment

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

LGTM

@Maxrimus
Copy link
Contributor

Got a success of the python-modules job running on this branch

@mppf mppf merged commit 9e8e6a2 into chapel-lang:main Feb 22, 2022
@mppf mppf deleted the fix-clang-static branch February 22, 2022 17:54
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.

2 participants