[HIPIFY][build][clang][fix] Make hipify-clang buildable with an LLVM configured to link libLLVM.so
#1840
+31
−20
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.
Without these changes, if building against an LLVM configured with
-DLLVM_LINK_LLVM_DYLIB=ON
, the resulting binary will have ODR violations resulting in the dread duplicate CL option registered errors at runtime.In order to work in this case, executables must be uniformly linked in the same way that LLVM binaries themselves are: by setting
LLVM_LINK_COMPONENTS
vs depending directly on the (static) individual libraries. This should work in all linking modes.Note that the problem originate because an LLVM configured in this way will configure any clang libraries to carry a transitive dep on libLLVM. Therefore, it is illegal to depend on clang (static) libraries and LLVM static libraries in combination.
There is a step further that could be taken to also support building against a shared libClang, but this is merely an optimization vs an error: since libClang is a leaf library, it is ok to depend on its static components. Perhaps total package size could be reduced by also supporting libClang, but this is left for the future.