concretizer: exempt already-installed specs from compiler and variant rules

Concrete specs that are already installed or that come from a buildcache
may have compilers and variant settings that we do not recognize, but that
shouldn't prevent reuse (at least not until we have a more detailed compiler
model).

- [x] make sure compiler and variant consistency rules only apply to
      built specs
- [x] don't validate concrete specs on input, either -- they're concrete
      and we shouldn't apply today's rules to yesterday's build
This commit is contained in:
Todd Gamblin 2021-11-03 22:20:39 -07:00
parent 49ed41b028
commit a4a2ed3c34
2 changed files with 22 additions and 7 deletions

View File

@ -1423,6 +1423,10 @@ def generate_possible_compilers(self, specs):
strict = spack.concretize.Concretizer().check_for_compiler_existence
for spec in specs:
for s in spec.traverse():
# we don't need to validate compilers for already-built specs
if s.concrete:
continue
if not s.compiler or not s.compiler.concrete:
continue

View File

@ -372,10 +372,13 @@ variant(Package, Variant) :- variant_condition(ID, Package, Variant),
% a variant cannot be set if it is not a variant on the package
:- variant_set(Package, Variant),
not variant(Package, Variant),
build(Package),
error("Unsatisfied conditional variants cannot be set").
% a variant cannot take on a value if it is not a variant of the package
:- variant_value(Package, Variant, _), not variant(Package, Variant),
:- variant_value(Package, Variant, _),
not variant(Package, Variant),
build(Package),
error("Unsatisfied conditional variants cannot take on a variant value").
% one variant value for single-valued variants.
@ -386,6 +389,7 @@ variant(Package, Variant) :- variant_condition(ID, Package, Variant),
:- node(Package),
variant(Package, Variant),
variant_single_value(Package, Variant),
build(Package),
error("Single valued variants must have a single value").
% at least one variant value for multi-valued variants.
@ -396,6 +400,7 @@ variant(Package, Variant) :- variant_condition(ID, Package, Variant),
:- node(Package),
variant(Package, Variant),
not variant_single_value(Package, Variant),
build(Package),
error("Internal error: All variants must have a value").
% if a variant is set to anything, it is considered 'set'.
@ -417,6 +422,7 @@ variant_set(Package, Variant) :- variant_set(Package, Variant, _).
variant_value_from_disjoint_sets(Package, Variant, Value1, Set1),
variant_value_from_disjoint_sets(Package, Variant, Value2, Set2),
Set1 != Set2,
build(Package),
error("Variant values selected from multiple disjoint sets").
% variant_set is an explicitly set variant value. If it's not 'set',
@ -640,10 +646,12 @@ node_target_mismatch(Parent, Dependency)
%-----------------------------------------------------------------------------
compiler(Compiler) :- compiler_version(Compiler, _).
% There must be only one compiler set per node. The compiler
% There must be only one compiler set per built node. The compiler
% is chosen among available versions.
1 { node_compiler_version(Package, Compiler, Version)
: compiler_version(Compiler, Version) } 1 :- node(Package), error("Each node must have exactly one compiler").
1 { node_compiler_version(Package, Compiler, Version) : compiler_version(Compiler, Version) } 1 :-
node(Package),
build(Package),
error("Each node must have exactly one compiler").
% Sometimes we just need to know the compiler and not the version
node_compiler(Package, Compiler) :- node_compiler_version(Package, Compiler, _).
@ -658,11 +666,14 @@ node_compiler(Package, Compiler) :- node_compiler_version(Package, Compiler, _).
% version_satisfies implies that exactly one of the satisfying versions
% is the package's version, and vice versa.
1 { node_compiler_version(Package, Compiler, Version)
: node_compiler_version_satisfies(Package, Compiler, Constraint, Version) } 1
:- node_compiler_version_satisfies(Package, Compiler, Constraint), error("Internal error: node compiler version mismatch").
: node_compiler_version_satisfies(Package, Compiler, Constraint, Version) } 1 :-
node_compiler_version_satisfies(Package, Compiler, Constraint),
error("Internal error: node compiler version mismatch").
node_compiler_version_satisfies(Package, Compiler, Constraint)
:- node_compiler_version(Package, Compiler, Version),
node_compiler_version_satisfies(Package, Compiler, Constraint, Version).
node_compiler_version_satisfies(Package, Compiler, Constraint, Version),
build(Package).
#defined node_compiler_version_satisfies/4.