Repository: spack/spack

Issue:
Installation issue: gcc@7.3.0
<!-- Thanks for taking the time to report this build failure. To proceed with the report please:

1. Title the issue "Installation issue: <name-of-the-package>".
2. Provide the information required below.

We encourage you to try, as much as possible, to reduce your problem to the minimal example that still reproduces the issue. That would help us a lot in fixing it quickly and effectively! -->

### Steps to reproduce the issue

<!-- Fill in the exact spec you are trying to build and the relevant part of the error message -->
From Ubuntu 20.04 with gcc 9.3.0 installed
```console
$ spack install gcc@7.3.0
...
In file included from /tmp/jjolly/spack-stage/spack-stage-gcc-7.3.0-qew2co74raqn36lqlwarwxe7pn6vq63n/spack-src/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc:190:0:
/tmp/jjolly/spack-stage/spack-stage-gcc-7.3.0-qew2co74raqn36lqlwarwxe7pn6vq63n/spack-src/libsanitizer/sanitizer_common/sanitizer_internal_defs.h:261:72: error: size of array 'assertion_failed__1150' is negative
     typedef char IMPL_PASTE(assertion_failed_##_, line)[2*(int)(pred)-1]
                                                                        ^
/tmp/jjolly/spack-stage/spack-stage-gcc-7.3.0-qew2co74raqn36lqlwarwxe7pn6vq63n/spack-src/libsanitizer/sanitizer_common/sanitizer_internal_defs.h:255:30: note: in expansion of macro 'IMPL_COMPILER_ASSERT' #define COMPILER_CHECK(pred) IMPL_COMPILER_ASSERT(pred, __LINE__)
                              ^~~~~~~~~~~~~~~~~~~~
/tmp/jjolly/spack-stage/spack-stage-gcc-7.3.0-qew2co74raqn36lqlwarwxe7pn6vq63n/spack-src/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h:1461:3: note: in expansion of macro 'COMPILER_CHECK'
   COMPILER_CHECK(sizeof(((__sanitizer_##CLASS *) NULL)->MEMBER) == \
   ^~~~~~~~~~~~~~
/tmp/jjolly/spack-stage/spack-stage-gcc-7.3.0-qew2co74raqn36lqlwarwxe7pn6vq63n/spack-src/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc:1150:1: note: in expansion of macro 'CHECK_SIZE_AND_OFFSET'
 CHECK_SIZE_AND_OFFSET(ipc_perm, mode);
 ^~~~~~~~~~~~~~~~~~~~~
make[4]: *** [Makefile:523: sanitizer_platform_limits_posix.lo] Error 1
```

### Information on your system

<!-- Please include the output of `spack debug report` -->
```console
$ spack debug report
* **Spack:** 0.14.2-1341-2ec680bbf
* **Python:** 3.8.2
* **Platform:** linux-ubuntu20.04-x86_64
```

<!-- If you have any relevant configuration detail (custom `packages.yaml` or `modules.yaml`, etc.) you can add that here as well. -->

### Additional information

<!-- Please upload the following files. They should be present in the stage directory of the failing build. Also upload any config.log or similar file if one exists. -->
* [spack-build-out.txt](https://github.com/spack/spack/files/4736493/spack-build-out.txt)
* [spack-build-env.txt](https://github.com/spack/spack/files/4736502/spack-build-env.txt)


<!-- Some packages have maintainers who have volunteered to debug build failures. Run `spack maintainers <name-of-the-package>` and @mention them here if they exist. -->
gcc maintainer: @michaelkuhn 

### General information

<!-- These boxes can be checked by replacing [ ] with [x] or by clicking them after submitting the issue. -->
- [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:

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
@@ -242,10 +242,13 @@ class Gcc(AutotoolsPackage, GNUMirrorPackage):
     patch('piclibs.patch', when='+piclibs')
     patch('gcc-backport.patch', when='@4.7:4.9.2,5:5.3')
 
-    # Backport libsanitizer patch for glibc >= 2.31 and 8.1.0 <= gcc <= 9.2.0
+    # Backport libsanitizer patch for glibc >= 2.31 and 5.3.0 <= gcc <= 9.2.0
     # https://bugs.gentoo.org/708346
-    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')
+    patch('glibc-2.31-libsanitizer-1.patch', when='@7.1.0:7.4.0,8.1.0:8.3.0,9.0.0:9.2.0')
+    patch('glibc-2.31-libsanitizer-1-gcc-6.patch', when='@5.3.0:5.5.0,6.1.0:6.5.0')
+    patch('glibc-2.31-libsanitizer-2.patch', when='@8.1.0:8.3.0,9.0.0:9.2.0')
+    patch('glibc-2.31-libsanitizer-2-gcc-6.patch', when='@5.3.0:5.5.0,6.1.0:6.5.0')
+    patch('glibc-2.31-libsanitizer-2-gcc-7.patch', when='@7.1.0:7.4.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: