From 966eb502feecf0420bc93d7fa0604923dd245e4c Mon Sep 17 00:00:00 2001 From: "Adrien M. BERNEDE" <51493078+adrienbernede@users.noreply.github.com> Date: Tue, 25 Mar 2025 14:45:52 +0100 Subject: [PATCH] make default logic for hip support more robust --- lib/spack/spack/build_systems/cached_cmake.py | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/spack/spack/build_systems/cached_cmake.py b/lib/spack/spack/build_systems/cached_cmake.py index ec830c57cd2..85f0fddb75a 100644 --- a/lib/spack/spack/build_systems/cached_cmake.py +++ b/lib/spack/spack/build_systems/cached_cmake.py @@ -285,24 +285,25 @@ def initconfig_hardware_entries(self): if archs[0] != "none": arch_str = ";".join(archs) entries.append(cmake_cache_string("CMAKE_HIP_ARCHITECTURES", arch_str)) + entries.append(cmake_cache_string("GPU_TARGETS", arch_str)) - if spec.satisfies("^blt@:0.6"): + llvm_prefix = spec["llvm-amdgpu"].prefix + llvm_bin = spec["llvm-amdgpu"].prefix.bin + # Some ROCm systems seem to point to //rocm-/ and + # others point to //rocm-/llvm + if os.path.basename(os.path.normpath(llvm_prefix)) != "llvm": + llvm_bin = os.path.join(llvm_prefix, "llvm/bin/") + entries.append( + cmake_cache_filepath("CMAKE_HIP_COMPILER", os.path.join(llvm_bin, "amdclang++")) + ) + + if not spec.satisfies("^blt"): # Explicitly setting HIP_ROOT_DIR may be a patch that is no longer necessary entries.append(cmake_cache_path("HIP_ROOT_DIR", "{0}".format(spec["hip"].prefix))) - llvm_bin = spec["llvm-amdgpu"].prefix.bin - llvm_prefix = spec["llvm-amdgpu"].prefix - # Some ROCm systems seem to point to //rocm-/ and - # others point to //rocm-/llvm - if os.path.basename(os.path.normpath(llvm_prefix)) != "llvm": - llvm_bin = os.path.join(llvm_prefix, "llvm/bin/") - entries.append( - cmake_cache_filepath("CMAKE_HIP_COMPILER", os.path.join(llvm_bin, "clang++")) - ) if archs[0] != "none": arch_str = ";".join(archs) entries.append(cmake_cache_string("AMDGPU_TARGETS", arch_str)) - entries.append(cmake_cache_string("GPU_TARGETS", arch_str)) if spec.satisfies("%gcc"): entries.append(