CHIP-SPV / chipStar

chipStar is a tool for compiling and running HIP/CUDA on SPIR-V via OpenCL or Level Zero APIs.
Other
166 stars 27 forks source link

Build fails on Ubuntu 24.04 #824

Closed jansol closed 2 months ago

jansol commented 3 months ago

Ubuntu packages LLVM in their official repos with version-suffixed binaries that are just symlinks to a LLVM version-specific location with non-suffixed binaries. They also provide a non-versioned package that simply symlinks to the version-specific location of the ~latest versioned LLVM package (which the unversioned package depends on).

$ ls -al /usr/bin/llvm-conf*
lrwxrwxrwx root root 30 B Wed Feb 28 10:30:40 2024 /usr/bin/llvm-config ⇒ ../lib/llvm-18/bin/llvm-config
lrwxrwxrwx root root 30 B Fri Jan 19 22:19:29 2024 /usr/bin/llvm-config-17 ⇒ ../lib/llvm-17/bin/llvm-config
lrwxrwxrwx root root 30 B Thu Feb 22 18:58:05 2024 /usr/bin/llvm-config-18 ⇒ ../lib/llvm-18/bin/llvm-config

However llvm-spirv is not part of the LLVM package and does not get installed in the same version-specific location:

$ ls -al /usr/bin/llvm-spir*
.rwxr-xr-x root root 1.6 MB Sat Feb 10 11:17:54 2024 /usr/bin/llvm-spirv-17

There are several versioned packages for llvm-spirv with version-suffixed binaries, but no non-versioned package. This means that cmake/FindLLVM.cmake will not find any llvm-spirv automatically. That is easily fixed by adding llvm-spirv-${LLVM_VERSION_MAJOR} to the NAMES in find_program, however now there are several build-time errors as various tools proceed to ignore the found binary (/usr/bin/llvm-spirv-17 as I was building with llvm-config-17) and try to invoke the non-versioned one anyway:

clang++: error: unable to execute command: Executable "llvm-spirv" doesn't exist!
clang++: error: hipspv-link command failed with exit code 1 (use -v to see invocation)
gmake[2]: *** [tests/runtime/CMakeFiles/RegressionTest302.dir/build.make:76: tests/runtime/CMakeFiles/RegressionTest302.dir/RegressionTest302.hip.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:20621: tests/runtime/CMakeFiles/RegressionTest302.dir/all] Error 2
clang++: error: unable to execute command: Executable "llvm-spirv" doesn't exist!
clang++: error: hipspv-link command failed with exit code 1 (use -v to see invocation)
gmake[2]: *** [tests/runtime/CMakeFiles/TestStlFunctionsDouble.dir/build.make:76: tests/runtime/CMakeFiles/TestStlFunctionsDouble.dir/TestStlFunctionsDouble.hip.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:20803: tests/runtime/CMakeFiles/TestStlFunctionsDouble.dir/all] Error 2
clang++: error: unable to execute command: Executable "llvm-spirv" doesn't exist!
clang++: error: hipspv-link command failed with exit code 1 (use -v to see invocation)
gmake[2]: *** [tests/runtime/CMakeFiles/TestStlFunctions.dir/build.make:76: tests/runtime/CMakeFiles/TestStlFunctions.dir/TestStlFunctions.hip.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:20777: tests/runtime/CMakeFiles/TestStlFunctions.dir/all] Error 2
...
linehill commented 3 months ago

however now there are several build-time errors as various tools proceed to ignore the found binary (/usr/bin/llvm-spirv-17 as I was building with llvm-config-17) and try to invoke the non-versioned one anyway.

Unfortunately, the clang is hard-coded to use non-versioned llvm-spirv. There is a patch that could change it to pick up llvm-spirv-XX matching the LLVM version the compiler is built against (https://github.com/llvm/llvm-project/pull/77897).

pvelesko commented 3 months ago

Thank you for bring this to our attention. I setup a new Ubuntu system and tried to install and run chipStar from scratch and ran into a lot of issues actually.

@jansol draft PR addressing some of these issues https://github.com/CHIP-SPV/chipStar/pull/825