Repository: spack/spack

Issue:
Spack concretisation issue on Cray KNL ('NoneType' object has no attribute 'to_cmp_dict')
On the Cray KNL system I see : 

```
$ spack arch
cray-CNL-mic_knl

$ spack spec tau
Input spec
--------------------------------
tau
Normalized
--------------------------------
tau
    ^pdt
Concretized
--------------------------------
Traceback (most recent call last):
  File "/home/kumbhar/spack/bin/spack", line 198, in <module>
    main()
  File "/home/kumbhar/spack/bin/spack", line 175, in main
    return_val = command(parser, args)
  File "/xxxx/home/kumbhar/spack/lib/spack/spack/cmd/spec.py", line 83, in spec
    spec.concretize()
  File "/xxxx/home/kumbhar/spack/lib/spack/spack/spec.py", line 1543, in concretize
    self._concretize_helper())
  File "/xxxx/home/kumbhar/spack/lib/spack/spack/spec.py", line 1362, in _concretize_helper
    changed |= dep.spec._concretize_helper(presets, visited)
  File "/xxxx/home/kumbhar/spack/lib/spack/spack/spec.py", line 1362, in _concretize_helper
    changed |= dep.spec._concretize_helper(presets, visited)
  File "/xxxx/home/kumbhar/spack/lib/spack/spack/spec.py", line 1362, in _concretize_helper
    changed |= dep.spec._concretize_helper(presets, visited)
  File "/xxxx/home/kumbhar/spack/lib/spack/spack/spec.py", line 1372, in _concretize_helper
    (spack.concretizer.concretize_architecture(self),
  File "/xxxx/home/kumbhar/spack/lib/spack/spack/concretize.py", line 270, in concretize_architecture
    replacement_fields = [k for k, v in arch.to_cmp_dict().iteritems()
AttributeError: 'NoneType' object has no attribute 'to_cmp_dict'
```

Quickly looked into `lib/spack/spack/concretize.py` : 

```
        default_archs = [root_arch, sys_arch]
        while not spec.architecture.concrete and default_archs:
            arch = default_archs.pop(0)

            replacement_fields = [k for k, v in arch.to_cmp_dict().iteritems()
                                  if v and not getattr(spec.architecture, k)]
```

And at some point during concretisation, the value of  `default_archs` is:

```
[None, cray-sles12-None]
```

Could someone have a look?


Discussion:
Hi @pramodk I believe I can fix this - my target would be to have a PR before tomorrow

@tgamblin could you merge https://github.com/LLNL/spack/pull/2549 (reverting the PR which assigns frontend architecture to build deps)? I'd like that to merge before fixing this.

Resolving patch:
diff --git a/lib/spack/spack/concretize.py b/lib/spack/spack/concretize.py
--- a/lib/spack/spack/concretize.py
+++ b/lib/spack/spack/concretize.py
@@ -263,9 +263,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 arch.to_cmp_dict().iteritems()
                                   if v and not getattr(spec.architecture, k)]
@@ -273,6 +274,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):
@@ -540,6 +544,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"""


Test patch: