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

Use llvm-config to fix link error if llvm is pre-built locally static or shared #492

Closed
wants to merge 27 commits into from

Conversation

wenju-he
Copy link
Contributor

@wenju-he wenju-he commented Oct 7, 2023

llvm_map_components_to_libnames is empty in these cases.
This fixes link error in Ubuntu 22.04 container. #484 and #454

(cherry picked from commit 1cde56c)
(cherry picked from commit 7b62fd8)

haonanya1 and others added 26 commits March 13, 2023 18:05
* [NFC] Improve for options_compile.cpp

1. Check return value for consume_front function
2. Pass by reference to avoid copy StringRef

* Apply suggestions
…OR}/ (intel#419)

Fedora places llvm include files into that directory instead of assumed
${LLVM_LIBRARY_DIRS}/clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}/include/

Try both, fail horribly when none of them exist
…set (intel#413)

* Works around windows x86 build if CMAKE_SIZEOF_VOID_P is not set

Determine windows binary suffix via LLVM_BUILD_32_BITS in windows x86
if CMAKE_SIZEOF_VOID_P is not set

* Apply suggestions
Cherry-pick commit 78c5e3f from `ocl-open-140` branch. Omit the Clang patch
addition, as https://reviews.llvm.org/D141297 is part of LLVM 16.

Signed-off-by: Artem Gindinson <artem.gindinson@intel.com>
…el#438)

Add cmake option EXCLUDE_LIBS_FROM_ALL to remove a specific llvm library
from llvm 'all'.

This PR partially reverts 743bd15.
This PR addresses intel#401, intel#417, intel#418, intel#422, and brings back SONAME.
cmake macro doesn't create new scope, so it is wrong to set PARENT_SCOPE
for CMAKE_CXX_FLAGS.
In addition, in out-of-tree build, the parent scope doesn't exist and
there is cmake warning.
llvm-related variable initialization, clang::ExecuteCompilerInvocation
and llvm-spirv aren't thread safe, at least for 90 branch.

(cherry picked from commit 76bc7f9)
The issue in 53b8f12 isn't observed on linux.
This allows parallel execution of clang::ExecuteCompilerInvocation and
parallel execution of llvm::writeSpirv.
This improves performance of multi-threaded OpenCL tests on linux.

(cherry picked from commit cf95b33)
* Request native clang only when cross-compiling

LLVM_USE_HOST_TOOLS may be set if LLVM is configured with
LLVM_OPTIMIZED_TABLEGEN, which does not necessarily indicate
cross-compilation or that clang will only execute on the target.

By checking that CMAKE_CROSSCOMPILING is set, we ensure that we only
build/use clang again if necessary for host execution.

* fixup: CMAKE_CROSSCOMPILING implies LLVM_USE_HOST_TOOLS

Co-authored-by: Wenju He <wenju.he@intel.com>

* fixup: also use CMAKE_CROSSCOMPILING in top-level CMakeLists.txt

---------

Co-authored-by: Wenju He <wenju.he@intel.com>
opencl-clang only uses clang libraries to generate frontend IR and
explicitly disables llvm optimizations. In addition, opencl-clang
doesn't parse/print assembly.
Therefore, there is no need to initialize llvm target machines, target
MCs, asm printers and asm parsers

This PR removes opencl-clang's dependency on some llvm libraries.
…l#471)

When opencl-clang is used in-tree of a project, these two variables may
be defined in CMakeLists.txt of the project. This PR makes the variable
names clear that they are intended for opencl-clang library and easily
distinguishable from other variables in CMakeLists.txt of the project.
Other dependent clang libraries, e.g. those clangFrontendTool depends,
will be automatically added by cmake.
The following link error occurs in downstream after 1bda00e:

```
ld: error: undefined symbol: clang::PCHContainerOperations::PCHContainerOperations()
>>> referenced by opencl_clang.cpp
>>>               _deps/opencl-clang-build/CMakeFiles/common_clang.dir/opencl_clang.cpp.o:(Compile)
icpx: error: linker command failed with exit code 1 (use -v to see invocation)
```

This is similar to the link error seen in
https://reviews.llvm.org/D157078, which was resolved in the same way
(https://reviews.llvm.org/rG36daf3532d91bb3e61d631edceea77ebb8417801).

This patch just adds 'clangSerialization' to the link libraries to
resolve the issue.
Not report undefined symbols when in sanitizer build, sanitizers do not support this flag. With this flag, it will lead to linker errors when trying to build with sanitizers.
Before this PR this build options is ignored by opencl-clang.
@wenju-he wenju-he requested review from cdai2 and haonanya October 7, 2023 08:39
@wenju-he wenju-he changed the title Fix link error if llvm is pre-built locally static or shared Use llvm-config to fix link error if llvm is pre-built locally static or shared Oct 7, 2023
… or shared

llvm_map_components_to_libnames is empty in these cases.
This fixes link error in Ubuntu 22.04 container. intel#484 and intel#454
@wenju-he wenju-he closed this Oct 7, 2023
@wenju-he wenju-he deleted the llvm-config branch October 8, 2023 00:32
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.

9 participants