diff --git a/lib/spack/spack/solver/concretize.lp b/lib/spack/spack/solver/concretize.lp index b27b80dc6e..d012bc3cf3 100644 --- a/lib/spack/spack/solver/concretize.lp +++ b/lib/spack/spack/solver/concretize.lp @@ -537,9 +537,6 @@ root(Dependency, 1) :- not root(Dependency), node(Dependency). 1@8,Package,Variant,Value : variant_not_default(Package, Variant, Value, Weight), not root(Package) }. -#minimize{ - Weight@8,Package : version_weight(Package, Weight) -}. % Try to maximize the number of compiler matches in the DAG, % while minimizing the number of nodes. This is done because @@ -548,10 +545,15 @@ root(Dependency, 1) :- not root(Dependency), node(Dependency). #minimize{ 1@7,Package : node(Package) }. #maximize{ Weight@7,Package : compiler_version_match(Package, Weight) }. +% Choose more recent versions for nodes +#minimize{ + Weight@6,Package : version_weight(Package, Weight) +}. + % Try to use preferred compilers -#minimize{ Weight@6,Package : compiler_weight(Package, Weight) }. +#minimize{ Weight@5,Package : compiler_weight(Package, Weight) }. % Maximize the number of matches for targets in the DAG, try % to select the preferred target. -#maximize{ Weight@5,Package : node_target_match(Package, Weight) }. -#minimize{ Weight@4,Package : node_target_weight(Package, Weight) }. +#maximize{ Weight@4,Package : node_target_match(Package, Weight) }. +#minimize{ Weight@3,Package : node_target_weight(Package, Weight) }. diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py index 8640c91a9e..11c2764822 100644 --- a/lib/spack/spack/test/concretize.py +++ b/lib/spack/spack/test/concretize.py @@ -923,3 +923,18 @@ def test_activating_test_dependencies( msg = "Test dependency in package '{0}' is unexpected" node = s[pkg_name] assert not node.dependencies(deptype='test'), msg.format(pkg_name) + + @pytest.mark.regression('20019') + def test_compiler_match_is_preferred_to_newer_version(self): + if spack.config.get('config:concretizer') == 'original': + pytest.xfail('Known failure of the original concretizer') + + # This spec depends on openblas. Openblas has a conflict + # that doesn't allow newer versions with gcc@4.4.0. Check + # that an old version of openblas is selected, rather than + # a different compiler for just that node. + spec_str = 'simple-inheritance+openblas %gcc@4.4.0 os=redhat6' + s = Spec(spec_str).concretized() + + assert 'openblas@0.2.13' in s + assert s['openblas'].satisfies('%gcc@4.4.0') diff --git a/lib/spack/spack/test/data/config/compilers.yaml b/lib/spack/spack/test/data/config/compilers.yaml index 3a2db05e72..3a63796941 100644 --- a/lib/spack/spack/test/data/config/compilers.yaml +++ b/lib/spack/spack/test/data/config/compilers.yaml @@ -102,6 +102,15 @@ compilers: cxxflags: -O0 -g fflags: -O0 -g modules: 'None' +- compiler: + spec: gcc@4.4.0 + operating_system: redhat6 + paths: + cc: /path/to/gcc440 + cxx: /path/to/g++440 + f77: /path/to/gfortran440 + fc: /path/to/gfortran440 + modules: 'None' - compiler: spec: clang@3.5 operating_system: redhat6 diff --git a/var/spack/repos/builtin.mock/packages/openblas/package.py b/var/spack/repos/builtin.mock/packages/openblas/package.py index ff4bda9a27..d97e4091a2 100644 --- a/var/spack/repos/builtin.mock/packages/openblas/package.py +++ b/var/spack/repos/builtin.mock/packages/openblas/package.py @@ -12,5 +12,10 @@ class Openblas(Package): url = "http://github.com/xianyi/OpenBLAS/archive/v0.2.15.tar.gz" version('0.2.15', 'b1190f3d3471685f17cfd1ec1d252ac9') + version('0.2.14', 'b1190f3d3471685f17cfd1ec1d252ac9') + version('0.2.13', 'b1190f3d3471685f17cfd1ec1d252ac9') + + # See #20019 for this conflict + conflicts('%gcc@:4.4.99', when='@0.2.14:') provides('blas')