HIP: enable_language(HIP) fails to build using recent ROCm versions
enable_language(HIP) in CMake 3.22.3 and 3.23.0-rc3 fails when compiling the built-in test program using ROCm 5.0.2 on Ubuntu 20.04.4:
-- The HIP compiler identification is Clang 14.0.0
-- Detecting HIP compiler ABI info
-- Detecting HIP compiler ABI info - failed
-- Check for working HIP compiler: /opt/rocm-5.0.2/llvm/bin/clang++
-- Check for working HIP compiler: /opt/rocm-5.0.2/llvm/bin/clang++ - broken
CMake Error at /snap/cmake/1049/share/cmake-3.23/Modules/CMakeTestHIPCompiler.cmake:65 (message):
The HIP compiler
"/opt/rocm-5.0.2/llvm/bin/clang++"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/user/project/build/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/ninja cmTC_74f12 && [1/2] Building HIP object CMakeFiles/cmTC_74f12.dir/testHIPCompiler.hip.o
[2/2] Linking HIP executable cmTC_74f12
FAILED: cmTC_74f12
: && /opt/rocm-5.0.2/llvm/bin/clang++ --cuda-host-only --offload-arch=gfx1030 CMakeFiles/cmTC_74f12.dir/testHIPCompiler.hip.o -o cmTC_74f12 && :
clang-14: error: '-fopenmp-targets' must be used in conjunction with a '-fopenmp' option compatible with offloading; e.g., '-fopenmp=libomp' or '-fopenmp=libiomp5'
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:126 (enable_language)
This error happens even when trying to configure an otherwise empty CMake project. The -fopenmp
error seems very strange because I don't see OpenMP referenced anywhere. Building and running the official HIP samples work fine, which use find_package(hip)
instead of enable_langauge(HIP)
.