ESMF package: support clang with flang

So far, the ESMF package recipe in spack assumes that the spack
compilers clang and apple-clang are using gfortran as the Fortran
compiler. But with the latest improvements to the LLVM compilers,
we need to also support clang with flang.
This commit is contained in:
Dom Heinzeller 2024-12-11 16:47:52 -07:00 committed by GitHub
parent fc4316cafa
commit 25cfea48f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -270,13 +270,18 @@ def setup_build_environment(self, env):
elif self.pkg.compiler.name == "intel" or self.pkg.compiler.name == "oneapi":
env.set("ESMF_COMPILER", "intel")
elif self.pkg.compiler.name in ["clang", "apple-clang"]:
env.set("ESMF_COMPILER", "gfortranclang")
with self.pkg.compiler.compiler_environment():
gfortran_major_version = int(
spack.compiler.get_compiler_version_output(
self.pkg.compiler.fc, "-dumpversion"
).split(".")[0]
)
if "flang" in self.pkg.compiler.fc:
env.set("ESMF_COMPILER", "llvm")
elif "gfortran" in self.pkg.compiler.fc:
env.set("ESMF_COMPILER", "gfortranclang")
with self.pkg.compiler.compiler_environment():
gfortran_major_version = int(
spack.compiler.get_compiler_version_output(
self.pkg.compiler.fc, "-dumpversion"
).split(".")[0]
)
else:
raise InstallError("Unsupported C/C++/Fortran compiler combination")
elif self.pkg.compiler.name == "nag":
env.set("ESMF_COMPILER", "nag")
elif self.pkg.compiler.name == "nvhpc":
@ -309,6 +314,7 @@ def setup_build_environment(self, env):
if (
self.pkg.compiler.name in ["gcc", "clang", "apple-clang"]
and "gfortran" in self.pkg.compiler.fc
and gfortran_major_version >= 10
and (self.spec.satisfies("@:8.2.99") or self.spec.satisfies("@8.3.0b09"))
):