From b52390dacc14028f84878ebf068bdd95d5cd82e2 Mon Sep 17 00:00:00 2001 From: Greg Becker Date: Mon, 29 Jun 2020 20:26:46 -0500 Subject: cray compilers: fix bug with verifying cray compilers (#17303) * fix bug with verifying cray compilers --- lib/spack/spack/compiler.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/spack/spack/compiler.py b/lib/spack/spack/compiler.py index 5dd3d60778..0982682081 100644 --- a/lib/spack/spack/compiler.py +++ b/lib/spack/spack/compiler.py @@ -297,11 +297,21 @@ class Compiler(object): Raises a CompilerAccessError if any of the non-null paths for the compiler are not accessible. """ - missing = [cmp for cmp in (self.cc, self.cxx, self.f77, self.fc) - if cmp and not (os.path.isfile(cmp) and - os.access(cmp, os.X_OK))] - if missing: - raise CompilerAccessError(self, missing) + def accessible_exe(exe): + # compilers may contain executable names (on Cray or user edited) + if not os.path.isabs(exe): + exe = spack.util.executable.which_string(exe) + if not exe: + return False + return os.path.isfile(exe) and os.access(exe, os.X_OK) + + # setup environment before verifying in case we have executable names + # instead of absolute paths + with self._compiler_environment(): + missing = [cmp for cmp in (self.cc, self.cxx, self.f77, self.fc) + if cmp and not accessible_exe(cmp)] + if missing: + raise CompilerAccessError(self, missing) @property def version(self): -- cgit v1.2.3-60-g2f50