HIP: CMake does not search multiarch dirs for hip-lang-config.cmake
There is a mismatch between where CMake looks for `hip-lang-config.cmake` and where that file is installed on Debian and Debian-derived distros. ## What was done In a fresh Ubuntu 23.04 container: ```bash apt-get -y update apt-get -y install hipcc cmake build-essential cat << 'EOF' > main.hip #include <hip/hip_runtime.h> int main() { return 0; } EOF cat << 'EOF' > CMakeLists.txt cmake_minimum_required(VERSION 3.22) project(example LANGUAGES HIP) add_executable(ex main.hip) EOF HIPFLAGS="--rocm-path=/usr --rocm-device-lib-path=/usr/lib/x86_64-linux-gnu/amdgcn/bitcode" \ HIPCXX=clang++-15 cmake -S. -Bbuild --debug-output ``` ## What was seen ``` -- The HIP compiler identification is Clang 15.0.7 Called from: [3] /usr/share/cmake-3.25/Modules/CMakeDetermineCompilerId.cmake [2] /usr/share/cmake-3.25/Modules/CMakeDetermineHIPCompiler.cmake [1] /root/CMakeLists.txt CMake Error at /usr/share/cmake-3.25/Modules/CMakeDetermineHIPCompiler.cmake:106 (message): The ROCm root directory: /usr does not contain the HIP runtime CMake package, expected at: /usr/lib/cmake/hip-lang/hip-lang-config.cmake Call Stack (most recent call first): CMakeLists.txt:2 (project) Called from: [2] /usr/share/cmake-3.25/Modules/CMakeDetermineHIPCompiler.cmake [1] /root/CMakeLists.txt -- Configuring incomplete, errors occurred! See also "/root/build/CMakeFiles/CMakeOutput.log". ``` Attached: [CMakeOutput.log](/uploads/925a618118a774df72a60d17f5de61ab/CMakeOutput.log) I used the distro cmake in the example above for simplicity, but the behaviour is unchanged on cmake-3.26.0-rc5-linux-x86_64. ## Discussion The package `libamdhip64-dev` provides `/usr/lib/x86_64-linux-gnu/cmake/hip-lang/hip-lang-config.cmake`. However, the `x86_64-linux-gnu` subdirectory is not searched for two reasons: 1. The path is hardcoded to `lib/cmake` in these three places: - [Modules/CMakeDetermineHIPCompiler.cmake:105](https://gitlab.kitware.com/cmake/cmake/-/blob/v3.26.0-rc5/Modules/CMakeDetermineHIPCompiler.cmake#L105) - [Modules/CMakeDetermineHIPCompiler.cmake:110](https://gitlab.kitware.com/cmake/cmake/-/blob/v3.26.0-rc5/Modules/CMakeDetermineHIPCompiler.cmake#L110) - [Modules/CMakeHIPInformation.cmake:145](https://gitlab.kitware.com/cmake/cmake/-/blob/v3.26.0-rc5/Modules/CMakeHIPInformation.cmake#L145) 2. The HIP library architecture does not seem to be set before cmake tries to include `hip-lang-config.cmake`. This also prevents ROCm components in `/usr/lib/x86_64-linux-gnu` such as comgr and the rocm-device-libs from being found by `find_dependency`. This issue has also been filed as [Debian Bug 1031799](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1031799). Ubuntu 23.04 is convenient for illustrating this problem because the relevant packages are now all frozen in preparation for release, whereas on Debian Testing or Unstable these packages are still somewhat in flux.
issue