Avoid null reference in arch concretization (#2596)

Fixes #2587

The concretizer falls back on using the root architecture (followed
by the default system architecture) to fill in unspecified arch
properties for a spec. It failed to check cases where the root could
be None.
This commit is contained in:
scheibelp 2017-04-04 15:03:52 -07:00 committed by becker33
parent 3866dba265
commit 0038ea84a1

View file

@ -222,9 +222,10 @@ def concretize_architecture(self, spec):
spec.architecture = spack.spec.ArchSpec(sys_arch)
spec_changed = True
default_archs = [root_arch, sys_arch]
while not spec.architecture.concrete and default_archs:
arch = default_archs.pop(0)
default_archs = list(x for x in [root_arch, sys_arch] if x)
for arch in default_archs:
if spec.architecture.concrete:
break
replacement_fields = [k for k, v in iteritems(arch.to_cmp_dict())
if v and not getattr(spec.architecture, k)]
@ -232,6 +233,9 @@ def concretize_architecture(self, spec):
setattr(spec.architecture, field, getattr(arch, field))
spec_changed = True
if not spec.architecture.concrete:
raise InsufficientArchitectureInfoError(spec, default_archs)
return spec_changed
def concretize_variants(self, spec):
@ -466,6 +470,17 @@ def __init__(self, spec):
% (spec.name, spec.versions))
class InsufficientArchitectureInfoError(spack.error.SpackError):
"""Raised when details on architecture cannot be collected from the
system"""
def __init__(self, spec, archs):
super(InsufficientArchitectureInfoError, self).__init__(
"Cannot determine necessary architecture information for '%s': %s"
% (spec.name, str(archs)))
class NoBuildError(spack.error.SpackError):
"""Raised when a package is configured with the buildable option False, but
no satisfactory external versions can be found"""