HIP
HIP copied to clipboard
CMake `enable_language(HIP)` fails with test program compile error
enable_language(HIP)
in CMake 3.22.3 and 3.23.0-rc3 fails when linking the test program using ROCm 5.0.2 on Ubuntu 20.04:
-- 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)
The same error happens with a completely empty CMake project. The -fopenmp
error is very strange because I don't see OpenMP referenced anywhere else. Building and running the HIP samples (which simply use find_package(hip)
) work fine, so the issue seems to be limited to the enable_language
feature. Could this be a bug in CMake, perhaps an incompatibility with the latest ROCm? I didn't try an older version.
For what it's worth, I've hit this issue in ROCm 5.0 and it should be resolved in 5.1
Thanks! With ROCm 5.1.1 it does not fail here anymore but now it fails when linking. For example:
/snap/cmake/1082/bin/cmake -E cmake_link_script CMakeFiles/HIPOnlyMathFunctions.dir/link.txt --verbose=1
/opt/rocm-5.1.1/llvm/bin/clang++ --offload-arch=gfx1030 CMakeFiles/HIPOnlyMathFunctions.dir/main.hip.o -o HIPOnlyMathFunctions
clang-14: warning: argument unused during compilation: '--offload-arch=gfx1030' [-Wunused-command-line-argument]
ld.lld: error: undefined symbol: hipMalloc
@atafra Can you please test with latest ROCm 6.0.2 (HIP 6.0.32831) to see if it fails linking? Thanks!