Repository: spack/spack

Issue:
Cannot use Spack-built gcc
I built gcc with Spack, then added it manually to Spack's compiler list:

```
$ cat ~/.spack/compilers.yaml
compilers:
- compiler:
    modules: []
    operating_system: elcapitan
    paths:
      cc: /usr/bin/clang
      cxx: /usr/bin/clang++
      f77: null
      fc: null
    spec: clang@8.0.0-apple
- compiler:
    modules: []
    operating_system: elcapitan
    paths:
      cc: /usr/bin/gcc
      cxx: /usr/bin/g++
      f77: null
      fc: null
    spec: gcc@4.2.1
- compiler:
    modules: []
    operating_system: elcapitan
    paths:
      cc: /Users/eschnett/src/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/gcc-6.2.0-oqafsa4af6qaah553lcrsqlh2dczk2ic/bin/gcc
      cxx: /Users/eschnett/src/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/gcc-6.2.0-oqafsa4af6qaah553lcrsqlh2dczk2ic/bin/g++
      f77: /Users/eschnett/src/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/gcc-6.2.0-oqafsa4af6qaah553lcrsqlh2dczk2ic/bin/gfortran
      fc: /Users/eschnett/src/spack/opt/spack/darwin-elcapitan-x86_64/clang-8.0.0-apple/gcc-6.2.0-oqafsa4af6qaah553lcrsqlh2dczk2ic/bin/gfortran
    spec: gcc@6.2.0-spack
```

This used to work fine, but doesn't any more: When I try to use this compiler, Spack produces an error:

```
$ spack spec cactusext +funhpc +julia +simulationio %gcc@6.2.0-spack
Input spec
------------------------------
  cactusext%gcc@6.2.0-spack+funhpc+julia+simulationio

Normalized
------------------------------
  cactusext%gcc@6.2.0-spack+funhpc+julia+simulationio
      ^boost+mpi
          ^openmpi%gcc@6.1.0-spack
              ^hwloc%gcc@6.1.0-spack
                  ^libpciaccess
                      ^libtool
                          ^m4
      ^fftw%gcc@6.1.0-spack+mpi+openmp
      ^funhpc%gcc@6.1.0-spack
          ^cereal
              ^cmake@2.8:
          ^curl
              ^openssl%gcc@6.1.0-spack
                  ^zlib%gcc@6.1.0-spack
          ^jemalloc%clang@7.3.0-apple
          ^openmpi%gcc@6.1.0-spack
          ^qthreads
      ^git%clang@7.3.0-apple
          ^autoconf
          ^expat
          ^gettext
          ^libiconv
          ^pcre
          ^perl
      ^gsl%gcc@6.1.0-spack
      ^hdf5@1.10.0-patch1%gcc@6.1.0-spack+mpi
      ^hdf5-blosc%gcc@6.1.0-spack
          ^c-blosc
              ^snappy
      ^julia@master%gcc@6.1.0-spack+hdf5+mpi
          ^python@2.7.12%clang@7.3.0-apple
              ^bzip2
              ^ncurses
              ^readline
              ^sqlite
      ^lmod%gcc@6.1.0-spack
          ^lua@5.2:%gcc@6.1.0-spack
          ^lua-luafilesystem
          ^lua-luaposix
          ^tcl
      ^openblas%gcc@6.1.0-spack
      ^papi%gcc@6.1.0-spack
      ^petsc%gcc@6.1.0-spack+boost+hdf5+mpi~mumps
          ^openblas%gcc@6.1.0-spack
      ^simulationio%gcc@6.1.0-spack
          ^swig

Concretized
------------------------------
Traceback (most recent call last):
  File "/Users/eschnett/src/spack/bin/spack", line 192, in <module>
    main()
  File "/Users/eschnett/src/spack/bin/spack", line 169, in main
    return_val = command(parser, args)
  File "/Users/eschnett/src/spack/lib/spack/spack/cmd/spec.py", line 57, in spec
    spec.concretize()
  File "/Users/eschnett/src/spack/lib/spack/spack/spec.py", line 1256, in concretize
    self._expand_virtual_packages(),
  File "/Users/eschnett/src/spack/lib/spack/spack/spec.py", line 1173, in _expand_virtual_packages
    spec)
  File "/Users/eschnett/src/spack/lib/spack/spack/concretize.py", line 127, in choose_virtual_or_external
    strict = [spack.abi.compatible(c, abi_exemplar) for c in candidates]
  File "/Users/eschnett/src/spack/lib/spack/spack/abi.py", line 126, in compatible
    self.compiler_compatible(parent, child, loose=loosematch)
  File "/Users/eschnett/src/spack/lib/spack/spack/abi.py", line 115, in compiler_compatible
    self._gcc_compiler_compare(pversion, cversion)):
  File "/Users/eschnett/src/spack/lib/spack/llnl/util/lang.py", line 187, in __call__
    self.cache[args] = self.func(*args)
  File "/Users/eschnett/src/spack/lib/spack/spack/abi.py", line 79, in _gcc_compiler_compare
    plib = self._gcc_get_libstdcxx_version(pversion)
  File "/Users/eschnett/src/spack/lib/spack/llnl/util/lang.py", line 187, in __call__
    self.cache[args] = self.func(*args)
  File "/Users/eschnett/src/spack/lib/spack/spack/abi.py", line 70, in _gcc_get_libstdcxx_version
    libpath = os.readlink(output.strip())
OSError: [Errno 2] No such file or directory: 'libstdc++.so'
```



Discussion:

Resolving patch:
diff --git a/lib/spack/spack/abi.py b/lib/spack/spack/abi.py
--- a/lib/spack/spack/abi.py
+++ b/lib/spack/spack/abi.py
@@ -54,10 +54,10 @@ def _gcc_get_libstdcxx_version(self, version):
         output = None
         if compiler.cxx:
             rungcc = Executable(compiler.cxx)
-            libname = "libstdc++.so"
+            libname = "libstdc++." + dso_suffix
         elif compiler.cc:
             rungcc = Executable(compiler.cc)
-            libname = "libgcc_s.so"
+            libname = "libgcc_s." + dso_suffix
         else:
             return None
         try:


Test patch: