hip: Set --gcc-toolchain to ensure external HIP installs pick up correct GCC (#46573)

This commit is contained in:
Mikael Simberg 2024-10-10 18:15:02 +02:00 committed by GitHub
parent f3a3e85bb9
commit 9346306b79
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -475,6 +475,19 @@ def set_variables(self, env):
env.set("HIP_PATH", self.spec.prefix)
env.set("HIP_PLATFORM", "nvidia")
# Set up hipcc/hip-clang to use the specific GCC toolchain that is
# being used to compile. This is only important for external ROCm
# installations, which may otherwise pick up the wrong GCC toolchain.
if self.spec.external and self.spec.satisfies("%gcc"):
# This is picked up by hipcc.
env.append_path(
"HIPCC_COMPILE_FLAGS_APPEND",
f"--gcc-toolchain={self.compiler.prefix}",
separator=" ",
)
# This is picked up by CMake when using HIP as a CMake language.
env.append_path("HIPFLAGS", f"--gcc-toolchain={self.compiler.prefix}", separator=" ")
def setup_build_environment(self, env):
self.set_variables(env)