summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Kosukhin <skosukhin@gmail.com>2017-08-09 18:00:34 +0200
committerbecker33 <becker33@llnl.gov>2017-08-09 09:00:34 -0700
commite463461ed1934c30e71756e6dbfade90d95b56be (patch)
treefab3e9aa3723e27e007ba7474f68daf373bbdc88
parentd6fc2363af65aaa86339a95beec646a68fac6458 (diff)
downloadspack-e463461ed1934c30e71756e6dbfade90d95b56be.tar.gz
spack-e463461ed1934c30e71756e6dbfade90d95b56be.tar.bz2
spack-e463461ed1934c30e71756e6dbfade90d95b56be.tar.xz
spack-e463461ed1934c30e71756e6dbfade90d95b56be.zip
Bugfixes for compiler detection on the Cray platform. (#3075)
* Typo fixes in docstrings. * Let OS classes know if the paths they get were explicitly specified by user. * Fixed regexp for cray compiler version matching. * Replaced LinuxDistro with CrayFrontend for the Cray platform's frontend.
-rw-r--r--lib/spack/spack/architecture.py2
-rw-r--r--lib/spack/spack/cmd/compiler.py3
-rw-r--r--lib/spack/spack/compilers/__init__.py2
-rw-r--r--lib/spack/spack/compilers/cce.py2
-rw-r--r--lib/spack/spack/operating_systems/cray_frontend.py76
-rw-r--r--lib/spack/spack/platforms/cray.py4
6 files changed, 81 insertions, 8 deletions
diff --git a/lib/spack/spack/architecture.py b/lib/spack/spack/architecture.py
index 487948dd4e..27092fb344 100644
--- a/lib/spack/spack/architecture.py
+++ b/lib/spack/spack/architecture.py
@@ -254,7 +254,7 @@ class OperatingSystem(object):
def find_compilers(self, *paths):
"""
- Return a list of compilers found in the suppied paths.
+ Return a list of compilers found in the supplied paths.
This invokes the find() method for each Compiler class,
and appends the compilers detected to a list.
"""
diff --git a/lib/spack/spack/cmd/compiler.py b/lib/spack/spack/cmd/compiler.py
index d5aa25ee8e..356161d3b3 100644
--- a/lib/spack/spack/cmd/compiler.py
+++ b/lib/spack/spack/cmd/compiler.py
@@ -36,7 +36,6 @@ from llnl.util.lang import index_by
from llnl.util.tty.colify import colify
from llnl.util.tty.color import colorize
from spack.spec import CompilerSpec, ArchSpec
-from spack.util.environment import get_path
description = "manage compilers"
section = "system"
@@ -89,8 +88,6 @@ def compiler_find(args):
"""
paths = args.add_paths
- if not paths:
- paths = get_path('PATH')
# Don't initialize compilers config via compilers.get_compiler_config.
# Just let compiler_find do the
diff --git a/lib/spack/spack/compilers/__init__.py b/lib/spack/spack/compilers/__init__.py
index 53b2572ab9..517a0bd5e8 100644
--- a/lib/spack/spack/compilers/__init__.py
+++ b/lib/spack/spack/compilers/__init__.py
@@ -182,7 +182,7 @@ def all_compiler_specs(scope=None, init_config=True):
def find_compilers(*paths):
- """Return a list of compilers found in the suppied paths.
+ """Return a list of compilers found in the supplied paths.
This invokes the find_compilers() method for each operating
system associated with the host platform, and appends
the compilers detected to a list.
diff --git a/lib/spack/spack/compilers/cce.py b/lib/spack/spack/compilers/cce.py
index 936614efac..2a5858f4e8 100644
--- a/lib/spack/spack/compilers/cce.py
+++ b/lib/spack/spack/compilers/cce.py
@@ -52,7 +52,7 @@ class Cce(Compiler):
@classmethod
def default_version(cls, comp):
- return get_compiler_version(comp, '-V', r'[Vv]ersion.*(\d+(\.\d+)+)')
+ return get_compiler_version(comp, '-V', r'[Vv]ersion.*?(\d+(\.\d+)+)')
@property
def openmp_flag(self):
diff --git a/lib/spack/spack/operating_systems/cray_frontend.py b/lib/spack/spack/operating_systems/cray_frontend.py
new file mode 100644
index 0000000000..bf3b76faf2
--- /dev/null
+++ b/lib/spack/spack/operating_systems/cray_frontend.py
@@ -0,0 +1,76 @@
+##############################################################################
+# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.
+# Produced at the Lawrence Livermore National Laboratory.
+#
+# This file is part of Spack.
+# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
+# LLNL-CODE-647188
+#
+# For details, see https://github.com/llnl/spack
+# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License (as
+# published by the Free Software Foundation) version 2.1, February 1999.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
+# conditions of the GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##############################################################################
+import os
+
+from spack.operating_systems.linux_distro import LinuxDistro
+from spack.util.module_cmd import get_module_cmd
+
+
+class CrayFrontend(LinuxDistro):
+ """Represents OS that runs on login and service nodes of the Cray platform.
+ It acts as a regular Linux without Cray-specific modules and compiler
+ wrappers."""
+
+ def find_compilers(self, *paths):
+ """Calls the overridden method but prevents it from detecting Cray
+ compiler wrappers to avoid possible false detections. The detected
+ compilers come into play only if a user decides to work with the Cray's
+ frontend OS as if it was a regular Linux environment."""
+
+ env_bu = None
+
+ # We rely on the fact that the PrgEnv-* modules set the PE_ENV
+ # environment variable.
+ if 'PE_ENV' in os.environ:
+ # Copy environment variables to restore them after the compiler
+ # detection. We expect that the only thing PrgEnv-* modules do is
+ # the environment variables modifications.
+ env_bu = os.environ.copy()
+
+ # Get the name of the module from the environment variable.
+ prg_env = 'PrgEnv-' + os.environ['PE_ENV'].lower()
+
+ # Unload the PrgEnv-* module. By doing this we intentionally
+ # provoke errors when the Cray's compiler wrappers are executed
+ # (Error: A PrgEnv-* modulefile must be loaded.) so they will not
+ # be detected as valid compilers by the overridden method. We also
+ # expect that the modules that add the actual compilers' binaries
+ # into the PATH environment variable (i.e. the following modules:
+ # 'intel', 'cce', 'gcc', etc.) will also be unloaded since they are
+ # specified as prerequisites in the PrgEnv-* modulefiles.
+ modulecmd = get_module_cmd()
+ exec (compile(
+ modulecmd('unload', prg_env, output=str, error=os.devnull),
+ '<string>', 'exec'))
+
+ # Call the overridden method.
+ clist = super(CrayFrontend, self).find_compilers(*paths)
+
+ # Restore the environment.
+ if env_bu is not None:
+ os.environ.clear()
+ os.environ.update(env_bu)
+
+ return clist
diff --git a/lib/spack/spack/platforms/cray.py b/lib/spack/spack/platforms/cray.py
index 9a7301d1f8..411eb32b1c 100644
--- a/lib/spack/spack/platforms/cray.py
+++ b/lib/spack/spack/platforms/cray.py
@@ -28,7 +28,7 @@ import llnl.util.tty as tty
from spack import build_env_path
from spack.util.executable import which
from spack.architecture import Platform, Target, NoPlatformError
-from spack.operating_systems.linux_distro import LinuxDistro
+from spack.operating_systems.cray_frontend import CrayFrontend
from spack.operating_systems.cnl import Cnl
from llnl.util.filesystem import join_path
from spack.util.module_cmd import get_module_cmd
@@ -88,7 +88,7 @@ class Cray(Platform):
else:
raise NoPlatformError()
- front_distro = LinuxDistro()
+ front_distro = CrayFrontend()
back_distro = Cnl()
self.default_os = str(back_distro)