Repository: spack/spack

Issue:
Installation issue: nettle fails to build on M2 silicon
### Steps to reproduce the issue

```console
MacBook-Pro:~ ldalessa$ spack spec -l nettle
Input spec
--------------------------------
nettle

Concretized
--------------------------------
ttk3r6k  nettle@3.4.1%apple-clang@13.1.6 arch=darwin-monterey-m1
ensdfb7      ^gmp@6.2.1%apple-clang@13.1.6 libs=shared,static arch=darwin-monterey-m1
suif6fh          ^autoconf@2.69%apple-clang@13.1.6 patches=35c4492,7793209,a49dd5b arch=darwin-monterey-m1
6ge5mev              ^gnuconfig@2021-08-14%apple-clang@13.1.6 arch=darwin-monterey-m1
hclwv4x              ^m4@1.4.6%apple-clang@13.1.6+sigsegv arch=darwin-monterey-m1
43xby7j              ^perl@5.34.1%apple-clang@13.1.6+cpanm+shared+threads arch=darwin-monterey-m1
e5dqqjq                  ^berkeley-db@18.1.40%apple-clang@13.1.6+cxx~docs+stl patches=b231fcc arch=darwin-monterey-m1
pn7g2gl                  ^bzip2@1.0.8%apple-clang@13.1.6~debug~pic+shared arch=darwin-monterey-m1
pfdmkku                      ^diffutils@2.8.1%apple-clang@13.1.6 arch=darwin-monterey-m1
n4qumdz                  ^gdbm@1.19%apple-clang@13.1.6 arch=darwin-monterey-m1
i35npi3                      ^readline@8.1.2%apple-clang@13.1.6 arch=darwin-monterey-m1
euuhhar                          ^ncurses@6.3%apple-clang@13.1.6~symlinks+termlib abi=none arch=darwin-monterey-m1
ett7ygi                              ^pkgconf@1.8.0%apple-clang@13.1.6 arch=darwin-monterey-m1
ke4alug                  ^zlib@1.2.12%apple-clang@13.1.6+optimize+pic+shared patches=0d38234 arch=darwin-monterey-m1
3fvlps3          ^automake@1.16.5%apple-clang@13.1.6 arch=darwin-monterey-m1
gbgb5q3          ^libtool@2.4.7%apple-clang@13.1.6 arch=darwin-monterey-m1
```


### Error message

The nettle configuration and build fails. According to https://doesitarm.com/formula/nettle/ it should work on apple silicon.

<details><summary>Click to expand</summary>

<pre>
==> Installing nettle-3.4.1-ttk3r6kobqsxqhma4znqj2i2k3wjhont
==> No binary for nettle-3.4.1-ttk3r6kobqsxqhma4znqj2i2k3wjhont found: installing from source
==> Using cached archive: /opt/spack/var/spack/cache/_source-cache/archive/f9/f941cf1535cd5d1819be5ccae5babef01f6db611f9b5a777bae9c7604b8a92ad.tar.gz
==> No patches needed for nettle
==> nettle: Executing phase: 'autoreconf'
==> nettle: Executing phase: 'configure'
==> nettle: Executing phase: 'build'
==> Error: ProcessError: Command exited with status 2:
    'make' '-j8' 'V=1'

