Repository: spack/spack

Issue:
Cray: CompilerAccessError: cc CC ftn not executable
Using `spack@develop` (commit id d71fdc9719f716347bb4d61e26e00368466f3aa4) on NERSC Cori Login node:

```
$> spack install zlib%gcc@8.3.0 arch=cray-cnl7-haswell
...
==> Error: Failed to install zlib due to ChildError: CompilerAccessError: Compiler 'gcc@8.3.0' has executables that are missing or are not executable: ['cc', 'CC', 'ftn', 'ftn']
/global/u1/l/lpeyrala/spack-greg-test/lib/spack/spack/build_environment.py:854, in child_process:
        851            tb_string = traceback.format_exc()
        852
        853            # build up some context from the offending package so we can
  >>    854            # show that, too.
        855            package_context = get_package_context(tb)
        856
        857            build_log = None

Traceback (most recent call last):
  File "/global/u1/l/lpeyrala/spack-greg-test/lib/spack/spack/build_environment.py", line 837, in child_process
    setup_package(pkg, dirty=dirty)
  File "/global/u1/l/lpeyrala/spack-greg-test/lib/spack/spack/build_environment.py", line 712, in setup_package
    set_compiler_environment_variables(pkg, build_env)
  File "/global/u1/l/lpeyrala/spack-greg-test/lib/spack/spack/build_environment.py", line 202, in set_compiler_environment_variables
    compiler.verify_executables()
  File "/global/u1/l/lpeyrala/spack-greg-test/lib/spack/spack/compiler.py", line 304, in verify_executables
    raise CompilerAccessError(self, missing)
spack.compiler.CompilerAccessError: Compiler 'gcc@8.3.0' has executables that are missing or are not executable: ['cc', 'CC', 'ftn', 'ftn']
```

Same error when trying with `%gcc@9.2.0`.

Here is the spack-created compilers.yaml entry for gcc@8.3.0:
```
- compiler:
    spec: gcc@8.3.0
    paths:
      cc: cc
      cxx: CC
      f77: ftn
      fc: ftn
    flags: {}
    operating_system: cnl7
    target: any
    modules:
    - PrgEnv-gnu
    - gcc/8.3.0
    environment: {}
    extra_rpaths: []
```

@becker33 


Discussion:

Resolving patch:
diff --git a/lib/spack/spack/compiler.py b/lib/spack/spack/compiler.py
--- a/lib/spack/spack/compiler.py
+++ b/lib/spack/spack/compiler.py
@@ -297,11 +297,21 @@ def verify_executables(self):
         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):


Test patch: