Repository: spack/spack

Issue:
Compiler detect not working with Cray wrappers
I think this comes down to a typo somewhere -- spack is attempting to query the version of CC by running `/opt/cray/craype/2.5.4/bin/CC ([Vv]ersion).*(\d+(\.\d+)+)`. I think that argument is a regex that is supposed to be going to a different function call, or perhaps as a different argument in the get_compiler_version method.

To reproduce on Cori, BlueWaters, or Titan, run `compiler find` with -vd.



Discussion:
I believe @mpbelhorn had some thoughts on this

I think that there is a missing argument `-V` for the CCE compilers. Also, the environment module name is `cce` on our Crays, not `craype`. I haven't checked if this is true elsewhere.

My branch is not pull-worthy yet, but can be found at https://github.com/mpbelhorn/spack/tree/olcf/correct_cce_compiler_name

```
diff --git a/lib/spack/spack/compilers/craype.py b/lib/spack/spack/compilers/craype.py
index 4ba8b11..030e2ee 100644
--- a/lib/spack/spack/compilers/craype.py
+++ b/lib/spack/spack/compilers/craype.py
@@ -45,7 +45,7 @@ class Craype(Compiler):
     suffixes = [r'-mp-\d\.\d']

     PrgEnv = 'PrgEnv-cray'
-    PrgEnv_compiler = 'craype'
+    PrgEnv_compiler = 'cce'

     link_paths = { 'cc'  : 'cc',
                    'cxx' : 'c++',
@@ -54,5 +54,5 @@ class Craype(Compiler):

     @classmethod
     def default_version(cls, comp):
-        return get_compiler_version(comp, r'([Vv]ersion).*(\d+(\.\d+)+)')
+        return get_compiler_version(comp, '-V', r'[Vv]ersion.*(\d+(\.\d+)+)')
```

@mpbelhorn Is this aspect of your branch working? You mentioned your branch isn't pull ready, but is that related to this issue or entirely separate?

@becker33 It appears to work on Titan, but I hadn't testing it on other systems or checked that `cce` is the right name when I posted. It does appear that `cce` is the correct module name on Cori, Titan, Edison, Eos, etc. That branch updates the python module to use the more correct name 'cray' instead of 'craype' for the Cray compiler suite. I've tested it on Titan and it seems OK. @robertdfrench Does this work for you?

It occurs to me the better name is `cce` as that is the name of the module so it follows the other compilers that the `spack compilers` shows the same name used in specs.


Resolving patch:
diff --git a/lib/spack/spack/operating_systems/cnl.py b/lib/spack/spack/operating_systems/cnl.py
--- a/lib/spack/spack/operating_systems/cnl.py
+++ b/lib/spack/spack/operating_systems/cnl.py
@@ -23,7 +23,6 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 ##############################################################################
 import re
-import os
 
 from spack.architecture import OperatingSystem
 from spack.util.executable import *
@@ -67,17 +66,10 @@ def find_compiler(self, cmp_cls, *paths):
             modulecmd = which('modulecmd')
             modulecmd.add_default_arg('python')
 
-            # Save the environment variable to restore later
-            old_modulepath = os.environ['MODULEPATH']
-            # if given any explicit paths, search them for module files too
-            if paths:
-                module_paths = ':' + ':'.join(p for p in paths)
-                os.environ['MODULEPATH'] = module_paths
-
             output = modulecmd(
                 'avail', cmp_cls.PrgEnv_compiler, output=str, error=str)
-            matches = re.findall(
-                r'(%s)/([\d\.]+[\d])' % cmp_cls.PrgEnv_compiler, output)
+            version_regex = r'(%s)/([\d\.]+[\d])' % cmp_cls.PrgEnv_compiler
+            matches = re.findall(version_regex, output)
             for name, version in matches:
                 v = version
                 comp = cmp_cls(
@@ -87,8 +79,4 @@ def find_compiler(self, cmp_cls, *paths):
 
                 compilers.append(comp)
 
-            # Restore modulepath environment variable
-            if paths:
-                os.environ['MODULEPATH'] = old_modulepath
-
         return compilers


Test patch: