We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
gcc v5.4.0 build fails due to mpfr patching problem
There seems to be a patch application issue in the mpfr-3.1.5 build procedure

I was expecting something like my previous build:
```
==> Installing mpfr
==> Fetching file://MIRROR_DIR/mirror/mpfr/mpfr-3.1.5.tar.bz2
==> Staging archive: WORKING_DIR/var/spack/stage/mpfr-3.1.5-rmi7bmi3oaqduvjown2v46snr6ps2zr5/mpfr-3.1.5.tar.bz2
==> Created stage in WORKING_DIR/var/spack/stage/mpfr-3.1.5-rmi7bmi3oaqduvjown2v46snr6ps2zr5
==> Applied patch vasprintf.patch
==> Applied patch strtofr.patch
==> Building mpfr [AutotoolsPackage]
==> Executing phase: 'autoreconf'
==> Executing phase: 'configure'
==> Executing phase: 'build'
==> Executing phase: 'install'
==> Successfully installed mpfr
  Fetch: 0.04s.  Build: 9.54s.  Total: 9.58s.
[+] WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-4.8.5/mpfr-3.1.5-rmi7bmi3oaqduvjown2v46snr6ps2zr5
```
When I tried to build the gcc compiler yesterday (and again this morning) the results were strange:
```
==> Installing mpfr
1 out of 1 hunk FAILED -- saving rejects to file VERSION.rej
1 out of 1 hunk FAILED -- saving rejects to file src/mpfr.h.rej
1 out of 1 hunk FAILED -- saving rejects to file src/version.c.rej
==> Fetching file://MIRROR_DIR/mirror/mpfr/mpfr-3.1.5.tar.bz2
==> Staging archive: WORKING_DIR/sat/spack/var/spack/stage/mpfr-3.1.5-rmi7bmi3oaqduvjown2v46snr6ps2zr5/mpfr-3.1.5.tar.bz2
==> Created stage in WORKING_DIR/sat/spack/var/spack/stage/mpfr-3.1.5-rmi7bmi3oaqduvjown2v46snr6ps2zr5
==> Patch strtofr.patch failed.
==> Error: ProcessError: Command exited with status 1:
    '/usr/bin/patch' '-s' '-p' '1' '-i' 'WORKING_DIR/sat/spack/var/spack/repos/builtin/packages/mpfr/strtofr.patch' '-d' '.'
==> Error: [Errno 2] No such file or directory: 'WORKING_DIR/sat/spack/var/spack/stage/mpfr-3.1.5-rmi7bmi3oaqduvjown2v46snr6ps2zr5/mpfr-3.1.5/spack-build.out'
```
Not only the error, but the order of the messages seem strange.

A clean clone of the spack repo made no difference
```console
$ spack install gcc@5.4.0
```

