Repository: spack/spack

Issue:
Installation Issue: man-db
### Steps to reproduce the issue

```console
$ spack install man-db%gcc@12.2.0 

$ spack spec -I man-db%gcc@12.2.0
Input spec
--------------------------------
 -   man-db%gcc@12.2.0

Concretized
--------------------------------
 -   man-db@2.10.2%gcc@12.2.0 arch=linux-rhel7-x86_64_v3
[+]      ^bzip2@1.0.8%gcc@12.2.0~debug~pic+shared arch=linux-rhel7-x86_64_v3
[+]          ^diffutils@3.8%gcc@12.2.0 arch=linux-rhel7-x86_64_v3
[+]              ^libiconv@1.16%gcc@12.2.0 libs=shared,static arch=linux-rhel7-x86_64_v3
[+]      ^flex@2.6.3%gcc@12.2.0+lex~nls arch=linux-rhel7-x86_64_v3
[+]          ^bison@3.8.2%gcc@12.2.0 arch=linux-rhel7-x86_64_v3
[+]              ^m4@1.4.19%gcc@12.2.0+sigsegv patches=9dc5fbd,bfdffa7 arch=linux-rhel7-x86_64_v3
[+]                  ^libsigsegv@2.13%gcc@12.2.0 arch=linux-rhel7-x86_64_v3
[+]              ^perl@5.34.1%gcc@12.2.0+cpanm+shared+threads arch=linux-rhel7-x86_64_v3
[+]                  ^berkeley-db@18.1.40%gcc@12.2.0+cxx~docs+stl patches=26090f4,b231fcc arch=linux-rhel7-x86_64_v3
[+]                  ^gdbm@1.19%gcc@12.2.0 arch=linux-rhel7-x86_64_v3
[+]                      ^readline@8.1.2%gcc@12.2.0 arch=linux-rhel7-x86_64_v3
[+]                          ^ncurses@6.3%gcc@12.2.0~symlinks+termlib abi=none arch=linux-rhel7-x86_64_v3
[+]                              ^pkgconf@1.8.0%gcc@12.2.0 arch=linux-rhel7-x86_64_v3
[+]                  ^zlib@1.2.12%gcc@12.2.0+optimize+pic+shared patches=0d38234 arch=linux-rhel7-x86_64_v3
[+]          ^findutils@4.9.0%gcc@12.2.0 patches=440b954 arch=linux-rhel7-x86_64_v3
[+]      ^gettext@0.21%gcc@12.2.0+bzip2+curses+git~libunistring+libxml2+tar+xz arch=linux-rhel7-x86_64_v3
[+]          ^libxml2@2.10.1%gcc@12.2.0~python arch=linux-rhel7-x86_64_v3
[+]              ^xz@5.2.5%gcc@12.2.0~pic libs=shared,static arch=linux-rhel7-x86_64_v3
[+]          ^tar@1.34%gcc@12.2.0 zip=pigz arch=linux-rhel7-x86_64_v3
[+]              ^pigz@2.7%gcc@12.2.0 arch=linux-rhel7-x86_64_v3
[+]              ^zstd@1.5.2%gcc@12.2.0+programs compression=none libs=shared,static arch=linux-rhel7-x86_64_v3
[+]      ^groff@1.22.4%gcc@12.2.0~pdf+uchardet~x arch=linux-rhel7-x86_64_v3
[+]          ^gawk@5.1.1%gcc@12.2.0~nls arch=linux-rhel7-x86_64_v3
[+]              ^gmp@6.2.1%gcc@12.2.0 libs=shared,static arch=linux-rhel7-x86_64_v3
[+]                  ^autoconf@2.69%gcc@12.2.0 patches=35c4492,7793209,a49dd5b arch=linux-rhel7-x86_64_v3
[+]                  ^automake@1.16.5%gcc@12.2.0 arch=linux-rhel7-x86_64_v3
[+]                  ^libtool@2.4.7%gcc@12.2.0 arch=linux-rhel7-x86_64_v3
[+]              ^mpfr@4.1.0%gcc@12.2.0 libs=shared,static arch=linux-rhel7-x86_64_v3
[+]                  ^autoconf-archive@2022.02.11%gcc@12.2.0 patches=139214f arch=linux-rhel7-x86_64_v3
[+]                  ^texinfo@6.5%gcc@12.2.0 patches=12f6edb,1732115 arch=linux-rhel7-x86_64_v3
[+]          ^gmake@4.3%gcc@12.2.0~guile+nls arch=linux-rhel7-x86_64_v3
[+]          ^sed@4.8%gcc@12.2.0 arch=linux-rhel7-x86_64_v3
[+]          ^uchardet@0.0.7%gcc@12.2.0~ipo build_type=RelWithDebInfo arch=linux-rhel7-x86_64_v3
[+]              ^cmake@3.24.2%gcc@12.2.0~doc+ncurses+ownlibs~qt build_type=Release arch=linux-rhel7-x86_64_v3
[+]                  ^openssl@1.1.1q%gcc@12.2.0~docs~shared certs=mozilla patches=3fdcf2d arch=linux-rhel7-x86_64_v3
[+]                      ^ca-certificates-mozilla@2022-07-19%gcc@12.2.0 arch=linux-rhel7-x86_64_v3
[+]      ^libpipeline@1.5.5%gcc@12.2.0 arch=linux-rhel7-x86_64_v3

```


