undefined references for common_clang.o with opencl-clang 10.0.0-2
- Dominant language
- C
- Stars
- 140
- Forks
- 92
- Avg merge
- 8h 2m
- Merged PRs (30d)
- 7
Description
I'm trying to build `opencl-clang` 10.0.0-2 on top of Clang 10.0.0 (in the context of getting https://github.com/intel/compute-runtime/releases/tag/20.25.17111 built from source), and I'm running into this problem:
```
[ 97%] Linking CXX shared library libopencl-clang.so
/software/CMake/3.16.4-GCCcore-9.3.0/bin/cmake -E cmake_link_script CMakeFiles/opencl-clang.dir/link.txt --verbose=1
/software/GCCcore/9.3.0/bin/g++ -fPIC -O2 -ftree-vectorize -march=native -fno-math-errno -O3 -DNDEBUG -Wl,-O3 -Wl,--gc-sections -Wl,--no-undefined -Wl,-Bsymbolic -Wl,--version-script=/tmp/openclclang/10.0.0-2/GCCcore-9.3.0/opencl-clang-10.0.0-2/common_clang.map -L/software/libxml2/2.9.10-GCCcore-9.3.0/lib -L/software/Clang/10.0.0-GCCcore-9.3.0/lib -L/software/SPIRV-LLVM-Translator/10.0.0-GCCcore-9.3.0-20200527/lib -L/software/binutils/2.34-GCCcore-9.3.0/lib -L/software/GCCcore/9.3.0/lib64 -L/software/GCCcore/9.3.0/lib -shared -Wl,-soname,libopencl-clang.so.10 -o libopencl-clang.so.10 CMakeFiles/opencl-clang.dir/common_clang.cpp.o CMakeFiles/opencl-clang.dir/options.cpp.o
CMakeFiles/opencl-clang.dir/pch_mgr.cpp.o CMakeFiles/opencl-clang.dir/options_compile.cpp.o cl_headers/CMakeFiles/cl_headers.dir/opencl-c.h.cpp.o cl_headers/CMakeFiles/cl_headers.dir/opencl-c-base.h.cpp.o cl_headers/CMakeFiles/cl_headers.dir/opencl-c-12-spir.mod.cpp.o cl_headers/CMakeFiles/cl_headers.dir/opencl-c-20-spir.mod.cpp.o cl_headers/CMakeFiles/cl_headers.dir/opencl-c-12-spir64.mod.cpp.o cl_headers/CMakeFiles/cl_headers.dir/opencl-c-20-spir64.mod.cpp.o cl_headers/CMakeFiles/cl_headers.dir/opencl-c-12-spir-fp64.mod.cpp.o cl_headers/CMakeFiles/cl_headers.dir/opencl-c-20-spir-fp64.mod.cpp.o cl_headers/CMakeFiles/cl_headers.dir/opencl-c-12-spir64-fp64.mod.cpp.o cl_headers/CMakeFiles/cl_headers.dir/opencl-c-20-spir64-fp64.mod.cpp.o cl_headers/CMakeFiles/cl_headers.dir/module.modulemap.cpp.o -Wl,-rpath,"\$ORIGIN/../lib:/software/Clang/10.0.0-GCCcore-9.3.0/lib" -ldl -lLLVMSPIRVLib -lclang-cpp
CMakeFiles/opencl-clang.dir/common_clang.cpp.o:common_clang.cpp:function CommonClangInitialize(): error: undefined reference to 'LLVMInitializeX86TargetInfo'
CMakeFiles/opencl-clang.dir/common_clang.cpp.o:common_clang.cpp:function CommonClangInitialize(): error: undefined reference to 'LLVMInitializeX86Target'
CMakeFiles/opencl-clang.dir/common_clang.cpp.o:common_clang.cpp:function CommonClangInitialize(): error: undefined reference to 'LLVMInitializeX86AsmPrinter'
CMakeFiles/opencl-clang.dir/common_clang.cpp.o:common_clang.cpp:function CommonClangInitialize(): error: undefined reference to 'LLVMInitializeX86AsmParser'
CMakeFiles/opencl-clang.dir/common_clang.cpp.o:common_clang.cpp:function CommonClangInitialize(): error: undefined reference to 'LLVMInitializeX86TargetMC'
collect2: error: ld returned 1 exit status
make[2]: *** [libopencl-clang.so.10] Error 1
```
I'm also building Clang 10.0.0 from source myself, so it's possible the `-lclang-cpp` being linked with isn't what `opencl-clang` expects it to be...
I have specified the location to the Clang/LLVM installation via `-DLLVM_DIR` as is [explained in the README](https://github.com/intel/opencl-clang#custom-llvm-installation), so I'm fairly sure that's not the problem here...
Any suggestions on what may be wrong here?
Contributor guide
Research direction
Start with common_clang.cpp and the verbose CMake link command shown in the report, then inspect how LLVM_DIR selects the Clang/LLVM installation and how -lclang-cpp is resolved. Done means the opencl-clang build links libopencl-clang.so without the reported undefined X86 initialization references.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100