Repository: spack/spack

Issue:
On Cray, infinite recursion when calling env/cc
@mpbelhorn @robertdfrench @mamelara I think there is a typo in `lib/spack/spack/platforms/cray.py` that can cause an infinite recursion when spack calls `env/cc`. The change listed below fixed this problem for me.  Can you confirm that this is a bug and that my change is correct?

```
diff --git a/lib/spack/spack/platforms/cray.py b/lib/spack/spack/platforms/cray.py
index 2a3b81c..0059b49 100644
--- a/lib/spack/spack/platforms/cray.py
+++ b/lib/spack/spack/platforms/cray.py
@@ -98,7 +98,7 @@ class Cray(Platform):
         cray_wrapper_names = join_path(spack.build_env_path, 'cray')
         if os.path.isdir(cray_wrapper_names):
             env.prepend_path('PATH', cray_wrapper_names)
-            env.prepend_path('SPACK_ENV_PATHS', cray_wrapper_names)
+            env.prepend_path('SPACK_ENV_PATH', cray_wrapper_names)

     @classmethod
     def detect(self):
```

On Cray, infinite recursion when calling env/cc
@mpbelhorn @robertdfrench @mamelara I think there is a typo in `lib/spack/spack/platforms/cray.py` that can cause an infinite recursion when spack calls `env/cc`. The change listed below fixed this problem for me.  Can you confirm that this is a bug and that my change is correct?

```
diff --git a/lib/spack/spack/platforms/cray.py b/lib/spack/spack/platforms/cray.py
index 2a3b81c..0059b49 100644
--- a/lib/spack/spack/platforms/cray.py
+++ b/lib/spack/spack/platforms/cray.py
@@ -98,7 +98,7 @@ class Cray(Platform):
         cray_wrapper_names = join_path(spack.build_env_path, 'cray')
         if os.path.isdir(cray_wrapper_names):
             env.prepend_path('PATH', cray_wrapper_names)
-            env.prepend_path('SPACK_ENV_PATHS', cray_wrapper_names)
+            env.prepend_path('SPACK_ENV_PATH', cray_wrapper_names)

     @classmethod
     def detect(self):
```



Discussion:
@KineticTheory I'm curious if this is related to an infinite loop I've seen where spack hits it's own compiler wrapper `cc` trying to invoke the cray wrapper. I worked around that by using the full path to the cray compiler wrappers, but my hack doesn't keep track of/respect changes in the CrayPE version:

```
diff --git a/lib/spack/spack/operating_systems/cnl.py b/lib/spack/spack/operating_systems/cnl.py
index dbd2775..a1b2a74 100644
--- a/lib/spack/spack/operating_systems/cnl.py
+++ b/lib/spack/spack/operating_systems/cnl.py
@@ -55,9 +55,13 @@ class Cnl(OperatingSystem):
                 r'(%s)/([\d\.]+[\d])' % cmp_cls.PrgEnv_compiler, output)
             for name, version in matches:
                 v = version
+                craype_dir = os.environ.get('CRAYPE_DIR', '')
+                if craype_dir:
+                    craype_dir = os.path.join(craype_dir, 'bin')
                 comp = cmp_cls(
                     spack.spec.CompilerSpec(name + '@' + v), self,
-                    ['cc', 'CC', 'ftn'], [cmp_cls.PrgEnv, name + '/' + v])
+                    [os.path.join(craype_dir, i) for i in ('cc', 'CC', 'ftn')],
+                    [cmp_cls.PrgEnv, name + '/' + v])

                 compilers.append(comp)
```

Your change is correct. Could you submit a PR with it?

