[mfem] Add a method to resolve all header dependencies of a spec using its

link dependencies. Use the new method for hipblas.

[petsc] Add new variant, fortran-bindings, which is propagated to the
        petsc configuration via the option with the same name.
This commit is contained in:
Veselin Dobrev 2025-05-05 00:53:55 -07:00
parent 0d51440648
commit d145ca6da4
2 changed files with 17 additions and 1 deletions

View File

@ -1004,7 +1004,7 @@ def find_optional_library(name, prefix):
if "^hipblas" in spec: # hipblas is needed @4.8.0:+rocm if "^hipblas" in spec: # hipblas is needed @4.8.0:+rocm
# note: superlu-dist+rocm needs the hipblas header path too # note: superlu-dist+rocm needs the hipblas header path too
hipblas = spec["hipblas"] hipblas = spec["hipblas"]
hip_headers += hipblas.headers hip_headers += self.all_headers(hipblas)
hip_libs += hipblas.libs hip_libs += hipblas.libs
if "%cce" in spec: if "%cce" in spec:
# We assume the proper Cray CCE module (cce) is loaded: # We assume the proper Cray CCE module (cce) is loaded:
@ -1405,3 +1405,12 @@ def ld_flags_from_dirs(self, pkg_dirs_list, pkg_libs_list):
flags += ["-L%s" % dir for dir in pkg_dirs_list if not self.is_sys_lib_path(dir)] flags += ["-L%s" % dir for dir in pkg_dirs_list if not self.is_sys_lib_path(dir)]
flags += ["-l%s" % lib for lib in pkg_libs_list] flags += ["-l%s" % lib for lib in pkg_libs_list]
return " ".join(flags) return " ".join(flags)
def all_headers(self, root_spec):
all_hdrs = HeaderList([])
for dep in root_spec.traverse(deptype="link"):
try:
all_hdrs += root_spec[dep.name].headers
except NoHeadersError:
pass
return all_hdrs

View File

@ -263,6 +263,9 @@ class Petsc(Package, CudaPackage, ROCmPackage):
variant("hwloc", default=False, description="Activates support for hwloc") variant("hwloc", default=False, description="Activates support for hwloc")
variant("kokkos", default=False, description="Activates support for kokkos and kokkos-kernels") variant("kokkos", default=False, description="Activates support for kokkos and kokkos-kernels")
variant("fortran", default=True, description="Activates fortran support") variant("fortran", default=True, description="Activates fortran support")
variant(
"fortran-bindings", default=True, when="+fortran", description="Activates fortran bindings"
)
with when("+rocm"): with when("+rocm"):
# https://github.com/spack/spack/issues/37416 # https://github.com/spack/spack/issues/37416
@ -503,6 +506,8 @@ def mpi_dependent_options(self):
] ]
if "+fortran" in self.spec: if "+fortran" in self.spec:
compiler_opts.append("--with-fc=%s" % os.environ["FC"]) compiler_opts.append("--with-fc=%s" % os.environ["FC"])
fb = "1" if self.spec.satisfies("+fortran-bindings") else "0"
compiler_opts.append(f"--with-fortran-bindings={fb}")
else: else:
compiler_opts.append("--with-fc=0") compiler_opts.append("--with-fc=0")
else: else:
@ -512,6 +517,8 @@ def mpi_dependent_options(self):
] ]
if "+fortran" in self.spec: if "+fortran" in self.spec:
compiler_opts.append("--with-fc=%s" % self.spec["mpi"].mpifc) compiler_opts.append("--with-fc=%s" % self.spec["mpi"].mpifc)
fb = "1" if self.spec.satisfies("+fortran-bindings") else "0"
compiler_opts.append(f"--with-fortran-bindings={fb}")
else: else:
compiler_opts.append("--with-fc=0") compiler_opts.append("--with-fc=0")
if self.spec.satisfies("%intel"): if self.spec.satisfies("%intel"):