427 errors found in build log:
     84      configure: Looking for assembler files in arm.
     85      checking CCPIC...
     86      checking if globals are prefixed by underscore... yes
     87      checking for ELF-style .type,%function pseudo-ops... no
     88      checking for ELF-style .type,#function pseudo-ops... no
     89      checking for COFF-style .type directive... no
  >> 90      checking if we should use a .note.GNU-stack section... /Library/Developer/CommandLineTools/usr/bin/objdump: error: 'conftest.o': Invalid/Unsupported object file format
     91      no
     92      checking if .align assembly directive is logarithmic... yes
     93      checking for m4... /usr/bin/m4
     94      checking for makeinfo... /usr/bin/makeinfo
     95      checking for library containing clock_gettime... none required
     96      configure: creating ./config.status

     ...

     196     /opt/spack/lib/spack/env/clang/clang -I.  -DHAVE_CONFIG_H -std=c99 -ggdb3 -Wall -W   -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes   -Wpointer-arith -Wb
             ad-function-cast -Wnested-externs  -MT aes-set-key-internal.o -MD -MP -MF aes-set-key-internal.o.d -c aes-set-key-internal.c \
                  197        && true
     198     /opt/spack/lib/spack/env/clang/clang -I.  -DHAVE_CONFIG_H -std=c99 -ggdb3 -Wall -W   -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes   -Wpointer-arith -Wb
             ad-function-cast -Wnested-externs  -MT aes-set-encrypt-key.o -MD -MP -MF aes-set-encrypt-key.o.d -c aes-set-encrypt-key.c \
     199        && true
     200     /opt/spack/lib/spack/env/clang/clang -I.  -DHAVE_CONFIG_H -std=c99 -ggdb3 -Wall -W   -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes   -Wpointer-arith -Wb
             ad-function-cast -Wnested-externs  -MT aes-set-decrypt-key.o -MD -MP -MF aes-set-decrypt-key.o.d -c aes-set-decrypt-key.c \
     201        && true
  >> 202     aes-encrypt-internal.s:75:2: error: unrecognized instruction mnemonic
     203      teq r3, #0
     204      ^
  >> 205     aes-encrypt-internal.s:78:8: error: vector register expected
     206      push {r0,r1,r3, r4,r5,r6,r7,r8,r10,r11,lr}
     207            ^
  >> 208     aes-encrypt-internal.s:78:10: error: unknown token in expression
     209      push {r0,r1,r3, r4,r5,r6,r7,r8,r10,r11,lr}
     210              ^
  >> 211     aes-encrypt-internal.s:78:10: error: invalid operand
     212      push {r0,r1,r3, r4,r5,r6,r7,r8,r10,r11,lr}
     213              ^
  >> 214     aes-encrypt-internal.s:79:6: error: invalid operand for instruction
  ...
</pre></details>

[error.txt](https://github.com/spack/spack/files/9485711/error.txt)


### Information on your system

```console
MacBook-Pro:~ ldalessa$ spack debug report
* **Spack:** 0.19.0.dev0 (0df0b9a505d3731088a462c7fafadf6e162b1cc6)
* **Python:** 3.8.9
* **Platform:** darwin-monterey-m1
* **Concretizer:** clingo
```

### Additional information

[spack-build-env.txt](https://github.com/spack/spack/files/9485707/spack-build-env.txt)
[spack-build-out.txt](https://github.com/spack/spack/files/9485708/spack-build-out.txt)


### General information

- [X] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [X] I have run `spack maintainers <name-of-the-package>` and **@mentioned** any maintainers
- [X] I have uploaded the build log and environment files
- [X] I have searched the issues of this repo and believe this is not a duplicate


Discussion:

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/nettle/package.py b/var/spack/repos/builtin/packages/nettle/package.py
--- a/var/spack/repos/builtin/packages/nettle/package.py
+++ b/var/spack/repos/builtin/packages/nettle/package.py
@@ -13,6 +13,7 @@ class Nettle(AutotoolsPackage, GNUMirrorPackage):
     homepage = "https://www.lysator.liu.se/~nisse/nettle/"
     gnu_mirror_path = "nettle/nettle-3.3.tar.gz"
 
+    version("3.8.1", sha256="364f3e2b77cd7dcde83fd7c45219c834e54b0c75e428b6f894a23d12dd41cbfe")
     version("3.4.1", sha256="f941cf1535cd5d1819be5ccae5babef01f6db611f9b5a777bae9c7604b8a92ad")
     version("3.4", sha256="ae7a42df026550b85daca8389b6a60ba6313b0567f374392e54918588a411e94")
     version("3.3", sha256="46942627d5d0ca11720fec18d81fc38f7ef837ea4197c1f630e71ce0d470b11e")


Test patch: