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

Dynamic linking to LLVM8 doesn't work #170

Open
dextorious opened this issue Jun 21, 2019 · 2 comments
Open

Dynamic linking to LLVM8 doesn't work #170

dextorious opened this issue Jun 21, 2019 · 2 comments

Comments

@dextorious
Copy link

Following the workaround given in #164 I changed the CMakeLists.txt file on the latest master commit of Oclgrind to link to LLVM dynamically on Manjaro Linux (which is basically Arch). Unfortunately, it doesn't compile:

[  9%] Built target OPENCL_C_HEADERS
[ 47%] Built target oclgrind
[ 52%] Built target oclgrind-rt-icd
[ 58%] Built target oclgrind-rt
[ 61%] Built target oclgrind-exe
[ 63%] Linking CXX executable oclgrind-kernel
/usr/bin/ld: CMakeFiles/oclgrind-kernel.dir/src/kernel/Simulation.cpp.o: undefined reference to symbol '_ZN4llvm24DisableABIBreakingChecksE@@LLVM_8'
/usr/bin/ld: /usr/lib/libLLVM-8.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/oclgrind-kernel.dir/build.make:100: oclgrind-kernel] Error 1
make[1]: *** [CMakeFiles/Makefile2:290: CMakeFiles/oclgrind-kernel.dir/all] Error 2
make: *** [Makefile:163: all] Error 2

Is there any reasonable workaround for this, or is it a case of ABI incompatibility that needs to be addressed?

@jrprice
Copy link
Owner

jrprice commented Oct 27, 2019

Apologies for the delay - finally had a chance to look at this today.

To fix this we need to make LLVM part of the the PUBLIC interface in CMake, so that LLVM gets linked into the executables as well. Here's the patch I used to get this building on a Manjaro Docker image:

index df4323d..41815e1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -216,8 +216,9 @@ add_library(oclgrind ${CORE_LIB_TYPE}
 target_link_libraries(oclgrind PRIVATE ${CORE_EXTRA_LIBS}
   clangCodeGen clangFrontend clangSerialization clangDriver
   clangParse clangSema clangAnalysis clangEdit clangAST clangASTMatchers
-  clangLex clangBasic
-  ${LLVM_LIBS})
+  clangLex clangBasic)
+
+target_link_libraries(oclgrind PUBLIC LLVM)
 
 if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
   target_link_libraries(oclgrind PRIVATE Version)```

@robstewart57
Copy link

@jrprice I was also affected by #164 (comment) .

Linux, Fedora 31.

This change fixed it for me also:

-  clangLex clangBasic
-  ${LLVM_LIBS})
+  clangLex clangBasic)
+
+target_link_libraries(oclgrind PUBLIC LLVM)

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

No branches or pull requests

3 participants