Repository: spack/spack

Issue:
gcc@8.4.0 build broken (?)

### Spack version
<!-- Add the output to the command below -->
```console
[kai@longhorn ~]$ spack --version
0.14.1-355-3aa225cd5
```

### Steps to reproduce the issue

```console
$ spack install gcc@8.4.0
==> 141160: Installing gcc
==> Fetching https://ftpmirror.gnu.org/gcc/gcc-8.4.0/gcc-8.4.0.tar.xz
######################################################################## 100.0%
==> Staging archive: /tmp/kai/spack-stage/spack-stage-gcc-8.4.0-gvwvazjtvvm766l77e5od326olt3yslv/gcc-8.4.0.tar.xz
==> Created stage in /tmp/kai/spack-stage/spack-stage-gcc-8.4.0-gvwvazjtvvm766l77e5od326olt3yslv
1 out of 1 hunk FAILED -- saving rejects to file libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc.rej
==> Patch /home/01537/kai/build/spack/var/spack/repos/builtin/packages/gcc/glibc-2.31-libsanitizer-1.patch failed.
==> Error: ProcessError: Command exited with status 1:
    '/bin/patch' '-s' '-p' '1' '-i' '/home/01537/kai/build/spack/var/spack/repos/builtin/packages/gcc/glibc-2.31-libsanitizer-1.patch' '-d' '.'
==> Error: Failed to install gcc due to ChildError: ProcessError: Command exited with status 1:
    '/bin/patch' '-s' '-p' '1' '-i' '/home/01537/kai/build/spack/var/spack/repos/builtin/packages/gcc/glibc-2.31-libsanitizer-1.patch' '-d' '.'Traceback (most recent call l
```

### Platform and user environment

```console
[kai@longhorn ~]$ uname -a
Linux login2.longhorn.tacc.utexas.edu 4.14.0-115.10.1.el7a.ppc64le #1 SMP Wed Jun 26 09:32:17 UTC 2019 ppc64le ppc64le ppc64le GNU/Linux
[kai@longhorn ~]$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.6 (Maipo)
``` 

I haven't look into it, but it appears that the patch that comes with spack doesn't actually apply cleanly to the gcc it downloaded.


Discussion:
You can try disabling the patches that fail to apply to 8.4.0 like so:
```diff
diff --git a/var/spack/repos/builtin/packages/gcc/package.py b/var/spack/repos/builtin/packages/gcc/package.py
index f3891161a2..451394a037 100644
--- a/var/spack/repos/builtin/packages/gcc/package.py
+++ b/var/spack/repos/builtin/packages/gcc/package.py
@@ -218,7 +218,7 @@ class Gcc(AutotoolsPackage, GNUMirrorPackage):
             # https://github.com/Homebrew/homebrew-core/pull/39041
             patch('https://raw.githubusercontent.com/Homebrew/formula-patches/master/gcc/8.3.0-xcode-bug-_Atomic-fix.patch',
                   sha256='33ee92bf678586357ee8ab9d2faddf807e671ad37b97afdd102d5d153d03ca84',
-                  when='@6:8')
+                  when='@6:8.3')
         if macos_version() >= Version('10.15'):
             # Fix system headers for Catalina SDK
             # (otherwise __OSX_AVAILABLE_STARTING ends up undefined)
@@ -237,8 +237,8 @@ class Gcc(AutotoolsPackage, GNUMirrorPackage):
 
     # Backport libsanitizer patch for glibc >= 2.31 and 8.1.0 <= gcc <= 9.2.0
     # https://bugs.gentoo.org/708346
-    patch('glibc-2.31-libsanitizer-1.patch', when='@8.1.0:9.2.0')
-    patch('glibc-2.31-libsanitizer-2.patch', when='@8.1.0:9.2.0')
+    patch('glibc-2.31-libsanitizer-1.patch', when='@8.1.0:8.3.0,9.0.0:9.2.0')
+    patch('glibc-2.31-libsanitizer-2.patch', when='@8.1.0:8.3.0,9.0.0:9.2.0')
     # Older versions do not compile with newer versions of glibc
     # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81712
     patch('ucontext_t.patch', when='@4.9,5.1:5.4,6.1:6.4,7.1')
```
If that doesn't work, someone will have to try to adapt those patches to 8.4.0.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/gcc/package.py b/var/spack/repos/builtin/packages/gcc/package.py
--- a/var/spack/repos/builtin/packages/gcc/package.py
+++ b/var/spack/repos/builtin/packages/gcc/package.py
@@ -237,8 +237,8 @@ class Gcc(AutotoolsPackage, GNUMirrorPackage):
 
     # Backport libsanitizer patch for glibc >= 2.31 and 8.1.0 <= gcc <= 9.2.0
     # https://bugs.gentoo.org/708346
-    patch('glibc-2.31-libsanitizer-1.patch', when='@8.1.0:9.2.0')
-    patch('glibc-2.31-libsanitizer-2.patch', when='@8.1.0:9.2.0')
+    patch('glibc-2.31-libsanitizer-1.patch', when='@8.1.0:8.3.99,9.0.0:9.2.0')
+    patch('glibc-2.31-libsanitizer-2.patch', when='@8.1.0:8.3.99,9.0.0:9.2.0')
     # Older versions do not compile with newer versions of glibc
     # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81712
     patch('ucontext_t.patch', when='@4.9,5.1:5.4,6.1:6.4,7.1')


Test patch: