Repository: spack/spack

Issue:
Problems building GCC 5.3.0
I'm trying to build GCC 5.3.0, but I'm seeing the following error message:

```
ld: cannot find -lstdc++
```

Any idea what's going on? This is on Fedora 24 with GCC 6.2.1.



Discussion:
Does `dnf provides */libstdc++.so` provide any hint about missing libstdc++?

```
$ dnf provides */libstdc++.so
Last metadata expiration check: 1 day, 21:58:08 ago on Tue Oct 18 12:48:26 2016.
gcc-c++-6.2.1-2.fc24.x86_64 : C++ support for GCC
Repo        : @System

gcc-c++-6.2.1-2.fc24.x86_64 : C++ support for GCC
Repo        : updates

libstdc++-devel-6.2.1-2.fc24.i686 : Header files and libraries for C++
                                  : development
Repo        : updates

compat-gcc-34-c++-3.4.6-40.fc24.x86_64 : C++ support for compatibility compiler
Repo        : fedora

gcc-c++-6.1.1-2.fc24.x86_64 : C++ support for GCC
Repo        : fedora

libstdc++-devel-6.1.1-2.fc24.i686 : Header files and libraries for C++
                                  : development
Repo        : fedora
```

Try `spack install gcc@5.3.0~binutils`

@sknigh This gives me a completely different error message:

```
cfns.gperf:101:1: error: ‘const char* libc_name_p(const char*, unsigned int)’ redeclared inline with ‘gnu_inline’ attribute
```

Hello, I'm new to `spack` but @adamjstewart was helping me get a CUDA 8 capable compiler on Fedora 24 which was what prompted this issue in the first place.

With respect to the original issue, after many failed attempts my understanding is that GCC 6 cannot build GCC 5 at this time.  I don't really understand the details, and was not successful doing this myself, but allegedly it can be fixed by using the C89 standard when compiling?
- Bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69959

That bug was the original problem I had when trying to build GCC 5 manually with GCC 6.2.1.

I had also tried to build GCC 5.3.0 with clang 3.8, but wasn't able to get that working either (I can open a separate issue for this with more details if you would like, it wasn't happy with something being forward declared as a `struct` in one file and a `class` in the other).

The solution for me to be able to build GCC 5.3.0 using `spack` was the following:
1. Install the compat gcc (3.4.6):
   
   ```
   dnf install compat-gcc-34 compat-gcc-34-c++
   ```
   
   There is also the compat fortran compiler (`compat-gcc-34-g77.x86_64 : Fortran 77 support for compatibility compiler`) in the fc24 repos.
   
   My experience has been that every linux distribution I have encountered provides a `compat-gcc` package of some form, and I believe it is standardized to 3.4 but am not really confident on any of that.
2. For some reason, `spack compiler find` does not discover the newly installed gcc.  I suspect it may be because it looks for `gcc-34` whereas mine installs as `gcc34` without a dash, but am not sure about the cause.  I edited the file `~/.spack/linux/compilers.yaml` and added
   
   ```
   - compiler:
       modules: []
       operating_system: fedora24
       paths:
         cc: /usr/bin/gcc34
         cxx: /usr/bin/g++34
         f77: null
         fc: null
       spec: gcc@3.4.6
   ```
3. Successful installation of GCC 5.3.0!!!
   
   ```
   spack install gcc@5.3.0%gcc@3.4.6~binutils
   ```

Noting that I had to add `~binutils` for the host package since that was unable to build (cause unknown...).

Please let me know if more information would be helpful, thanks for `spack` it's a very interesting tool :)


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
@@ -58,6 +58,7 @@ class Gcc(Package):
         provides('golang', when='@4.7.1:')
 
     patch('piclibs.patch', when='+piclibs')
+    patch('gcc-backport.patch', when='@4.7:5.3')
 
     def install(self, spec, prefix):
         # libjava/configure needs a minor fix to install into spack paths.


Test patch: