Repository: spack/spack

Issue:
Installation issue: gdb@11.1
### Steps to reproduce the issue

```console
$ spack install gdb@11.1
[+] /usr (external python-3.6.8-42zz3vk7tj5ooiq2s33wqd4zx2njlxqj)
[+] /usr (external texinfo-6.5-uzihy7vowlztilxfy6wrzmos226rgcqn)
[+] /usr (external xz-5.2.4-aznlbqrcwv5pwolhte6xmvjwtvjrduaq)
==> Installing gdb-11.1-bqvgcs4nr4rbb57x24tldnlbcv3mpmqy
==> No binary for gdb-11.1-bqvgcs4nr4rbb57x24tldnlbcv3mpmqy found: installing from source
==> Fetching https://mirror.spack.io/_source-cache/archive/cc/cc2903474e965a43d09c3b263952d48ced39dd22ce2d01968f3aa181335fcb9c.tar.gz
==> Applied patch /home/bc/spack/var/spack/repos/builtin/packages/gdb/gdb-libintl-11.patch
==> gdb: Executing phase: 'autoreconf'
==> gdb: Executing phase: 'configure'
==> gdb: Executing phase: 'build'
==> Error: ProcessError: Command exited with status 2:
    'make' '-j16' 'V=1'

1 error found in build log:
     5318    checking size of unsigned __int128... 16
     5319    checking for library containing dlopen... none required
     5320    checking whether to use expat... auto
     5321    checking for libexpat... no
     5322    configure: WARNING: expat is missing or unusable; some features may be unavailable.
     5323    checking for libgmp... no
  >> 5324    configure: error: GMP is missing or unusable
     5325    make[1]: *** [Makefile:10420: configure-gdb] Error 1
     5326    make[1]: Leaving directory '/tmp/bc/spack-stage/spack-stage-gdb-11.1-bqvgcs4nr4rbb57x24tldnlbcv3mpmqy/sp
             ack-src/spack-build'
     5327    make: *** [Makefile:903: all] Error 2

See build log for details:
  /tmp/bc/spack-stage/spack-stage-gdb-11.1-bqvgcs4nr4rbb57x24tldnlbcv3mpmqy/spack-build-out.txt
```

### Information on your system

* **Spack:** 0.16.3-4399-cdcecda9d0
* **Python:** 3.6.8
* **Platform:** linux-rocky8-zen2
* **Concretizer:** clingo


### Additional information

