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

Providing -DOpenCL_LIBRARY=path/to/libOpenCL.so results in a compilation error #734

Closed
pvelesko opened this issue Dec 21, 2023 · 7 comments · Fixed by #738
Closed

Providing -DOpenCL_LIBRARY=path/to/libOpenCL.so results in a compilation error #734

pvelesko opened this issue Dec 21, 2023 · 7 comments · Fixed by #738
Labels
opencl Issues affecting only the OpenCL backend
Milestone

Comments

@pvelesko
Copy link
Collaborator

[ 65%] Linking CXX shared library libCHIP.so
/usr/bin/cmake -E cmake_link_script CMakeFiles/CHIP.dir/link.txt --verbose=1
/space/pvelesko/install/llvm/17.0/bin/clang++ -fPIC  -Wno-duplicate-decl-specifier -Wno-tautological-constant-compare  -Wno-c++20-extensions -Wno-unused-result -Wno-delete-abstract-non-virtual-dtor -Wno-deprecated-declarations -Wunused-command-line-argument -O3 -DNDEBUG -Wl,-rpath, -shared -Wl,-soname,libCHIP.so -o libCHIP.so CMakeFiles/CHIP.dir/src/spirv.cc.o CMakeFiles/CHIP.dir/src/spirv_hiprtc.cc.o CMakeFiles/CHIP.dir/src/CHIPDriver.cc.o CMakeFiles/CHIP.dir/src/CHIPBackend.cc.o CMakeFiles/CHIP.dir/src/SPVRegister.cc.o CMakeFiles/CHIP.dir/src/CHIPGraph.cc.o CMakeFiles/CHIP.dir/src/CHIPBindings.cc.o CMakeFiles/CHIP.dir/src/logging.cc.o CMakeFiles/CHIP.dir/src/Utils.cc.o CMakeFiles/CHIP.dir/src/SPIRVFuncInfo.cc.o CMakeFiles/CHIP.dir/src/backend/OpenCL/CHIPBackendOpenCL.cc.o CMakeFiles/CHIP.dir/src/backend/OpenCL/SVMemoryRegion.cc.o bitcode/CMakeFiles/rtdevlib.dir/atomicAddFloat_native.cc.o bitcode/CMakeFiles/rtdevlib.dir/atomicAddFloat_emulation.cc.o bitcode/CMakeFiles/rtdevlib.dir/atomicAddDouble_native.cc.o bitcode/CMakeFiles/rtdevlib.dir/atomicAddDouble_emulation.cc.o bitcode/CMakeFiles/rtdevlib.dir/ballot_native.cc.o  /lib/x86_64-linux-gnu/libOpenCL.so.1 -lOpenCL
/usr/bin/ld: input file 'libCHIP.so' is the same as output file
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
@pvelesko
Copy link
Collaborator Author

-Wl,-soname,libCHIP.so -o libCHIP.so

@pvelesko
Copy link
Collaborator Author

Also, .so.0.0 etc are not accepted

@linehill
Copy link
Collaborator

rpath option looks broken: ... -Wl,-rpath, .... It is missing a path. Would it compile if it were removed?

@pvelesko
Copy link
Collaborator Author

leads to other errors down the path

@pjaaskel pjaaskel added this to the 1.1 milestone Dec 21, 2023
@pjaaskel pjaaskel added the opencl Issues affecting only the OpenCL backend label Dec 21, 2023
@linehill
Copy link
Collaborator

I get compile error too with -DOpenCL_LIBRARY:

[ 63%] Linking CXX shared library libCHIP.so
/home/linehill/.local/lib/python3.10/site-packages/cmake/data/bin/cmake -E cmake_link_script CMakeFiles/CHIP.dir/link.txt --verbose=1
/mnt/md1/linehill/ws-chipstar-2/install/bin/clang++ -fPIC  -Wno-duplicate-decl-specifier -Wno-tautological-constant-compare  -Wno-c++20-extensions -Wno-unused-result -Wno-delete-abstract-non-virtual-dtor -Wno-deprecated-declarations -Wunused-command-line-argument -g -Wl,-rpath, -Wl,-rpath,/usr/lib/x86_64-linux-gnu -shared -Wl,-soname,libCHIP.so -o libCHIP.so CMakeFiles/CHIP.dir/src/spirv.cc.o CMakeFiles/CHIP.dir/src/spirv_hiprtc.cc.o CMakeFiles/CHIP.dir/src/CHIPDriver.cc.o CMakeFiles/CHIP.dir/src/CHIPBackend.cc.o CMakeFiles/CHIP.dir/src/SPVRegister.cc.o CMakeFiles/CHIP.dir/src/CHIPGraph.cc.o CMakeFiles/CHIP.dir/src/CHIPBindings.cc.o CMakeFiles/CHIP.dir/src/logging.cc.o CMakeFiles/CHIP.dir/src/Utils.cc.o CMakeFiles/CHIP.dir/src/SPIRVFuncInfo.cc.o CMakeFiles/CHIP.dir/src/backend/OpenCL/CHIPBackendOpenCL.cc.o CMakeFiles/CHIP.dir/src/backend/OpenCL/SVMemoryRegion.cc.o CMakeFiles/CHIP.dir/src/backend/Level0/CHIPBackendLevel0.cc.o bitcode/CMakeFiles/rtdevlib.dir/atomicAddFloat_native.cc.o bitcode/CMakeFiles/rtdevlib.dir/atomicAddFloat_emulation.cc.o bitcode/CMakeFiles/rtdevlib.dir/atomicAddDouble_native.cc.o bitcode/CMakeFiles/rtdevlib.dir/atomicAddDouble_emulation.cc.o bitcode/CMakeFiles/rtdevlib.dir/ballot_native.cc.o  /usr/lib/x86_64-linux-gnu/libze_loader.so /usr/lib/x86_64-linux-gnu/libOpenCL.so -lOpenCL -lze_loader 
/usr/bin/ld: cannot find /usr/lib/x86_64-linux-gnu: file format not recognized
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)

But with different error message.

The chipStar builds successfully (from scratch) on my machine with the following change:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ff392f95..b4556104 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -68,12 +68,13 @@ endforeach()
 if(NOT DEFINED OpenCL_LIBRARY)
   message(STATUS "OpenCL_LIBRARY was not set. Searching for libOpenCL.so in LD_LIBRARY_PATH")
   find_library(OpenCL_LIBRARY NAMES OpenCL PATHS ENV LD_LIBRARY_PATH ./ NO_CACHE)
-  if(OpenCL_LIBRARY)
-    get_filename_component(OpenCL_DIR ${OpenCL_LIBRARY} DIRECTORY CACHE)
-    message(STATUS "Setting OpenCL_DIR to ${OpenCL_DIR}")
-  else()
-    message(STATUS "OpenCL not found")
-  endif()
+endif()
+
+if(OpenCL_LIBRARY)
+  get_filename_component(OpenCL_DIR ${OpenCL_LIBRARY} DIRECTORY CACHE)
+  message(STATUS "Setting OpenCL_DIR to ${OpenCL_DIR}")
+else()
+  message(STATUS "OpenCL not found")
 endif()
 
 if(NOT DEFINED LevelZero_LIBRARY)

This patch solves the broken -Wl,-rpath option with the missing path value.

@pjaaskel
Copy link
Collaborator

@pvelesko can you confirm it fixes it? Can we create a PR of this and merge it in main?

@pvelesko
Copy link
Collaborator Author

pvelesko commented Dec 21, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
opencl Issues affecting only the OpenCL backend
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants