From a6d433b937ee7d418289b23585a6d53343f1f14e Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Fri, 4 Dec 2020 16:27:03 +0100 Subject: [PATCH] concretizer: restrict maximizing variant values to MV variants (#20194) --- lib/spack/spack/solver/concretize.lp | 8 ++++++-- lib/spack/spack/test/concretize.py | 4 ++++ .../dep-with-variants-if-develop-root/package.py | 11 +++++++++++ .../packages/dep-with-variants-if-develop/package.py | 12 ++++++++++++ 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 var/spack/repos/builtin.mock/packages/dep-with-variants-if-develop-root/package.py create mode 100644 var/spack/repos/builtin.mock/packages/dep-with-variants-if-develop/package.py diff --git a/lib/spack/spack/solver/concretize.lp b/lib/spack/spack/solver/concretize.lp index 2de7030ddf..acfed6f599 100644 --- a/lib/spack/spack/solver/concretize.lp +++ b/lib/spack/spack/solver/concretize.lp @@ -508,7 +508,9 @@ root(Dependency, 1) :- not root(Dependency), node(Dependency). % need to maximize their number below to ensure they're all set #maximize { 1@13,Package,Variant,Value - : variant_not_default(Package, Variant, Value, Weight), root(Package) + : variant_not_default(Package, Variant, Value, Weight), + not variant_single_value(Package, Variant), + root(Package) }. #minimize{ Weight@13,Provider @@ -531,7 +533,9 @@ root(Dependency, 1) :- not root(Dependency), node(Dependency). % need to maximize their number below to ensure they're all set #maximize { 1@8,Package,Variant,Value - : variant_not_default(Package, Variant, Value, Weight), not root(Package) + : variant_not_default(Package, Variant, Value, Weight), + not variant_single_value(Package, Variant), + not root(Package) }. % Try to maximize the number of compiler matches in the DAG, diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py index fed0432f91..2e96eea4af 100644 --- a/lib/spack/spack/test/concretize.py +++ b/lib/spack/spack/test/concretize.py @@ -975,3 +975,7 @@ def test_all_patches_applied(self): spec.concretize() assert ((uuidpatch, localpatch) == spec['libelf'].variants['patches'].value) + + def test_dont_select_version_that_brings_more_variants_in(self): + s = Spec('dep-with-variants-if-develop-root').concretized() + assert s['dep-with-variants-if-develop'].satisfies('@1.0') diff --git a/var/spack/repos/builtin.mock/packages/dep-with-variants-if-develop-root/package.py b/var/spack/repos/builtin.mock/packages/dep-with-variants-if-develop-root/package.py new file mode 100644 index 0000000000..00162ee200 --- /dev/null +++ b/var/spack/repos/builtin.mock/packages/dep-with-variants-if-develop-root/package.py @@ -0,0 +1,11 @@ +# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) +class DepWithVariantsIfDevelopRoot(Package): + """Package that adds a dependency with many variants only at @develop""" + homepage = "https://dev.null" + + version('1.0') + + depends_on('dep-with-variants-if-develop') diff --git a/var/spack/repos/builtin.mock/packages/dep-with-variants-if-develop/package.py b/var/spack/repos/builtin.mock/packages/dep-with-variants-if-develop/package.py new file mode 100644 index 0000000000..ecb11224b3 --- /dev/null +++ b/var/spack/repos/builtin.mock/packages/dep-with-variants-if-develop/package.py @@ -0,0 +1,12 @@ +# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) +class DepWithVariantsIfDevelop(Package): + """Package that adds a dependency with many variants only at @develop""" + homepage = "https://dev.null" + + version('develop') + version('1.0') + + depends_on('dep-with-variants', when='@develop')