Fix problem with static link order with static clang and llvm #19272
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This resolves a problem on CentOS 7 which has an error like this:
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 (withllvm-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, likelibLLVM-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!