ASP-based solver: fix provider logic (#24351)

This commit fixes a subtle bug that may occur when
a package is a "possible_provider" of a virtual but
no "provides_virtual" can be deduced. In that case
the cardinality constraint on "provides_virtual"
may arbitrarily assign a package the role of provider
even if the constraints for it to be one are not fulfilled.

The fix reworks the logic around three concepts:
- "possible_provider": a package may provide a virtual if some constraints are met
- "provides_virtual": a package meet the constraints to provide a virtual
- "provider": a package selected to provide a virtual
This commit is contained in:
Massimiliano Culpo
2021-06-22 20:37:24 +02:00
committed by GitHub
parent 02b92dbf10
commit acc11f676d
4 changed files with 58 additions and 10 deletions

View File

@@ -0,0 +1,15 @@
# Copyright 2013-2021 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 UnsatProvider(Package):
"""This package has a dependency on a virtual that cannot be provided"""
homepage = "http://www.example.com"
url = "http://www.example.com/v1.0.tgz"
version('1.0', sha256='foobarbaz')
variant('foo', default=True, description='')
provides('unsatvdep', when='+foo')
conflicts('+foo')

View File

@@ -0,0 +1,12 @@
# Copyright 2013-2021 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 UnsatVirtualDependency(Package):
"""This package has a dependency on a virtual that cannot be provided"""
homepage = "http://www.example.com"
url = "http://www.example.com/v1.0.tgz"
version('1.0', sha256='foobarbaz')
depends_on('unsatvdep')