From: Kelly Thompson <notifications@github.com<mailto:notifications@github.com>>
Reply-To: LLNL/spack <reply@reply.github.com<mailto:reply@reply.github.com>>
Date: Wednesday, August 3, 2016 at 10:54 AM
To: LLNL/spack <spack@noreply.github.com<mailto:spack@noreply.github.com>>
Subject: [LLNL/spack] On Cray, infinite recursion when calling env/cc (#1428)

@mpbelhornhttps://github.com/mpbelhorn @robertdfrenchhttps://github.com/robertdfrench @mamelarahttps://github.com/mamelara I think there is a typo in lib/spack/spack/platforms/cray.py that can cause an infinite recursion when spack calls env/cc. The change listed below fixed this problem for me. Can you confirm that this is a bug and that my change is correct?

diff --git a/lib/spack/spack/platforms/cray.py b/lib/spack/spack/platforms/cray.py
index 2a3b81c..0059b49 100644
--- a/lib/spack/spack/platforms/cray.py
+++ b/lib/spack/spack/platforms/cray.py
@@ -98,7 +98,7 @@ class Cray(Platform):
         cray_wrapper_names = join_path(spack.build_env_path, 'cray')
         if os.path.isdir(cray_wrapper_names):
             env.prepend_path('PATH', cray_wrapper_names)
-            env.prepend_path('SPACK_ENV_PATHS', cray_wrapper_names)
- ```
         env.prepend_path('SPACK_ENV_PATH', cray_wrapper_names)
  ```
  
   @classmethod
   def detect(self):

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHubhttps://github.com/LLNL/spack/issues/1428, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ANUwcNaS5aJml4bsqvionVl-6mIdANRjks5qcNXKgaJpZM4Jb5_-.

@KineticTheory I'm curious if this is related to an infinite loop I've seen where spack hits it's own compiler wrapper `cc` trying to invoke the cray wrapper. I worked around that by using the full path to the cray compiler wrappers, but my hack doesn't keep track of/respect changes in the CrayPE version:

```
diff --git a/lib/spack/spack/operating_systems/cnl.py b/lib/spack/spack/operating_systems/cnl.py
index dbd2775..a1b2a74 100644
--- a/lib/spack/spack/operating_systems/cnl.py
+++ b/lib/spack/spack/operating_systems/cnl.py
@@ -55,9 +55,13 @@ class Cnl(OperatingSystem):
                 r'(%s)/([\d\.]+[\d])' % cmp_cls.PrgEnv_compiler, output)
             for name, version in matches:
                 v = version
+                craype_dir = os.environ.get('CRAYPE_DIR', '')
+                if craype_dir:
+                    craype_dir = os.path.join(craype_dir, 'bin')
                 comp = cmp_cls(
                     spack.spec.CompilerSpec(name + '@' + v), self,
-                    ['cc', 'CC', 'ftn'], [cmp_cls.PrgEnv, name + '/' + v])
+                    [os.path.join(craype_dir, i) for i in ('cc', 'CC', 'ftn')],
+                    [cmp_cls.PrgEnv, name + '/' + v])

                 compilers.append(comp)
```

Your change is correct. Could you submit a PR with it?

From: Kelly Thompson <notifications@github.com<mailto:notifications@github.com>>
Reply-To: LLNL/spack <reply@reply.github.com<mailto:reply@reply.github.com>>
Date: Wednesday, August 3, 2016 at 10:54 AM
To: LLNL/spack <spack@noreply.github.com<mailto:spack@noreply.github.com>>
Subject: [LLNL/spack] On Cray, infinite recursion when calling env/cc (#1428)

@mpbelhornhttps://github.com/mpbelhorn @robertdfrenchhttps://github.com/robertdfrench @mamelarahttps://github.com/mamelara I think there is a typo in lib/spack/spack/platforms/cray.py that can cause an infinite recursion when spack calls env/cc. The change listed below fixed this problem for me. Can you confirm that this is a bug and that my change is correct?

diff --git a/lib/spack/spack/platforms/cray.py b/lib/spack/spack/platforms/cray.py
index 2a3b81c..0059b49 100644
--- a/lib/spack/spack/platforms/cray.py
+++ b/lib/spack/spack/platforms/cray.py
@@ -98,7 +98,7 @@ class Cray(Platform):
         cray_wrapper_names = join_path(spack.build_env_path, 'cray')
         if os.path.isdir(cray_wrapper_names):
             env.prepend_path('PATH', cray_wrapper_names)
-            env.prepend_path('SPACK_ENV_PATHS', cray_wrapper_names)
- ```
         env.prepend_path('SPACK_ENV_PATH', cray_wrapper_names)
  ```
  
   @classmethod
   def detect(self):

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHubhttps://github.com/LLNL/spack/issues/1428, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ANUwcNaS5aJml4bsqvionVl-6mIdANRjks5qcNXKgaJpZM4Jb5_-.


Resolving patch:
diff --git a/lib/spack/spack/platforms/cray.py b/lib/spack/spack/platforms/cray.py
--- a/lib/spack/spack/platforms/cray.py
+++ b/lib/spack/spack/platforms/cray.py
@@ -98,7 +98,7 @@ def setup_platform_environment(self, pkg, env):
         cray_wrapper_names = join_path(spack.build_env_path, 'cray')
         if os.path.isdir(cray_wrapper_names):
             env.prepend_path('PATH', cray_wrapper_names)
-            env.prepend_path('SPACK_ENV_PATHS', cray_wrapper_names)
+            env.prepend_path('SPACK_ENV_PATH', cray_wrapper_names)
 
     @classmethod
     def detect(self):


Test patch: