diff options
author | Massimiliano Culpo <massimiliano.culpo@gmail.com> | 2020-11-26 13:10:48 +0100 |
---|---|---|
committer | Tamara Dahlgren <dahlgren1@llnl.gov> | 2021-02-17 17:07:16 -0800 |
commit | b326d59e10046f75b65c8fcbeb691faa5ea7a71a (patch) | |
tree | c1b1bf5717653b519f70148c3268fe9eca3b40c7 /lib | |
parent | 0ae49821e2e1ccb6fd179b1b020e263c1d9db8f2 (diff) | |
download | spack-b326d59e10046f75b65c8fcbeb691faa5ea7a71a.tar.gz spack-b326d59e10046f75b65c8fcbeb691faa5ea7a71a.tar.bz2 spack-b326d59e10046f75b65c8fcbeb691faa5ea7a71a.tar.xz spack-b326d59e10046f75b65c8fcbeb691faa5ea7a71a.zip |
concretizer: prioritize matching compilers over newer versions (#20020)
fixes #20019
Before this modification having a newer version of a node came
at higher priority in the optimization than having matching
compilers. This could result in unexpected configurations for
packages with conflict directives on compilers of the type:
conflicts('%gcc@X.Y:', when='@:A.B')
where changing the compiler for just that node is preferred to
lower the node version to less than 'A.B'. Now the priority has
been switched so the solver will try to lower the version of the
nodes in question before changing their compiler.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/solver/concretize.lp | 14 | ||||
-rw-r--r-- | lib/spack/spack/test/concretize.py | 15 | ||||
-rw-r--r-- | lib/spack/spack/test/data/config/compilers.yaml | 9 |
3 files changed, 32 insertions, 6 deletions
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 @@ class TestConcretize(object): 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 @@ -103,6 +103,15 @@ compilers: 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 paths: |