summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/spack/solver/asp.py34
-rw-r--r--lib/spack/spack/test/concretize.py8
-rw-r--r--lib/spack/spack/test/data/config/compilers.yaml14
3 files changed, 53 insertions, 3 deletions
diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py
index fa70eed47c..b15c4826be 100644
--- a/lib/spack/spack/solver/asp.py
+++ b/lib/spack/spack/solver/asp.py
@@ -31,6 +31,7 @@ import llnl.util.tty.color as color
import spack
import spack.architecture
import spack.cmd
+import spack.compilers
import spack.config
import spack.dependency
import spack.error
@@ -829,6 +830,18 @@ class SpackSolverSetup(object):
f = fn.default_compiler_preference(cspec.name, cspec.version, i)
self.gen.fact(f)
+ # Enumerate target families. This may be redundant, but compilers with
+ # custom versions will be able to concretize properly.
+ for entry in spack.compilers.all_compilers_config():
+ compiler_entry = entry['compiler']
+ cspec = spack.spec.CompilerSpec(compiler_entry['spec'])
+ if not compiler_entry.get('target', None):
+ continue
+
+ self.gen.fact(fn.compiler_supports_target(
+ cspec.name, cspec.version, compiler_entry['target']
+ ))
+
def compiler_supports_os(self):
compilers_yaml = spack.compilers.all_compilers_config()
for entry in compilers_yaml:
@@ -1230,7 +1243,7 @@ class SpackSolverSetup(object):
if dep.versions.concrete:
self.possible_versions[dep.name].add(dep.version)
- def _supported_targets(self, compiler, targets):
+ def _supported_targets(self, compiler_name, compiler_version, targets):
"""Get a list of which targets are supported by the compiler.
Results are ordered most to least recent.
@@ -1239,7 +1252,7 @@ class SpackSolverSetup(object):
for target in targets:
try:
- target.optimization_flags(compiler.name, compiler.version)
+ target.optimization_flags(compiler_name, compiler_version)
supported.append(target)
except archspec.cpu.UnsupportedMicroarchitecture:
continue
@@ -1289,7 +1302,22 @@ class SpackSolverSetup(object):
# TODO: investigate this.
best_targets = set([uarch.family.name])
for compiler in sorted(compilers):
- supported = self._supported_targets(compiler, compatible_targets)
+ supported = self._supported_targets(
+ compiler.name, compiler.version, compatible_targets
+ )
+
+ # If we can't find supported targets it may be due to custom
+ # versions in the spec, e.g. gcc@foo. Try to match the
+ # real_version from the compiler object to get more accurate
+ # results.
+ if not supported:
+ compiler_obj = spack.compilers.compilers_for_spec(compiler)
+ compiler_obj = compiler_obj[0]
+ supported = self._supported_targets(
+ compiler.name,
+ compiler_obj.real_version,
+ compatible_targets
+ )
if not supported:
continue
diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py
index e5cd8b162a..8366ecca14 100644
--- a/lib/spack/spack/test/concretize.py
+++ b/lib/spack/spack/test/concretize.py
@@ -959,3 +959,11 @@ class TestConcretize(object):
# Check that non-default variant values are forced on the dependency
d = s['dep-with-variants']
assert '+foo+bar+baz' in d
+
+ @pytest.mark.regression('20055')
+ def test_custom_compiler_version(self):
+ if spack.config.get('config:concretizer') == 'original':
+ pytest.xfail('Known failure of the original concretizer')
+
+ s = Spec('a %gcc@foo os=redhat6').concretized()
+ assert '%gcc@foo' in s
diff --git a/lib/spack/spack/test/data/config/compilers.yaml b/lib/spack/spack/test/data/config/compilers.yaml
index 3a63796941..641331dc9f 100644
--- a/lib/spack/spack/test/data/config/compilers.yaml
+++ b/lib/spack/spack/test/data/config/compilers.yaml
@@ -8,6 +8,7 @@ compilers:
f77: None
fc: None
modules: 'None'
+ target: x86_64
- compiler:
spec: gcc@4.5.0
operating_system: {0.name}{0.version}
@@ -17,6 +18,7 @@ compilers:
f77: None
fc: None
modules: 'None'
+ target: x86_64
- compiler:
spec: clang@3.3
operating_system: CNL
@@ -35,6 +37,7 @@ compilers:
f77: None
fc: None
modules: 'None'
+ target: x86_64
- compiler:
spec: clang@3.3
operating_system: yosemite
@@ -44,6 +47,7 @@ compilers:
f77: None
fc: None
modules: 'None'
+ target: x86_64
- compiler:
paths:
cc: /path/to/gcc
@@ -62,6 +66,7 @@ compilers:
operating_system: SuSE11
spec: gcc@4.5.0
modules: 'None'
+ target: x86_64
- compiler:
paths:
cc: /path/to/gcc
@@ -71,6 +76,7 @@ compilers:
operating_system: yosemite
spec: gcc@4.5.0
modules: 'None'
+ target: x86_64
- compiler:
paths:
cc: /path/to/gcc
@@ -80,6 +86,7 @@ compilers:
operating_system: elcapitan
spec: gcc@4.5.0
modules: 'None'
+ target: x86_64
- compiler:
spec: clang@3.3
operating_system: elcapitan
@@ -89,6 +96,7 @@ compilers:
f77: None
fc: None
modules: 'None'
+ target: x86_64
- compiler:
spec: gcc@4.7.2
operating_system: redhat6
@@ -102,6 +110,7 @@ compilers:
cxxflags: -O0 -g
fflags: -O0 -g
modules: 'None'
+ target: x86_64
- compiler:
spec: gcc@4.4.0
operating_system: redhat6
@@ -123,6 +132,7 @@ compilers:
cflags: -O3
cxxflags: -O3
modules: 'None'
+ target: x86_64
- compiler:
spec: clang@8.0.0
operating_system: redhat7
@@ -135,6 +145,7 @@ compilers:
cflags: -O3
cxxflags: -O3
modules: 'None'
+ target: x86_64
- compiler:
spec: apple-clang@9.1.0
operating_system: elcapitan
@@ -144,6 +155,7 @@ compilers:
f77: None
fc: None
modules: 'None'
+ target: x86_64
- compiler:
spec: gcc@foo
operating_system: redhat6
@@ -153,6 +165,7 @@ compilers:
f77: /path/to/gfortran
fc: /path/to/gfortran
modules: 'None'
+ target: x86_64
- compiler:
spec: gcc@4.4.0-special
operating_system: redhat6
@@ -162,3 +175,4 @@ compilers:
f77: /path/to/gfortran
fc: /path/to/gfortran
modules: 'None'
+ target: x86_64