### Error message

<details><summary>Error message</summary><pre>
mv -f .deps/libgnu_la-argp-ba.Tpo .deps/libgnu_la-argp-ba.Plo
/bin/sh ../../libtool  --tag=CC   --mode=compile /opt/spack/lib/spack/env/gcc/gcc -DHAVE_CONFIG_H -I. -I../..  -DDEFAULT_TEXT_DOMAIN=\"man-db-gnulib\"   -Wno-cast-qual -Wno-conversion -Wno-float-equal -Wno-sign-compare -Wno-undef -Wno-unused-function -Wno-unused-parameter -Wno-float-conversion -Wimplicit-fallthrough -Wno-pedantic -Wno-sign-conversion -Wno-type-limits -Wno-unsuffixed-float-constants -g -O2 -Wall -MT libgnu_la-argp-pvh.lo -MD -MP -MF .deps/libgnu_la-argp-pvh.Tpo -c -o libgnu_la-argp-pvh.lo `test -f 'argp-pvh.c' || echo './'`argp-pvh.c
In file included from /usr/include/string.h:633,
                 from ./string.h:41,
                 from argp-fmtstream.h:28,
                 from argp-fs-xinl.c:30:
./string.h:1080:1: error: expected identifier or '(' before '__extension__'
 1080 | _GL_FUNCDECL_SYS (strndup, char *,
      | ^~~~~~~~~~~~~~~~
In file included from /usr/include/string.h:633,
                 from ./string.h:41,
                 from argp-fmtstream.c:27:
./string.h:1080:1: error: expected identifier or '(' before '__extension__'
 1080 | _GL_FUNCDECL_SYS (strndup, char *,
      | ^~~~~~~~~~~~~~~~
mv -f .deps/libgnu_la-argp-pv.Tpo .deps/libgnu_la-argp-pv.Plo
In file included from /usr/include/string.h:633,
                 from ./string.h:41,
                 from argp-parse.c:27:
./string.h:1080:1: error: expected identifier or '(' before '__extension__'
 1080 | _GL_FUNCDECL_SYS (strndup, char *,
      | ^~~~~~~~~~~~~~~~
mv -f .deps/libgnu_la-argp-pin.Tpo .deps/libgnu_la-argp-pin.Plo
/bin/sh ../../libtool  --tag=CC   --mode=compile /opt/spack/lib/spack/env/gcc/gcc -DHAVE_CONFIG_H -I. -I../..  -DDEFAULT_TEXT_DOMAIN=\"man-db-gnulib\"   -Wno-cast-qual -Wno-conversion -Wno-float-equal -Wno-sign-compare -Wno-undef -Wno-unused-function -Wno-unused-parameter -Wno-float-conversion -Wimplicit-fallthrough -Wno-pedantic -Wno-sign-conversion -Wno-type-limits -Wno-unsuffixed-float-constants -g -O2 -Wall -MT libgnu_la-argp-xinl.lo -MD -MP -MF .deps/libgnu_la-argp-xinl.Tpo -c -o libgnu_la-argp-xinl.lo `test -f 'argp-xinl.c' || echo './'`argp-xinl.c
make[4]: *** [Makefile:2862: libgnu_la-argp-fs-xinl.lo] Error 1
make[4]: *** Waiting for unfinished jobs....
In file included from /usr/include/string.h:633,
                 from ./string.h:41,
                 from argp-help.c:32:
./string.h:1080:1: error: expected identifier or '(' before '__extension__'
 1080 | _GL_FUNCDECL_SYS (strndup, char *,
      | ^~~~~~~~~~~~~~~~
make[4]: *** [Makefile:2855: libgnu_la-argp-fmtstream.lo] Error 1
libtool: compile:  /opt/spack/lib/spack/env/gcc/gcc -DHAVE_CONFIG_H -I. -I../.. -DDEFAULT_TEXT_DOMAIN=\"man-db-gnulib\" -Wno-cast-qual -Wno-conversion -Wno-float-equal -Wno-sign-compare -Wno-undef -Wno-unused-function -Wno-unused-parameter -Wno-float-conversion -Wimplicit-fallthrough -Wno-pedantic -Wno-sign-conversion -Wno-type-limits -Wno-unsuffixed-float-constants -g -O2 -Wall -MT libgnu_la-argp-pvh.lo -MD -MP -MF .deps/libgnu_la-argp-pvh.Tpo -c argp-pvh.c  -fPIC -DPIC -o .libs/libgnu_la-argp-pvh.o
make[4]: *** [Makefile:2876: libgnu_la-argp-parse.lo] Error 1
mv -f .deps/libgnu_la-argp-eexst.Tpo .deps/libgnu_la-argp-eexst.Plo
make[4]: *** [Makefile:2869: libgnu_la-argp-help.lo] Error 1
libtool: compile:  /opt/spack/lib/spack/env/gcc/gcc -DHAVE_CONFIG_H -I. -I../.. -DDEFAULT_TEXT_DOMAIN=\"man-db-gnulib\" -Wno-cast-qual -Wno-conversion -Wno-float-equal -Wno-sign-compare -Wno-undef -Wno-unused-function -Wno-unused-parameter -Wno-float-conversion -Wimplicit-fallthrough -Wno-pedantic -Wno-sign-conversion -Wno-type-limits -Wno-unsuffixed-float-constants -g -O2 -Wall -MT libgnu_la-argp-xinl.lo -MD -MP -MF .deps/libgnu_la-argp-xinl.Tpo -c argp-xinl.c  -fPIC -DPIC -o .libs/libgnu_la-argp-xinl.o
mv -f .deps/libgnu_la-argp-pvh.Tpo .deps/libgnu_la-argp-pvh.Plo
mv -f .deps/libgnu_la-argp-xinl.Tpo .deps/libgnu_la-argp-xinl.Plo
make[4]: Leaving directory '/scratchpad/spack/build/spack-stage-man-db-2.10.2-u72duglold3vlm3len33waxpjdzwanoy/spack-src/gl/lib'
make[3]: *** [Makefile:4332: all-recursive] Error 1
make[3]: Leaving directory '/scratchpad/spack/build/spack-stage-man-db-2.10.2-u72duglold3vlm3len33waxpjdzwanoy/spack-src/gl/lib'
make[2]: *** [Makefile:2500: all] Error 2
make[2]: Leaving directory '/scratchpad/spack/build/spack-stage-man-db-2.10.2-u72duglold3vlm3len33waxpjdzwanoy/spack-src/gl/lib'
make[1]: *** [Makefile:1746: all-recursive] Error 1
make[1]: Leaving directory '/scratchpad/spack/build/spack-stage-man-db-2.10.2-u72duglold3vlm3len33waxpjdzwanoy/spack-src'
make: *** [Makefile:1678: all] Error 2
</pre></details>


### Information on your system

* **Spack:** 0.19.0.dev0 (6c2df00443a2cd092446c7d84431ae37e64e4296)
* **Python:** 3.6.8
* **Platform:** linux-rhel7-x86_64_v3
* **Concretizer:** clingo

### Additional information

[spack-build-out.txt](https://github.com/spack/spack/files/9742906/spack-build-out.txt)
[spack-build-env.txt](https://github.com/spack/spack/files/9742907/spack-build-env.txt)
[spack-config.log](https://github.com/spack/spack/files/9742908/spack-config.log)


### 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:
Seems like you're hitting a bug in a vendored copy of gnulib, see https://github.com/spack/spack/pull/31693 for details.

You can add pretty much the same patch to man-db, except that gnulib lives in the `./gl` dir.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/man-db/package.py b/var/spack/repos/builtin/packages/man-db/package.py
--- a/var/spack/repos/builtin/packages/man-db/package.py
+++ b/var/spack/repos/builtin/packages/man-db/package.py
@@ -30,6 +30,10 @@ class ManDb(AutotoolsPackage):
     depends_on("gdbm")
     depends_on("groff", type=("build", "link", "run"))
 
+    # gnulib bug introduced in commit cbdb5ea63cb5348d9ead16dc46bedda77a4c3d7d.
+    # fix is from commit 84863a1c4dc8cca8fb0f6f670f67779cdd2d543b
+    patch("gnulib.patch", when="@2.10.2", working_dir="gl")
+
     # TODO: add gzip support via a new package.
     # man pages are typically compressed, include all available
     # compression libraries


Test patch: