diff --git a/lib/spack/spack/build_systems/compiler.py b/lib/spack/spack/build_systems/compiler.py index 783027c8f2f..d9658474741 100644 --- a/lib/spack/spack/build_systems/compiler.py +++ b/lib/spack/spack/build_systems/compiler.py @@ -199,10 +199,21 @@ def cxx(self) -> Optional[str]: return self.spec.extra_attributes["compilers"].get("cxx", None) return self._cxx_path() + @property + def hip(self) -> Optional[str]: + assert self.spec.concrete, "cannot retrieve HIP compiler, spec is not concrete" + if self.spec.external: + return self.spec.extra_attributes["compilers"].get("hip", None) + return self._hip_path() + def _cxx_path(self) -> Optional[str]: """Returns the path to the C++ compiler, if the package was installed by Spack""" return None + def _hip_path(self) -> Optional[str]: + """Returns the path to the HIP compiler, if the package was installed by Spack""" + return self._cxx_path() + @property def fortran(self): assert self.spec.concrete, "cannot retrieve Fortran compiler, spec is not concrete" diff --git a/var/spack/repos/builtin/packages/comgr/package.py b/var/spack/repos/builtin/packages/comgr/package.py index b1f4d5289b6..4dc659d4731 100644 --- a/var/spack/repos/builtin/packages/comgr/package.py +++ b/var/spack/repos/builtin/packages/comgr/package.py @@ -68,7 +68,7 @@ def url_for_version(self, version): depends_on("zlib-api", type="link") depends_on("z3", type="link") depends_on("ncurses", type="link") - requires(f"%[virtuals=c,cxx] llvm-amdgpu") + requires("%[virtuals=c,cxx] llvm-amdgpu") for ver in [ "5.3.0", diff --git a/var/spack/repos/builtin/packages/compiler-wrapper/package.py b/var/spack/repos/builtin/packages/compiler-wrapper/package.py index 5bee909f026..e6cd637b293 100644 --- a/var/spack/repos/builtin/packages/compiler-wrapper/package.py +++ b/var/spack/repos/builtin/packages/compiler-wrapper/package.py @@ -156,6 +156,9 @@ def setup_dependent_build_environment(self, env, dependent_spec): _var_list.append(("fortran", "fortran", "F77", "SPACK_F77")) _var_list.append(("fortran", "fortran", "FC", "SPACK_FC")) + if dependent_spec.has_virtual_dependency("hip-lang"): + _var_list.append(("hip-lang", "hip", "HIPCXX", "SPACK_HIPCXX")) + # The package is not used as a compiler, so skip this setup if not _var_list: return diff --git a/var/spack/repos/builtin/packages/hipify-clang/package.py b/var/spack/repos/builtin/packages/hipify-clang/package.py index cf4ae5f7c94..5c9d0eff4f5 100644 --- a/var/spack/repos/builtin/packages/hipify-clang/package.py +++ b/var/spack/repos/builtin/packages/hipify-clang/package.py @@ -57,7 +57,7 @@ class HipifyClang(CMakePackage): depends_on("cxx", type="build") depends_on("cmake@3.5:", type="build") - requires(f"%[virtuals=c,cxx] llvm-amdgpu") + requires("%[virtuals=c,cxx] llvm-amdgpu") for ver in [ "5.3.0", diff --git a/var/spack/repos/builtin/packages/hsa-rocr-dev/package.py b/var/spack/repos/builtin/packages/hsa-rocr-dev/package.py index 94bf198c3d7..345bed59b04 100644 --- a/var/spack/repos/builtin/packages/hsa-rocr-dev/package.py +++ b/var/spack/repos/builtin/packages/hsa-rocr-dev/package.py @@ -64,7 +64,7 @@ class HsaRocrDev(CMakePackage): depends_on("numactl") depends_on("pkgconfig") depends_on("libdrm", when="@6.3:") - requires(f"%[virtuals=c,cxx] llvm-amdgpu") + requires("%[virtuals=c,cxx] llvm-amdgpu") for ver in [ "5.3.0", diff --git a/var/spack/repos/builtin/packages/llvm-amdgpu/package.py b/var/spack/repos/builtin/packages/llvm-amdgpu/package.py index 1a8f54c2573..f21d73f6528 100644 --- a/var/spack/repos/builtin/packages/llvm-amdgpu/package.py +++ b/var/spack/repos/builtin/packages/llvm-amdgpu/package.py @@ -23,6 +23,7 @@ class LlvmAmdgpu(CMakePackage, LlvmDetection, CompilerPackage): "c": "rocmcc/amdclang", "cxx": "rocmcc/amdclang++", "fortran": "rocmcc/amdflang", + "hip-lang": "rocmcc/amdclang++", } stdcxx_libs = ("-lstdc++",)