Repository: spack/spack

Issue:
Installation issue: libtiff
### Steps to reproduce the issue

```
% spack install py-matplotlib backend=qt5agg arch=m1
...
==> Installing libtiff-4.3.0-jb7jy5ml6u37vqoury25x6rgjlg4c6ce
==> No binary for libtiff-4.3.0-jb7jy5ml6u37vqoury25x6rgjlg4c6ce found: installing from source
==> Fetching https://mirror.spack.io/_source-cache/archive/0e/0e46e5acb087ce7d1ac53cf4f56a09b221537fc86dfc5daaad1c2e89e1b37ac8.tar.gz
==> Ran patch() for libtiff
==> libtiff: Executing phase: 'autoreconf'
==> libtiff: Executing phase: 'configure'
==> libtiff: Executing phase: 'build'
==> Error: ProcessError: Command exited with status 2:
    'make' '-j8' 'V=1'

23 errors found in build log:
     429    In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1
            /string:511:
     430    In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1
            /string_view:179:
     431    In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1
            /__string:57:
     432    In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1
            /algorithm:649:
     433    In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1
            /initializer_list:46:
     434    In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1
            /cstddef:37:
  >> 435    ../version:1:1: error: expected unqualified-id
     436    4.3.0
     437    ^
...
...
...
   ^
     646    fatal error: too many errors emitted, stopping now [-ferror-limit=]
     647    20 errors generated.
  >> 648    make[3]: *** [tif_stream.lo] Error 1
     649    make[3]: *** Waiting for unfinished jobs....
     650    libtool: link: (cd ".libs" && rm -f "libtiff.dylib" && ln -s "libtiff.5.dylib" "libtiff.dyli
            b")
     651    libtool: link: ar cr .libs/libtiff.a  tif_aux.o tif_close.o tif_codec.o tif_color.o tif_comp
            ress.o tif_dir.o tif_dirinfo.o tif_dirread.o tif_dirwrite.o tif_dumpmode.o tif_error.o tif_e
            xtension.o tif_fax3.o tif_fax3sm.o tif_flush.o tif_getimage.o tif_jbig.o tif_jpeg.o tif_jpeg
            _12.o tif_lerc.o tif_luv.o tif_lzma.o tif_lzw.o tif_next.o tif_ojpeg.o tif_open.o tif_packbi
            ts.o tif_pixarlog.o tif_predict.o tif_print.o tif_read.o tif_strip.o tif_swab.o tif_thunder.
            o tif_tile.o tif_version.o tif_warning.o tif_webp.o tif_write.o tif_zip.o tif_zstd.o tif_uni
            x.o
     652    libtool: link: ranlib .libs/libtiff.a
     653    libtool: link: ( cd ".libs" && rm -f "libtiff.la" && ln -s "../libtiff.la" "libtiff.la" )
  >> 654    make[2]: *** [all] Error 2
  >> 655    make[1]: *** [all-recursive] Error 1
  >> 656    make: *** [all] Error 2

See build log for details:
  /var/folders/z9/v6xmb1p14m57c94dsn9l_k780000gn/T/rutvik/spack-stage/spack-stage-libtiff-4.3.0-jb7jy5ml6u37vqoury25x6rgjlg4c6ce/spack-build-out.txt

==> Warning: Skipping build of lcms-2.9-zegoherv7bneajtncap6bhklwl66qwvk since libtiff-4.3.0-jb7jy5ml6u37vqoury25x6rgjlg4c6ce failed
==> Warning: Skipping build of libmng-2.0.3-2nkoj73cx3oe3q2xoxgwnr5eqlmf2uea since lcms-2.9-zegoherv7bneajtncap6bhklwl66qwvk failed
==> Warning: Skipping build of qt-5.15.2-dgdkvbvpujy7ie77recigdjh2l4s45os since libmng-2.0.3-2nkoj73cx3oe3q2xoxgwnr5eqlmf2uea failed
==> Warning: Skipping build of py-pyqt5-5.13.1-7wqhtbxkf5lyqitelm6o6sytkneqgitc since qt-5.15.2-dgdkvbvpujy7ie77recigdjh2l4s45os failed
==> Warning: Skipping build of py-matplotlib-3.5.1-6q5ise4akjjwsjuw3eppzdg4eihsqobx since py-pyqt5-5.13.1-7wqhtbxkf5lyqitelm6o6sytkneqgitc failed
```

### Information on your system

* **Spack:** 0.17.1-677-c2e1a12cdf
* **Python:** 3.9.7
* **Platform:** darwin-monterey-m1
* **Concretizer:** clingo


### Additional information

[spack-build-out.txt](https://github.com/spack/spack/files/7790834/spack-build-out.txt)
[spack-build-env.txt](https://github.com/spack/spack/files/7790836/spack-build-env.txt)
@adamjstewart 

### 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:
May be related to https://gitlab.com/libtiff/libtiff/-/issues/252. Also, Homebrew's recipe has a patch for M1: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/libtiff.rb. Going to try adding that.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/libtiff/package.py b/var/spack/repos/builtin/packages/libtiff/package.py
--- a/var/spack/repos/builtin/packages/libtiff/package.py
+++ b/var/spack/repos/builtin/packages/libtiff/package.py
@@ -55,6 +55,18 @@ class Libtiff(AutotoolsPackage):
     conflicts('+zstd', when='@:4.0.9')
     conflicts('+webp', when='@:4.0.9')
 
+    # https://gitlab.com/libtiff/libtiff/-/merge_requests/243
+    patch('no-include-root.patch', when='@4.3.0')
+
+    depends_on('automake', when='@4.3.0', type='build')
+    depends_on('autoconf', when='@4.3.0', type='build')
+    depends_on('libtool', when='@4.3.0', type='build')
+    depends_on('m4', when='@4.3.0', type='build')
+
+    @property
+    def force_autoreconf(self):
+        return self.spec.satisfies('@4.3.0')
+
     def patch(self):
         # Remove flags not recognized by the NVIDIA compiler
         if self.spec.satisfies('%nvhpc@:20.11'):


Test patch: