summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2015-08-27 02:04:58 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2015-08-27 02:04:58 -0700
commitc5c9ada7b0efd9cec5cf55c4cf71d76b186513ff (patch)
tree0caf25673f4fe46d25fa12aca49a085e1c092340
parent6af49d41fdf5fc9802ef63942de74fcb79a8c1f6 (diff)
downloadspack-c5c9ada7b0efd9cec5cf55c4cf71d76b186513ff.tar.gz
spack-c5c9ada7b0efd9cec5cf55c4cf71d76b186513ff.tar.bz2
spack-c5c9ada7b0efd9cec5cf55c4cf71d76b186513ff.tar.xz
spack-c5c9ada7b0efd9cec5cf55c4cf71d76b186513ff.zip
Fix for GitHub #95
develop: compiler clang@unknown created for /usr/bin/clang-format https://github.com/scalability-llnl/spack/issues/95
-rw-r--r--lib/spack/spack/compiler.py24
1 files changed, 21 insertions, 3 deletions
diff --git a/lib/spack/spack/compiler.py b/lib/spack/spack/compiler.py
index 646050d267..1e800a8979 100644
--- a/lib/spack/spack/compiler.py
+++ b/lib/spack/spack/compiler.py
@@ -227,14 +227,32 @@ class Compiler(object):
for d in dicts:
all_keys.update(d)
- compilers = []
+ compilers = {}
for k in all_keys:
ver, pre, suf = k
+
+ # Skip compilers with unknown version.
+ if ver == 'unknown':
+ continue
+
paths = tuple(pn[k] if k in pn else None for pn in dicts)
spec = spack.spec.CompilerSpec(cls.name, ver)
- compilers.append(cls(spec, *paths))
- return compilers
+ if ver in compilers:
+ prev = compilers[ver]
+
+ # prefer the one with more compilers.
+ prev_paths = [prev.cc, prev.cxx, prev.f77, prev.fc]
+ newcount = len([p for p in paths if p is not None])
+ prevcount = len([p for p in prev_paths if p is not None])
+
+ # Don't add if it's not an improvement over prev compiler.
+ if newcount <= prevcount:
+ continue
+
+ compilers[ver] = cls(spec, *paths)
+
+ return list(compilers.values())
def __repr__(self):