Repository: spack/spack

Issue:
AttributeError: 'Target' object has no attribute 'lower'
When installing `llvm` I've run into a Spack error `AttributeError: 'Target' object has no attribute 'lower'`. There are a few other packages that also use `Target.lower()` but I haven't tried installing those yet.

### Steps to reproduce the issue

```console
$ spack install llvm
...
```

### Error Message

```
==> Building llvm [CMakePackage]
==> Executing phase: 'cmake'
==> Error: AttributeError: 'Target' object has no attribute 'lower'

/var/tmp/spack/var/spack/repos/builtin/packages/llvm/package.py:686, in cmake_args:
        683                # hence the test to see if the version starts with "flang".
        684                targets.append('CppBackend')
        685
  >>    686            if 'x86' in spec.architecture.target.lower():
        687                targets.append('X86')
        688            elif 'arm' in spec.architecture.target.lower():
        689                targets.append('ARM')
```



### Information on your system

Only tried a single system at this moment:

```
$ git rev-parse HEAD
6cd5edacca8e4cacbcaf104b3c241097fc83568f
$ uname -a
Linux p901 4.14.0-115.8.1.el7a.ppc64le #1 SMP Wed Jun 5 15:02:21 UTC 2019 ppc64le ppc64le ppc64le GNU/Linux
```
```



Discussion:

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/llvm/package.py b/var/spack/repos/builtin/packages/llvm/package.py
--- a/var/spack/repos/builtin/packages/llvm/package.py
+++ b/var/spack/repos/builtin/packages/llvm/package.py
@@ -683,16 +683,19 @@ def cmake_args(self):
                 # hence the test to see if the version starts with "flang".
                 targets.append('CppBackend')
 
-            if 'x86' in spec.architecture.target.lower():
+            if spec.target.family == 'x86' or spec.target.family == 'x86_64':
                 targets.append('X86')
-            elif 'arm' in spec.architecture.target.lower():
+            elif spec.target.family == 'arm':
                 targets.append('ARM')
-            elif 'aarch64' in spec.architecture.target.lower():
+            elif spec.target.family == 'aarch64':
                 targets.append('AArch64')
-            elif 'sparc' in spec.architecture.target.lower():
+            elif (spec.target.family == 'sparc' or
+                  spec.target.family == 'sparc64'):
                 targets.append('Sparc')
-            elif ('ppc' in spec.architecture.target.lower() or
-                  'power' in spec.architecture.target.lower()):
+            elif (spec.target.family == 'ppc64' or
+                  spec.target.family == 'ppc64le' or
+                  spec.target.family == 'ppc' or
+                  spec.target.family == 'ppcle'):
                 targets.append('PowerPC')
 
             cmake_args.append(
diff --git a/var/spack/repos/builtin/packages/mesa/package.py b/var/spack/repos/builtin/packages/mesa/package.py
--- a/var/spack/repos/builtin/packages/mesa/package.py
+++ b/var/spack/repos/builtin/packages/mesa/package.py
@@ -101,7 +101,7 @@ def configure_args(self):
         args_gallium_drivers = ['swrast']
         args_dri_drivers = []
 
-        if 'arm' in spec.architecture.target.lower():
+        if spec.target.family == 'arm':
             args.append('--disable-libunwind')
 
         num_frontends = 0


Test patch: