diff options
author | scheibelp <scheibel1@llnl.gov> | 2017-04-04 15:03:52 -0700 |
---|---|---|
committer | becker33 <becker33@llnl.gov> | 2017-04-04 15:03:52 -0700 |
commit | 0038ea84a1c5e105cdc171b04c7369cdf9b5bd9f (patch) | |
tree | f1cd8e61e6cbaee469ca1e756f81365250da2818 | |
parent | 3866dba2650114e0a50b66def40da02cba531758 (diff) | |
download | spack-0038ea84a1c5e105cdc171b04c7369cdf9b5bd9f.tar.gz spack-0038ea84a1c5e105cdc171b04c7369cdf9b5bd9f.tar.bz2 spack-0038ea84a1c5e105cdc171b04c7369cdf9b5bd9f.tar.xz spack-0038ea84a1c5e105cdc171b04c7369cdf9b5bd9f.zip |
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.
-rw-r--r-- | lib/spack/spack/concretize.py | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/spack/spack/concretize.py b/lib/spack/spack/concretize.py index 6c230a151b..2a5ce65fa4 100644 --- a/lib/spack/spack/concretize.py +++ b/lib/spack/spack/concretize.py @@ -222,9 +222,10 @@ class DefaultConcretizer(object): 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 @@ class DefaultConcretizer(object): 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 @@ class NoValidVersionError(spack.error.SpackError): % (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""" |