Default environment:
```linux-centos7-x86_64/gcc-4.8.5```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `var/spack/repos/builtin/packages/mpfr/package.py`
Content:
```
1 ##############################################################################
2 # Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
3 # Produced at the Lawrence Livermore National Laboratory.
4 #
5 # This file is part of Spack.
6 # Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
7 # LLNL-CODE-647188
8 #
9 # For details, see https://github.com/spack/spack
10 # Please also see the NOTICE and LICENSE files for our notice and the LGPL.
11 #
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU Lesser General Public License (as
14 # published by the Free Software Foundation) version 2.1, February 1999.
15 #
16 # This program is distributed in the hope that it will be useful, but
17 # WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
19 # conditions of the GNU Lesser General Public License for more details.
20 #
21 # You should have received a copy of the GNU Lesser General Public
22 # License along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 ##############################################################################
25 from spack import *
26 
27 
28 class Mpfr(AutotoolsPackage):
29     """The MPFR library is a C library for multiple-precision
30        floating-point computations with correct rounding."""
31 
32     homepage = "http://www.mpfr.org"
33     url      = "https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.5.tar.bz2"
34 
35     version('3.1.5', 'b1d23a55588e3b2a13e3be66bc69fd8d')
36     version('3.1.4', 'b8a2f6b0e68bef46e53da2ac439e1cf4')
37     version('3.1.3', '5fdfa3cfa5c86514ee4a241a1affa138')
38     version('3.1.2', 'ee2c3ac63bf0c2359bf08fc3ee094c19')
39 
40     # mpir is a drop-in replacement for gmp
41     depends_on('gmp@4.1.0:')  # 4.2.3 or higher is recommended
42 
43     patch('vasprintf.patch', when='@3.1.5')
44     patch('strtofr.patch',   when='@3.1.5')
45 
46     def configure_args(self):
47         args = [
48             '--with-gmp=' + self.spec['gmp'].prefix,
49         ]
50         return args
51
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/var/spack/repos/builtin/packages/mpfr/package.py b/var/spack/repos/builtin/packages/mpfr/package.py
--- a/var/spack/repos/builtin/packages/mpfr/package.py
+++ b/var/spack/repos/builtin/packages/mpfr/package.py
@@ -30,18 +30,33 @@
        floating-point computations with correct rounding."""
 
     homepage = "http://www.mpfr.org"
-    url      = "https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.5.tar.bz2"
+    url      = "https://ftp.gnu.org/gnu/mpfr/mpfr-4.0.1.tar.bz2"
 
+    version('4.0.1', '8c21d8ac7460493b2b9f3ef3cc610454')
+    version('4.0.0', 'ef619f3bb68039e35c4a219e06be72d0')
+    version('3.1.6', '320c28198def956aeacdb240b46b8969')
     version('3.1.5', 'b1d23a55588e3b2a13e3be66bc69fd8d')
     version('3.1.4', 'b8a2f6b0e68bef46e53da2ac439e1cf4')
     version('3.1.3', '5fdfa3cfa5c86514ee4a241a1affa138')
     version('3.1.2', 'ee2c3ac63bf0c2359bf08fc3ee094c19')
 
     # mpir is a drop-in replacement for gmp
-    depends_on('gmp@4.1.0:')  # 4.2.3 or higher is recommended
+    depends_on('gmp@4.1:')  # 4.2.3 or higher is recommended
+    depends_on('gmp@5.0:', when='@4.0.0:')  # http://www.mpfr.org/mpfr-4.0.0/
 
-    patch('vasprintf.patch', when='@3.1.5')
-    patch('strtofr.patch',   when='@3.1.5')
+    # Check the Bugs section of old release pages for patches.
+    # http://www.mpfr.org/mpfr-X.Y.Z/#bugs
+    patches = {
+        '3.1.6': '66a5d58364113a21405fc53f4a48f4e8',
+        '3.1.5': '1dc5fe65feb5607b89fe0f410d53b627',
+        '3.1.4': 'd124381573404fe83654c7d5a79aeabf',
+        '3.1.3': 'ebd1d835e0ae2fd8a9339210ccd1d0a8',
+        '3.1.2': '9f96a5c7cac1d6cd983ed9cf7d997074',
+    }
+
+    for ver, checksum in patches.items():
+        patch('http://www.mpfr.org/mpfr-{0}/allpatches'.format(ver),
+              when='@' + ver, sha256=checksum)
 
     def configure_args(self):
         args = [

{"golden_diff": "diff --git a/var/spack/repos/builtin/packages/mpfr/package.py b/var/spack/repos/builtin/packages/mpfr/package.py\n--- a/var/spack/repos/builtin/packages/mpfr/package.py\n+++ b/var/spack/repos/builtin/packages/mpfr/package.py\n@@ -30,18 +30,33 @@\n        floating-point computations with correct rounding.\"\"\"\n \n     homepage = \"http://www.mpfr.org\"\n-    url      = \"https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.5.tar.bz2\"\n+    url      = \"https://ftp.gnu.org/gnu/mpfr/mpfr-4.0.1.tar.bz2\"\n \n+    version('4.0.1', '8c21d8ac7460493b2b9f3ef3cc610454')\n+    version('4.0.0', 'ef619f3bb68039e35c4a219e06be72d0')\n+    version('3.1.6', '320c28198def956aeacdb240b46b8969')\n     version('3.1.5', 'b1d23a55588e3b2a13e3be66bc69fd8d')\n     version('3.1.4', 'b8a2f6b0e68bef46e53da2ac439e1cf4')\n     version('3.1.3', '5fdfa3cfa5c86514ee4a241a1affa138')\n     version('3.1.2', 'ee2c3ac63bf0c2359bf08fc3ee094c19')\n \n     # mpir is a drop-in replacement for gmp\n-    depends_on('gmp@4.1.0:')  # 4.2.3 or higher is recommended\n+    depends_on('gmp@4.1:')  # 4.2.3 or higher is recommended\n+    depends_on('gmp@5.0:', when='@4.0.0:')  # http://www.mpfr.org/mpfr-4.0.0/\n \n-    patch('vasprintf.patch', when='@3.1.5')\n-    patch('strtofr.patch',   when='@3.1.5')\n+    # Check the Bugs section of old release pages for patches.\n+    # http://www.mpfr.org/mpfr-X.Y.Z/#bugs\n+    patches = {\n+        '3.1.6': '66a5d58364113a21405fc53f4a48f4e8',\n+        '3.1.5': '1dc5fe65feb5607b89fe0f410d53b627',\n+        '3.1.4': 'd124381573404fe83654c7d5a79aeabf',\n+        '3.1.3': 'ebd1d835e0ae2fd8a9339210ccd1d0a8',\n+        '3.1.2': '9f96a5c7cac1d6cd983ed9cf7d997074',\n+    }\n+\n+    for ver, checksum in patches.items():\n+        patch('http://www.mpfr.org/mpfr-{0}/allpatches'.format(ver),\n+              when='@' + ver, sha256=checksum)\n \n     def configure_args(self):\n         args = [\n", "issue": "gcc v5.4.0 build fails due to mpfr patching problem\nThere seems to be a patch application issue in the mpfr-3.1.5 build procedure\r\n\r\nI was expecting something like my previous build:\r\n```\r\n==> Installing mpfr\r\n==> Fetching file://MIRROR_DIR/mirror/mpfr/mpfr-3.1.5.tar.bz2\r\n==> Staging archive: WORKING_DIR/var/spack/stage/mpfr-3.1.5-rmi7bmi3oaqduvjown2v46snr6ps2zr5/mpfr-3.1.5.tar.bz2\r\n==> Created stage in WORKING_DIR/var/spack/stage/mpfr-3.1.5-rmi7bmi3oaqduvjown2v46snr6ps2zr5\r\n==> Applied patch vasprintf.patch\r\n==> Applied patch strtofr.patch\r\n==> Building mpfr [AutotoolsPackage]\r\n==> Executing phase: 'autoreconf'\r\n==> Executing phase: 'configure'\r\n==> Executing phase: 'build'\r\n==> Executing phase: 'install'\r\n==> Successfully installed mpfr\r\n  Fetch: 0.04s.  Build: 9.54s.  Total: 9.58s.\r\n[+] WORKING_DIR/opt/spack/linux-centos7-x86_64/gcc-4.8.5/mpfr-3.1.5-rmi7bmi3oaqduvjown2v46snr6ps2zr5\r\n```\r\nWhen I tried to build the gcc compiler yesterday (and again this morning) the results were strange:\r\n```\r\n==> Installing mpfr\r\n1 out of 1 hunk FAILED -- saving rejects to file VERSION.rej\r\n1 out of 1 hunk FAILED -- saving rejects to file src/mpfr.h.rej\r\n1 out of 1 hunk FAILED -- saving rejects to file src/version.c.rej\r\n==> Fetching file://MIRROR_DIR/mirror/mpfr/mpfr-3.1.5.tar.bz2\r\n==> Staging archive: WORKING_DIR/sat/spack/var/spack/stage/mpfr-3.1.5-rmi7bmi3oaqduvjown2v46snr6ps2zr5/mpfr-3.1.5.tar.bz2\r\n==> Created stage in WORKING_DIR/sat/spack/var/spack/stage/mpfr-3.1.5-rmi7bmi3oaqduvjown2v46snr6ps2zr5\r\n==> Patch strtofr.patch failed.\r\n==> Error: ProcessError: Command exited with status 1:\r\n    '/usr/bin/patch' '-s' '-p' '1' '-i' 'WORKING_DIR/sat/spack/var/spack/repos/builtin/packages/mpfr/strtofr.patch' '-d' '.'\r\n==> Error: [Errno 2] No such file or directory: 'WORKING_DIR/sat/spack/var/spack/stage/mpfr-3.1.5-rmi7bmi3oaqduvjown2v46snr6ps2zr5/mpfr-3.1.5/spack-build.out'\r\n```\r\nNot only the error, but the order of the messages seem strange.\r\n\r\nA clean clone of the spack repo made no difference\r\n```console\r\n$ spack install gcc@5.4.0\r\n```\r\n\r\nDefault environment:\r\n```linux-centos7-x86_64/gcc-4.8.5```\n", "before_files": [{"content": "##############################################################################\n# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.\n# Produced at the Lawrence Livermore National Laboratory.\n#\n# This file is part of Spack.\n# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.\n# LLNL-CODE-647188\n#\n# For details, see https://github.com/spack/spack\n# Please also see the NOTICE and LICENSE files for our notice and the LGPL.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU Lesser General Public License (as\n# published by the Free Software Foundation) version 2.1, February 1999.\n#\n# This program is distributed in the hope that it will be useful, but\n# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and\n# conditions of the GNU Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this program; if not, write to the Free Software\n# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n##############################################################################\nfrom spack import *\n\n\nclass Mpfr(AutotoolsPackage):\n    \"\"\"The MPFR library is a C library for multiple-precision\n       floating-point computations with correct rounding.\"\"\"\n\n    homepage = \"http://www.mpfr.org\"\n    url      = \"https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.5.tar.bz2\"\n\n    version('3.1.5', 'b1d23a55588e3b2a13e3be66bc69fd8d')\n    version('3.1.4', 'b8a2f6b0e68bef46e53da2ac439e1cf4')\n    version('3.1.3', '5fdfa3cfa5c86514ee4a241a1affa138')\n    version('3.1.2', 'ee2c3ac63bf0c2359bf08fc3ee094c19')\n\n    # mpir is a drop-in replacement for gmp\n    depends_on('gmp@4.1.0:')  # 4.2.3 or higher is recommended\n\n    patch('vasprintf.patch', when='@3.1.5')\n    patch('strtofr.patch',   when='@3.1.5')\n\n    def configure_args(self):\n        args = [\n            '--with-gmp=' + self.spec['gmp'].prefix,\n        ]\n        return args\n", "path": "var/spack/repos/builtin/packages/mpfr/package.py"}], "after_files": [{"content": "##############################################################################\n# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.\n# Produced at the Lawrence Livermore National Laboratory.\n#\n# This file is part of Spack.\n# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.\n# LLNL-CODE-647188\n#\n# For details, see https://github.com/spack/spack\n# Please also see the NOTICE and LICENSE files for our notice and the LGPL.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU Lesser General Public License (as\n# published by the Free Software Foundation) version 2.1, February 1999.\n#\n# This program is distributed in the hope that it will be useful, but\n# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and\n# conditions of the GNU Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this program; if not, write to the Free Software\n# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n##############################################################################\nfrom spack import *\n\n\nclass Mpfr(AutotoolsPackage):\n    \"\"\"The MPFR library is a C library for multiple-precision\n       floating-point computations with correct rounding.\"\"\"\n\n    homepage = \"http://www.mpfr.org\"\n    url      = \"https://ftp.gnu.org/gnu/mpfr/mpfr-4.0.1.tar.bz2\"\n\n    version('4.0.1', '8c21d8ac7460493b2b9f3ef3cc610454')\n    version('4.0.0', 'ef619f3bb68039e35c4a219e06be72d0')\n    version('3.1.6', '320c28198def956aeacdb240b46b8969')\n    version('3.1.5', 'b1d23a55588e3b2a13e3be66bc69fd8d')\n    version('3.1.4', 'b8a2f6b0e68bef46e53da2ac439e1cf4')\n    version('3.1.3', '5fdfa3cfa5c86514ee4a241a1affa138')\n    version('3.1.2', 'ee2c3ac63bf0c2359bf08fc3ee094c19')\n\n    # mpir is a drop-in replacement for gmp\n    depends_on('gmp@4.1:')  # 4.2.3 or higher is recommended\n    depends_on('gmp@5.0:', when='@4.0.0:')  # http://www.mpfr.org/mpfr-4.0.0/\n\n    # Check the Bugs section of old release pages for patches.\n    # http://www.mpfr.org/mpfr-X.Y.Z/#bugs\n    patches = {\n        '3.1.6': '66a5d58364113a21405fc53f4a48f4e8',\n        '3.1.5': '1dc5fe65feb5607b89fe0f410d53b627',\n        '3.1.4': 'd124381573404fe83654c7d5a79aeabf',\n        '3.1.3': 'ebd1d835e0ae2fd8a9339210ccd1d0a8',\n        '3.1.2': '9f96a5c7cac1d6cd983ed9cf7d997074',\n    }\n\n    for ver, checksum in patches.items():\n        patch('http://www.mpfr.org/mpfr-{0}/allpatches'.format(ver),\n              when='@' + ver, sha256=checksum)\n\n    def configure_args(self):\n        args = [\n            '--with-gmp=' + self.spec['gmp'].prefix,\n        ]\n        return args\n", "path": "var/spack/repos/builtin/packages/mpfr/package.py"}]}