gdb requires GMP to build since version 11.1. (https://www.gnu.org/software/gdb/download/ANNOUNCEMENT)

@robertu94

[spack-build-out.txt](https://github.com/spack/spack/files/7254919/spack-build-out.txt)
[spack-build-env.txt](https://github.com/spack/spack/files/7254920/spack-build-env.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:
@zzzoom good catch. Could you please provide a list of external packages and the contents of /etc/os-release so I can verify a fix. I have many deadlines in the next two-three weeks so I’ll have limited bandwidth to work on this until then. 

If you provide a PR, I’d be happy to review it. 

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/gdb/package.py b/var/spack/repos/builtin/packages/gdb/package.py
--- a/var/spack/repos/builtin/packages/gdb/package.py
+++ b/var/spack/repos/builtin/packages/gdb/package.py
@@ -15,11 +15,11 @@ class Gdb(AutotoolsPackage, GNUMirrorPackage):
     """
 
     homepage = "https://www.gnu.org/software/gdb"
-    gnu_mirror_path = "gdb/gdb-7.10.tar.gz"
+    gnu_mirror_path = "gdb/gdb-11.1.tar.gz"
 
     maintainers = ['robertu94']
 
-    version('11.1', sha256='cc2903474e965a43d09c3b263952d48ced39dd22ce2d01968f3aa181335fcb9c')
+    version('11.1',   sha256='cc2903474e965a43d09c3b263952d48ced39dd22ce2d01968f3aa181335fcb9c')
     version('10.2',   sha256='b33ad58d687487a821ec8d878daab0f716be60d0936f2e3ac5cf08419ce70350')
     version('10.1',   sha256='f12f388b99e1408c01308c3f753313fafa45517740c81ab7ed0d511b13e2cf55')
     version('9.2',    sha256='38ef247d41ba7cc3f6f93a612a78bab9484de9accecbe3b0150a3c0391a3faf0')
@@ -32,12 +32,8 @@ class Gdb(AutotoolsPackage, GNUMirrorPackage):
     version('8.0.1',  sha256='52017d33cab5b6a92455a1a904046d075357abf24153470178c0aadca2d479c5')
     version('8.0',    sha256='8968a19e14e176ee026f0ca777657c43456514ad41bb2bc7273e8c4219555ac9')
     version('7.12.1', sha256='142057eacecfb929d52b561eb47a1103c7d504cec3f659dd8a5ae7bc378f7e77')
-    version('7.11',   sha256='9382f5534aa0754169e1e09b5f1a3b77d1fa8c59c1e57617e06af37cb29c669a')
+    version('7.11.1', sha256='57e9e9aa3172ee16aa1e9c66fef08b4393b51872cc153e3f1ffdf18a57440586')
     version('7.10.1', sha256='ff14f8050e6484508c73cbfa63731e57901478490ca1672dc0b5e2b03f6af622')
-    version('7.10',   sha256='50690e6d6b7917a6544190ec9401eaafb555e3cef8981709ea9870296c383ce5')
-    version('7.9.1',  sha256='4994ad986726ac4128a6f1bd8020cd672e9a92aa76b80736563ef992992764ef')
-    version('7.9',    sha256='d282508cb7df0cb8b2cf659032ce1bede7b5725796e3ac90f3cd9d65844a65f2')
-    version('7.8.2',  sha256='fd9a9784ca24528aac8a4e6b8d7ae7e8cf0784e128cd67a185c986deaf6b9929')
 
     variant('python', default=True, description='Compile with Python support')
     variant('xz', default=True, description='Compile with lzma support')
@@ -53,6 +49,15 @@ class Gdb(AutotoolsPackage, GNUMirrorPackage):
     patch('gdb-libintl-10.patch', level=0, when='@10.1:11.0')
     patch('gdb-libintl-11.patch', level=0, when='@11.1:')
 
+    # Upstream patch and backport to fix build with glibc@2.25:
+    # http://lists.busybox.net/pipermail/buildroot/2017-March/188055.html
+    patch('https://git.buildroot.net/buildroot/plain/package/gdb/7.11.1/0002-Sync-proc_service-definition-with-GLIBC.patch?id=a8a2e5288ed4704907383b10bab704fca211f5db',
+          sha256='f2648907cc22f7d02551d0018d44848f9db9fc5cdfda4fea65906a372f4f551b',
+          when="@7.11.1")
+    patch('https://git.buildroot.net/buildroot/plain/package/gdb/7.10.1/0007-Sync-proc_service-definition-with-GLIBC.patch?id=a8a2e5288ed4704907383b10bab704fca211f5db',
+          sha256='6bfa89d9989d70167b307e6b0aa5f72dd0bc3d124553c4b54b270f8c4adf5fdc',
+          when="@7.10.1")
+
     # Silence warnings about imp being deprecated on new python versions
     # https://sourceware.org/pipermail/gdb-patches/2021-February/176622.html
     patch('importlib.patch', when="@8.3.1:10.2 ^python@3.4:")
@@ -62,9 +67,11 @@ class Gdb(AutotoolsPackage, GNUMirrorPackage):
 
     # Optional dependencies
     depends_on('python+debug', when='+python', type=('build', 'link', 'run'))
+    depends_on('python@:3.6', when='@:8.1+python', type=('build', 'link', 'run'))
     depends_on('xz', when='+xz')
     depends_on('source-highlight', when='+source-highlight')
     depends_on('ncurses', when='+tui')
+    depends_on('gmp', when='@11.1:')
 
     build_directory = 'spack-build'
 
@@ -73,8 +80,11 @@ def configure_args(self):
             '--with-system-gdbinit={0}'.format(self.prefix.etc.gdbinit)
         ]
 
+        if self.spec.version >= Version("11.1"):
+            args.append("--with-gmp={0}".format(self.spec['gmp'].prefix))
+
         if '+python' in self.spec:
-            args.append('--with-python')
+            args.append('--with-python={0}'.format(self.spec['python'].command))
             args.append('LDFLAGS={0}'.format(
                 self.spec['python'].libs.ld_flags))
 
@@ -103,3 +113,7 @@ def gdbinit(self):
                 mkdir(self.prefix.etc)
                 with open(self.prefix.etc.gdbinit, 'w') as gdbinit:
                     gdbinit.write('add-auto-load-safe-path {0}\n'.format(tool))
+
+    def check(self):
+        """The GDB testsuite is extensive and is hard to pass. Skip it for now."""
+        pass


Test patch: