From fe8f631b7d412a6834f6a9a921c047bf03d8b89a Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Thu, 29 Aug 2024 11:24:58 +0200 Subject: tau: fix (cray) compiler names/paths (#46104) fixes a build issue on cray ci --- var/spack/repos/builtin/packages/tau/package.py | 34 +++++++++++-------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/var/spack/repos/builtin/packages/tau/package.py b/var/spack/repos/builtin/packages/tau/package.py index 4b944cc027..fd499910dd 100644 --- a/var/spack/repos/builtin/packages/tau/package.py +++ b/var/spack/repos/builtin/packages/tau/package.py @@ -204,25 +204,21 @@ class Tau(Package): # ('CC', 'CXX' and 'FC') # 4 - if no -cc= -cxx= is passed tau is built with # system compiler silently - # (regardless of what % is used in the spec) - # 5 - On cray gnu compilers are not provied by self.compilers - # Checking GCC_PATH will work if spack loads the gcc module - # - # In the following we give TAU what he expects and put compilers into - # PATH - compiler_path = os.path.dirname(self.compiler.cc) - if not compiler_path and self.compiler.cc_names[0] == "gcc": - compiler_path = os.environ.get("GCC_PATH", "") - if compiler_path: - compiler_path = compiler_path + "/bin/" - os.environ["PATH"] = ":".join([compiler_path, os.environ["PATH"]]) - compiler_options = [ - "-c++=%s" % os.path.basename(self.compiler.cxx), - "-cc=%s" % os.path.basename(self.compiler.cc), - ] - - if "+fortran" in spec and self.compiler.fc: - compiler_options.append("-fortran=%s" % os.path.basename(self.compiler.fc)) + compiler_flags: Dict[str, str] = { + flag: os.path.basename(getattr(self.compiler, compiler)) + for flag, compiler in (("-cc", "cc"), ("-c++", "cxx"), ("-fortran", "fc")) + if getattr(self.compiler, compiler) + } + + if "~fortran" in spec: + compiler_flags.pop("-fortran", None) + + # tau does not understand `craycc`, `crayCC`, `crayftn`, strip off the `cray` prefix + for flag, value in compiler_flags.items(): + if value.startswith("cray"): + compiler_flags[flag] = value[4:] + + compiler_options = [f"{flag}={value}" for flag, value in compiler_flags.items()] ########## -- cgit v1.2.3-70-g09d2