diff options
author | Brad King <brad.king@kitware.com> | 2021-09-13 17:31:28 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-09-16 19:33:47 (GMT) |
commit | a71f0fc9c7762a06d0bfdd64d0d490919e12357a (patch) | |
tree | 89468eda1f91241b97d97aa60aad833152aea6e8 /Modules/CMakeDetermineHIPCompiler.cmake | |
parent | b125e9809a1a3f3e28fc1682c8a33c3a928f79b5 (diff) | |
download | CMake-a71f0fc9c7762a06d0bfdd64d0d490919e12357a.zip CMake-a71f0fc9c7762a06d0bfdd64d0d490919e12357a.tar.gz CMake-a71f0fc9c7762a06d0bfdd64d0d490919e12357a.tar.bz2 |
HIP: Remove ROMClang compiler id and use Clang directly
Since commit bd844387df (ROCMClang: Add the ROCm toolkit derived clang
compiler to CMake, 2020-08-28, v3.21.0-rc1~66^2~6) and commit ff0d2858e1
(HIP: Extract clang compiler details from hipcc, 2020-10-21,
v3.21.0-rc1~66^2~5), the separate `ROCMClang` compiler id for `hipcc`
has caused a few problems:
* The compiler id changed from behavior of CMake 3.20 and below,
breaking projects that already built with `hipcc` treated as `Clang`.
* The implementation of `target_compile_features` was incomplete for
the `ROCMClang` identity.
* Only `hipcc` was identified as `ROCMClang`, so after it is unwrapped
to the underlying `clang++`, future runs of new CMake versions on
an existing build tree would not repeat this.
* Clang should be usable as a HIP compiler without the `hipcc` wrapper.
Remove the `ROMClang` compiler identity, and revise HIP language support
to work directly with a Clang compiler.
Reject direct `hipcc` usage as a HIP compiler. For now it cannot be
supported because it interferes with flags CMake needs to pass to Clang.
Fixes: #22536, #22460, #22593
Diffstat (limited to 'Modules/CMakeDetermineHIPCompiler.cmake')
-rw-r--r-- | Modules/CMakeDetermineHIPCompiler.cmake | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/Modules/CMakeDetermineHIPCompiler.cmake b/Modules/CMakeDetermineHIPCompiler.cmake index 394f8e2..5c8849e 100644 --- a/Modules/CMakeDetermineHIPCompiler.cmake +++ b/Modules/CMakeDetermineHIPCompiler.cmake @@ -15,6 +15,13 @@ if(NOT CMAKE_HIP_COMPILER) # prefer the environment variable HIPCXX if(NOT $ENV{HIPCXX} STREQUAL "") + if("$ENV{HIPCXX}" MATCHES "hipcc") + message(FATAL_ERROR + "The HIPCXX environment variable is set to the hipcc wrapper:\n" + " $ENV{HIPCXX}\n" + "This is not supported. Use Clang directly, or let CMake pick a default." + ) + endif() get_filename_component(CMAKE_HIP_COMPILER_INIT $ENV{HIPCXX} PROGRAM PROGRAM_ARGS CMAKE_HIP_FLAGS_ENV_INIT) if(CMAKE_HIP_FLAGS_ENV_INIT) set(CMAKE_HIP_COMPILER_ARG1 "${CMAKE_HIP_FLAGS_ENV_INIT}" CACHE STRING "Arguments to CXX compiler") @@ -26,10 +33,25 @@ if(NOT CMAKE_HIP_COMPILER) # finally list compilers to try if(NOT CMAKE_HIP_COMPILER_INIT) - set(CMAKE_HIP_COMPILER_LIST hipcc clang++) + set(CMAKE_HIP_COMPILER_LIST clang++) + + # Look for the Clang coming with ROCm to support HIP. + execute_process(COMMAND hipconfig --hipclangpath + OUTPUT_VARIABLE _CMAKE_HIPCONFIG_CLANGPATH + RESULT_VARIABLE _CMAKE_HIPCONFIG_RESULT + ) + if(_CMAKE_HIPCONFIG_RESULT EQUAL 0 AND EXISTS "${_CMAKE_HIPCONFIG_CLANGPATH}") + set(CMAKE_HIP_COMPILER_HINTS "${_CMAKE_HIPCONFIG_CLANGPATH}") + endif() endif() _cmake_find_compiler(HIP) +elseif(CMAKE_HIP_COMPILER MATCHES "hipcc") + message(FATAL_ERROR + "CMAKE_HIP_COMPILER is set to the hipcc wrapper:\n" + " ${CMAKE_HIP_COMPILER}\n" + "This is not supported. Use Clang directly, or let CMake pick a default." + ) else() _cmake_find_compiler_path(HIP) endif() |