concretizer: handle compiler existence check settings
To handle unknown compilers propely in tests (and elsewhere), we need to add unknown compilers from the spec to the list of possible compilers. Rework how the compiler list is generated and includes compilers from specs if the existence check is disabled.
This commit is contained in:
parent
3b648c294e
commit
35ae4c0ddd
1 changed files with 27 additions and 4 deletions
|
@ -305,7 +305,7 @@ def available_compilers(self):
|
||||||
"""Facts about available compilers."""
|
"""Facts about available compilers."""
|
||||||
|
|
||||||
self.h2("Available compilers")
|
self.h2("Available compilers")
|
||||||
compilers = spack.compilers.all_compiler_specs()
|
compilers = self.possible_compilers
|
||||||
|
|
||||||
compiler_versions = collections.defaultdict(lambda: set())
|
compiler_versions = collections.defaultdict(lambda: set())
|
||||||
for compiler in compilers:
|
for compiler in compilers:
|
||||||
|
@ -323,7 +323,7 @@ def compiler_defaults(self):
|
||||||
"""Set compiler defaults, given a list of possible compilers."""
|
"""Set compiler defaults, given a list of possible compilers."""
|
||||||
self.h2("Default compiler preferences")
|
self.h2("Default compiler preferences")
|
||||||
|
|
||||||
compiler_list = [c.spec for c in self.possible_compilers]
|
compiler_list = self.possible_compilers.copy()
|
||||||
compiler_list = sorted(
|
compiler_list = sorted(
|
||||||
compiler_list, key=lambda x: (x.name, x.version), reverse=True)
|
compiler_list, key=lambda x: (x.name, x.version), reverse=True)
|
||||||
ppk = spack.package_prefs.PackagePrefs("all", 'compiler', all=False)
|
ppk = spack.package_prefs.PackagePrefs("all", 'compiler', all=False)
|
||||||
|
@ -623,7 +623,7 @@ def arch_defaults(self):
|
||||||
# consider the *best* target that each compiler supports, along
|
# consider the *best* target that each compiler supports, along
|
||||||
# with the family.
|
# with the family.
|
||||||
compatible_targets = [uarch] + uarch.ancestors
|
compatible_targets = [uarch] + uarch.ancestors
|
||||||
compilers = compilers_for_default_arch()
|
compilers = self.possible_compilers
|
||||||
|
|
||||||
# this loop can be used to limit the number of targets
|
# this loop can be used to limit the number of targets
|
||||||
# considered. Right now we consider them all, but it seems that
|
# considered. Right now we consider them all, but it seems that
|
||||||
|
@ -670,6 +670,29 @@ def virtual_providers(self):
|
||||||
# TODO: handle versioned and conditional virtuals
|
# TODO: handle versioned and conditional virtuals
|
||||||
self.fact(fn.provides_virtual(provider.name, vspec))
|
self.fact(fn.provides_virtual(provider.name, vspec))
|
||||||
|
|
||||||
|
def generate_possible_compilers(self, specs):
|
||||||
|
default_arch = spack.spec.ArchSpec(spack.architecture.sys_type())
|
||||||
|
compilers = spack.compilers.compilers_for_arch(default_arch)
|
||||||
|
cspecs = set([c.spec for c in compilers])
|
||||||
|
|
||||||
|
# add compiler specs from the input line to possibilities if we
|
||||||
|
# don't require compilers to exist.
|
||||||
|
strict = spack.concretize.Concretizer.check_for_compiler_existence
|
||||||
|
for spec in specs:
|
||||||
|
for s in spec.traverse():
|
||||||
|
if (not s.compiler
|
||||||
|
or s.compiler in cspecs
|
||||||
|
or not s.compiler.concrete):
|
||||||
|
continue
|
||||||
|
|
||||||
|
if strict:
|
||||||
|
raise spack.concretize.UnavailableCompilerVersionError(
|
||||||
|
s.compiler)
|
||||||
|
else:
|
||||||
|
cspecs.add(s.compiler)
|
||||||
|
|
||||||
|
return cspecs
|
||||||
|
|
||||||
def generate_asp_program(self, specs):
|
def generate_asp_program(self, specs):
|
||||||
"""Write an ASP program for specs.
|
"""Write an ASP program for specs.
|
||||||
|
|
||||||
|
@ -691,7 +714,7 @@ def generate_asp_program(self, specs):
|
||||||
pkgs = set(possible)
|
pkgs = set(possible)
|
||||||
|
|
||||||
# get possible compilers
|
# get possible compilers
|
||||||
self.possible_compilers = compilers_for_default_arch()
|
self.possible_compilers = self.generate_possible_compilers(specs)
|
||||||
|
|
||||||
# read the main ASP program from concrtize.lp
|
# read the main ASP program from concrtize.lp
|
||||||
concretize_lp = pkgutil.get_data('spack.solver', 'concretize.lp')
|
concretize_lp = pkgutil.get_data('spack.solver', 'concretize.lp')
|
||||||
|
|
Loading…
Reference in a new issue