summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorscheibelp <scheibel1@llnl.gov>2017-12-14 17:54:57 -0800
committerGitHub <noreply@github.com>2017-12-14 17:54:57 -0800
commit020ce7735d5b2b8873b36278ce476035c20ce024 (patch)
tree9066d1a0ff4761df163282c8a961db528964dfc1 /lib
parent1aed3f7c01bc6590618af5be79f0033a9cd44761 (diff)
downloadspack-020ce7735d5b2b8873b36278ce476035c20ce024.tar.gz
spack-020ce7735d5b2b8873b36278ce476035c20ce024.tar.bz2
spack-020ce7735d5b2b8873b36278ce476035c20ce024.tar.xz
spack-020ce7735d5b2b8873b36278ce476035c20ce024.zip
Skip collection of compilers which report an empty version (#6684)
Fixes #6200 For compilers that successfully run a version detection script but don't actually return a version, Spack was keeping track of the empty version and then failing when attempting to construct a compiler spec. This skips any attempt to add a compiler entry when no version is reported (but logs when a compiler fails to report a version).
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/compiler.py44
-rw-r--r--lib/spack/spack/test/compilers.py14
2 files changed, 39 insertions, 19 deletions
diff --git a/lib/spack/spack/compiler.py b/lib/spack/spack/compiler.py
index e19601116f..451051364c 100644
--- a/lib/spack/spack/compiler.py
+++ b/lib/spack/spack/compiler.py
@@ -278,27 +278,11 @@ class Compiler(object):
match = re.match(regex, exe)
if match:
- key = (full_path,) + match.groups()
+ key = (full_path,) + match.groups() + (detect_version,)
checks.append(key)
- def check(key):
- try:
- full_path, prefix, suffix = key
- version = detect_version(full_path)
- return (version, prefix, suffix, full_path)
- except ProcessError as e:
- tty.debug(
- "Couldn't get version for compiler %s" % full_path, e)
- return None
- except Exception as e:
- # Catching "Exception" here is fine because it just
- # means something went wrong running a candidate executable.
- tty.debug("Error while executing candidate compiler %s"
- % full_path,
- "%s: %s" % (e.__class__.__name__, e))
- return None
-
- successful = [k for k in parmap(check, checks) if k is not None]
+ successful = [k for k in parmap(_get_versioned_tuple, checks)
+ if k is not None]
# The 'successful' list is ordered like the input paths.
# Reverse it here so that the dict creation (last insert wins)
@@ -322,6 +306,28 @@ class Compiler(object):
str(self.operating_system)))))
+def _get_versioned_tuple(compiler_check_tuple):
+ full_path, prefix, suffix, detect_version = compiler_check_tuple
+ try:
+ version = detect_version(full_path)
+ if (not version) or (not str(version).strip()):
+ tty.debug(
+ "Couldn't get version for compiler %s" % full_path)
+ return None
+ return (version, prefix, suffix, full_path)
+ except ProcessError as e:
+ tty.debug(
+ "Couldn't get version for compiler %s" % full_path, e)
+ return None
+ except Exception as e:
+ # Catching "Exception" here is fine because it just
+ # means something went wrong running a candidate executable.
+ tty.debug("Error while executing candidate compiler %s"
+ % full_path,
+ "%s: %s" % (e.__class__.__name__, e))
+ return None
+
+
class CompilerAccessError(spack.error.SpackError):
def __init__(self, path):
diff --git a/lib/spack/spack/test/compilers.py b/lib/spack/spack/test/compilers.py
index d172d56638..d4f1aa9976 100644
--- a/lib/spack/spack/test/compilers.py
+++ b/lib/spack/spack/test/compilers.py
@@ -27,6 +27,7 @@ from six import iteritems
import spack.spec
import spack.compilers as compilers
+from spack.compiler import _get_versioned_tuple
@pytest.mark.usefixtures('config')
@@ -49,6 +50,19 @@ class TestCompilers(object):
assert len(filtered) == 1
+def test_version_detection_is_empty():
+ no_version = lambda x: None
+ compiler_check_tuple = ('/usr/bin/gcc', '', r'\d\d', no_version)
+ assert not _get_versioned_tuple(compiler_check_tuple)
+
+
+def test_version_detection_is_successful():
+ version = lambda x: '4.9'
+ compiler_check_tuple = ('/usr/bin/gcc', '', r'\d\d', version)
+ assert _get_versioned_tuple(compiler_check_tuple) == (
+ '4.9', '', r'\d\d', '/usr/bin/gcc')
+
+
def test_compiler_flags_from_config_are_grouped():
compiler_entry = {
'spec': 'intel@17.0.2',