** Description changed:
Description:
Follow-up to LP: #2143705.
The fix in cmake (4.2.3-2ubuntu2)
(debian/patches/0003-fix-missing-multiarch-search-path-in-CMakeDetermineH.patch)
adds a multiarch fallback for hip-lang-config.cmake, but only when
CMAKE_LIBRARY_ARCHITECTURE is already populated. That variable is set during
C/CXX compiler detection. In projects that use HIP as
the only language (project(... LANGUAGES HIP)), no C/CXX detection runs
before CMakeDetermineHIPCompiler.cmake, so CMAKE_LIBRARY_ARCHITECTURE is empty
and the new elseif branch is never taken — leaving the bug visible exactly as
reported in LP #2143705.
Reproducer
Tested on Ubuntu 26.04 (Resolute) with cmake 4.2.3-2ubuntu2,
libamdhip64-dev 7.2.4-0ubuntu1~ppa1~26.04, clang-22.
$ cat > main.hip <<'EOF'
#include <hip/hip_runtime.h>
int main(){ return 0; }
EOF
$ cat > CMakeLists.txt <<'EOF'
cmake_minimum_required(VERSION 3.22)
project(example LANGUAGES HIP)
add_executable(ex main.hip)
EOF
$ HIPCXX=/usr/bin/clang++ cmake -S. -Bbuild
-DCMAKE_HIP_ARCHITECTURES=gfx1030
-- The HIP compiler identification is unknown
CMake Error at
/usr/share/cmake-4.2/Modules/CMakeDetermineHIPCompiler.cmake:242 (message):
The ROCm root directory:
/usr
does not contain the HIP runtime CMake package, expected at one of:
/usr/lib/cmake/hip-lang/hip-lang-config.cmake
/usr/lib64/cmake/hip-lang/hip-lang-config.cmake
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
The actual file /usr/lib/x86_64-linux-gnu/cmake/hip-lang/hip-lang-
config.cmake is shipped by libamdhip64-dev and is correctly located in
the multiarch path — just not searched by CMake when CXX isn't enabled.
Workaround
Either:
- Add CXX to LANGUAGES, e.g. project(example LANGUAGES CXX HIP), so
CMAKE_LIBRARY_ARCHITECTURE gets populated before
CMakeDetermineHIPCompiler.cmake runs, or
- Pass -DCMAKE_HIP_LIBRARY_ARCHITECTURE=x86_64-linux-gnu explicitly.
Neither is documented and both should be unnecessary.
Proposed fix
Extend the patch from LP #2143705 with a third-tier fallback that
queries dpkg-architecture when neither HIP nor generic library
architecture is set. Suggested diff against
Modules/CMakeDetermineHIPCompiler.cmake:
if(CMAKE_HIP_LIBRARY_ARCHITECTURE)
list(APPEND _CMAKE_HIP_COMPILER_ROCM_LIB_DIRS
"${CMAKE_HIP_COMPILER_ROCM_ROOT}/lib/${CMAKE_HIP_LIBRARY_ARCHITECTURE}")
elseif(CMAKE_LIBRARY_ARCHITECTURE)
list(APPEND _CMAKE_HIP_COMPILER_ROCM_LIB_DIRS
"${CMAKE_HIP_COMPILER_ROCM_ROOT}/lib/${CMAKE_LIBRARY_ARCHITECTURE}")
+ else()
+ # HIP-only projects haven't run C/CXX detection yet, so
+ # CMAKE_LIBRARY_ARCHITECTURE is unset. Fall back to
dpkg-architecture
+ # on Debian/Ubuntu so multiarch installs are still discoverable.
+ find_program(_CMAKE_HIP_DPKG_ARCH dpkg-architecture)
+ if(_CMAKE_HIP_DPKG_ARCH)
+ execute_process(COMMAND "${_CMAKE_HIP_DPKG_ARCH}"
-qDEB_HOST_MULTIARCH
+ OUTPUT_VARIABLE _CMAKE_HIP_DEB_MULTIARCH
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_QUIET)
+ if(_CMAKE_HIP_DEB_MULTIARCH)
+ list(APPEND _CMAKE_HIP_COMPILER_ROCM_LIB_DIRS
+
"${CMAKE_HIP_COMPILER_ROCM_ROOT}/lib/${_CMAKE_HIP_DEB_MULTIARCH}")
+ endif()
+ endif()
endif()
This should also be forwarded upstream as an addendum to
https://gitlab.kitware.com/cmake/cmake/-/merge_requests/11796 (or a new
MR), so distros that lack dpkg-architecture aren't affected (the
find_program guards it).
System Information
$ lsb_release -rd
Description: Ubuntu Resolute Raccoon (development branch)
Release: 26.04
$ apt-cache policy cmake
cmake:
Installed: 4.2.3-2ubuntu2
Candidate: 4.2.3-2ubuntu2
$ apt-cache policy libamdhip64-dev
libamdhip64-dev:
Installed: 7.2.4-0ubuntu1~ppa1~26.04
Surfaced by the rocm-hipamd 7.2.4 autopkgtest (cmake-hip-lang test) in
ppa:igorluppi/rocm-hipamd-7.2.4.
+
+ Update / triage note
+
+ Further investigation showed that this bug surfaced in an artificial
setting: the rocm-hipamd cmake-hip-lang autopkgtest uses project(example
LANGUAGES HIP) with HIP as the only
+ enabled language, which prevents the existing multiarch fallback (from LP
#2143705) from kicking in, since CMAKE_LIBRARY_ARCHITECTURE is only populated
during C/CXX detection.
+ After surveying real-world CMake-based HIP projects, we couldn't find one
that enables HIP without also enabling CXX (or C) — typical projects use
LANGUAGES CXX HIP or call
+ enable_language(HIP) after a CXX-enabled project(), both of which are
already covered by the current cmake patch.
+
+ Given that, the short-term action is to update the rocm-hipamd autopkgtest
to add CXX to the language list, which matches real-world usage and unblocks
the package's test
+ pipeline. This LP bug is intentionally left open as a low-priority
follow-up so the discussion stays visible. If a real-world project that enables
HIP as its only language is
+ reported, we can revisit the priority and pursue a fix — either as a
refinement of the Debian patch or, preferably, an upstream change in
CMakeDetermineHIPCompiler.cmake. Until
+ then, no Debian-local patch is being added.
** Description changed:
Description:
Follow-up to LP: #2143705.
The fix in cmake (4.2.3-2ubuntu2)
(debian/patches/0003-fix-missing-multiarch-search-path-in-CMakeDetermineH.patch)
adds a multiarch fallback for hip-lang-config.cmake, but only when
CMAKE_LIBRARY_ARCHITECTURE is already populated. That variable is set during
C/CXX compiler detection. In projects that use HIP as
the only language (project(... LANGUAGES HIP)), no C/CXX detection runs
before CMakeDetermineHIPCompiler.cmake, so CMAKE_LIBRARY_ARCHITECTURE is empty
and the new elseif branch is never taken — leaving the bug visible exactly as
reported in LP #2143705.
Reproducer
Tested on Ubuntu 26.04 (Resolute) with cmake 4.2.3-2ubuntu2,
libamdhip64-dev 7.2.4-0ubuntu1~ppa1~26.04, clang-22.
$ cat > main.hip <<'EOF'
#include <hip/hip_runtime.h>
int main(){ return 0; }
EOF
$ cat > CMakeLists.txt <<'EOF'
cmake_minimum_required(VERSION 3.22)
project(example LANGUAGES HIP)
add_executable(ex main.hip)
EOF
$ HIPCXX=/usr/bin/clang++ cmake -S. -Bbuild
-DCMAKE_HIP_ARCHITECTURES=gfx1030
-- The HIP compiler identification is unknown
CMake Error at
/usr/share/cmake-4.2/Modules/CMakeDetermineHIPCompiler.cmake:242 (message):
The ROCm root directory:
/usr
does not contain the HIP runtime CMake package, expected at one of:
/usr/lib/cmake/hip-lang/hip-lang-config.cmake
/usr/lib64/cmake/hip-lang/hip-lang-config.cmake
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
The actual file /usr/lib/x86_64-linux-gnu/cmake/hip-lang/hip-lang-
config.cmake is shipped by libamdhip64-dev and is correctly located in
the multiarch path — just not searched by CMake when CXX isn't enabled.
Workaround
Either:
- Add CXX to LANGUAGES, e.g. project(example LANGUAGES CXX HIP), so
CMAKE_LIBRARY_ARCHITECTURE gets populated before
CMakeDetermineHIPCompiler.cmake runs, or
- Pass -DCMAKE_HIP_LIBRARY_ARCHITECTURE=x86_64-linux-gnu explicitly.
Neither is documented and both should be unnecessary.
Proposed fix
Extend the patch from LP #2143705 with a third-tier fallback that
queries dpkg-architecture when neither HIP nor generic library
architecture is set. Suggested diff against
Modules/CMakeDetermineHIPCompiler.cmake:
if(CMAKE_HIP_LIBRARY_ARCHITECTURE)
list(APPEND _CMAKE_HIP_COMPILER_ROCM_LIB_DIRS
"${CMAKE_HIP_COMPILER_ROCM_ROOT}/lib/${CMAKE_HIP_LIBRARY_ARCHITECTURE}")
elseif(CMAKE_LIBRARY_ARCHITECTURE)
list(APPEND _CMAKE_HIP_COMPILER_ROCM_LIB_DIRS
"${CMAKE_HIP_COMPILER_ROCM_ROOT}/lib/${CMAKE_LIBRARY_ARCHITECTURE}")
+ else()
+ # HIP-only projects haven't run C/CXX detection yet, so
+ # CMAKE_LIBRARY_ARCHITECTURE is unset. Fall back to
dpkg-architecture
+ # on Debian/Ubuntu so multiarch installs are still discoverable.
+ find_program(_CMAKE_HIP_DPKG_ARCH dpkg-architecture)
+ if(_CMAKE_HIP_DPKG_ARCH)
+ execute_process(COMMAND "${_CMAKE_HIP_DPKG_ARCH}"
-qDEB_HOST_MULTIARCH
+ OUTPUT_VARIABLE _CMAKE_HIP_DEB_MULTIARCH
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_QUIET)
+ if(_CMAKE_HIP_DEB_MULTIARCH)
+ list(APPEND _CMAKE_HIP_COMPILER_ROCM_LIB_DIRS
+
"${CMAKE_HIP_COMPILER_ROCM_ROOT}/lib/${_CMAKE_HIP_DEB_MULTIARCH}")
+ endif()
+ endif()
endif()
This should also be forwarded upstream as an addendum to
https://gitlab.kitware.com/cmake/cmake/-/merge_requests/11796 (or a new
MR), so distros that lack dpkg-architecture aren't affected (the
find_program guards it).
System Information
$ lsb_release -rd
Description: Ubuntu Resolute Raccoon (development branch)
Release: 26.04
$ apt-cache policy cmake
cmake:
Installed: 4.2.3-2ubuntu2
Candidate: 4.2.3-2ubuntu2
$ apt-cache policy libamdhip64-dev
libamdhip64-dev:
Installed: 7.2.4-0ubuntu1~ppa1~26.04
Surfaced by the rocm-hipamd 7.2.4 autopkgtest (cmake-hip-lang test) in
ppa:igorluppi/rocm-hipamd-7.2.4.
- Update / triage note
+ *** Update / triage note ***
- Further investigation showed that this bug surfaced in an artificial
setting: the rocm-hipamd cmake-hip-lang autopkgtest uses project(example
LANGUAGES HIP) with HIP as the only
- enabled language, which prevents the existing multiarch fallback (from LP
#2143705) from kicking in, since CMAKE_LIBRARY_ARCHITECTURE is only populated
during C/CXX detection.
- After surveying real-world CMake-based HIP projects, we couldn't find one
that enables HIP without also enabling CXX (or C) — typical projects use
LANGUAGES CXX HIP or call
- enable_language(HIP) after a CXX-enabled project(), both of which are
already covered by the current cmake patch.
+ Further investigation showed that this bug surfaced in an artificial
setting: the rocm-hipamd cmake-hip-lang autopkgtest uses project(example
LANGUAGES HIP) with HIP as the only
+ enabled language, which prevents the existing multiarch fallback (from LP
#2143705) from kicking in, since CMAKE_LIBRARY_ARCHITECTURE is only populated
during C/CXX detection.
+ After surveying real-world CMake-based HIP projects, we couldn't find one
that enables HIP without also enabling CXX (or C) — typical projects use
LANGUAGES CXX HIP or call
+ enable_language(HIP) after a CXX-enabled project(), both of which are
already covered by the current cmake patch.
- Given that, the short-term action is to update the rocm-hipamd autopkgtest
to add CXX to the language list, which matches real-world usage and unblocks
the package's test
- pipeline. This LP bug is intentionally left open as a low-priority
follow-up so the discussion stays visible. If a real-world project that enables
HIP as its only language is
- reported, we can revisit the priority and pursue a fix — either as a
refinement of the Debian patch or, preferably, an upstream change in
CMakeDetermineHIPCompiler.cmake. Until
- then, no Debian-local patch is being added.
+ Given that, the short-term action is to update the rocm-hipamd autopkgtest
to add CXX to the language list, which matches real-world usage and unblocks
the package's test
+ pipeline. This LP bug is intentionally left open as a low-priority
follow-up so the discussion stays visible. If a real-world project that enables
HIP as its only language is
+ reported, we can revisit the priority and pursue a fix — either as a
refinement of the Debian patch or, preferably, an upstream change in
CMakeDetermineHIPCompiler.cmake. Until
+ then, no Debian-local patch is being added.
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2156062
Title:
CMakeDetermineHIPCompiler multiarch fallback fails for HIP-only
projects
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/cmake/+bug/2156062/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs