From 25cfea48f3dd0d55b36d1a4274f5011b71eccded Mon Sep 17 00:00:00 2001 From: Dom Heinzeller Date: Wed, 11 Dec 2024 16:47:52 -0700 Subject: [PATCH] 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. --- .../repos/builtin/packages/esmf/package.py | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/var/spack/repos/builtin/packages/esmf/package.py b/var/spack/repos/builtin/packages/esmf/package.py index 20a7223e630..44190510d2c 100644 --- a/var/spack/repos/builtin/packages/esmf/package.py +++ b/var/spack/repos/builtin/packages/esmf/package.py @@ -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")) ):