add hip compiler property

This commit is contained in:
Harmen Stoppels 2025-03-24 12:59:21 +01:00
parent 2519ad20da
commit 0ac63a3799
6 changed files with 18 additions and 3 deletions

View File

@ -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"

View File

@ -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",

View File

@ -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

View File

@ -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",

View File

@ -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",

View File

@ -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++",)