Where is GCC-5 after installing it on Solaris 11

gccipspackage-managementsolaris

Please forgive my ignorance… I only use Solaris for testing C/C++ libraries I have an interest in. I'm not a Solaris admin or Solaris user.

I installed GCC-5 on Solaris 11.3, x86 because I needed a C++ compiler that supports -std=c++11 (see below for the package output). Sun's native GCC is 4.8, and it does not support C++11 well (or at all).

Unfortunately, I cannot find it after the install:

$ g++-5 --version
-bash: g++-5: command not found  

$ sudo find /usr -name gcc-5
$ sudo find /bin -name gcc-5
$

And for completeness:

$ /bin/gcc --version
gcc (GCC) 4.8.2
...

$ ls -l /usr/bin/gcc
lrwxrwxrwx   1 root   root   18 Jun  7  2016 /usr/bin/gcc -> ../gcc/4.8/bin/gcc

$ which gcc-5
no gcc-5 in /usr/local/bin /usr/local/sbin /bin /sbin /usr/bin /usr/sbin /usr/sfw/bin

Where is the compiler located?


According to Installing GCC on Oracle Solaris 11 on Stack Overflow, its supposed to be in /usr/bin/gcc as a symlink. But the answer appears to be off a bit:

$ /usr/bin/gcc --version
gcc (GCC) 4.8.2
...

According to GCC missing from Solaris 11, and server already deployed on Server Fault:

/usr/sfw/bin is the bundled gcc path with Solaris 10. On Solaris
11.1, gcc is, when installed, directly available in /usr/bin as a symlink that points to /usr/gcc/<version>/bin/gcc

The answer appears to be off a bit, too.


$ sudo pkg install --accept gcc-5
------------------------------------------------------------
Package: pkg://solaris/release/evaluation@1.0,5.12-5.12.0.0.0.115.0:20170111T175931Z
License: evaluation

This software has been made available for evaluation purposes only.
See http://www.oracle.com/technetwork/server-storage/solaris11/technologies/foss-evaluation-program-2586275.html for further information.        

           Packages to install:  2
       Create boot environment: No
Create backup boot environment: No

DOWNLOAD                                PKGS         FILES    XFER (MB)   SPEED
Completed                                2/2           8/8      0.0/0.0 17.4k/s

PHASE                                          ITEMS
Installing new actions                         37/37
Updating package state database                 Done
Updating package cache                           0/0
Updating image state                            Done
Creating fast lookup database                   Done
Updating package cache                           2/2

After installing gcc-5:

$ find / -name 'gcc*' 2>/dev/null
/usr/share/vim/vim73/compiler/gcc.vim
/usr/share/gcc-4.8.2
/usr/share/man/man1/gcc.1
/usr/gcc
/usr/gcc/4.8/bin/gcc-nm
/usr/gcc/4.8/bin/gcc-ranlib
/usr/gcc/4.8/bin/gcc
/usr/gcc/4.8/bin/gcc-ar
/usr/gcc/4.8/lib/gcc
/usr/gcc/4.8/lib/gcc/i386-pc-solaris2.11/4.8.2/plugin/include/ada/gcc-interface
/usr/gcc/4.8/lib/gcc/i386-pc-solaris2.11/4.8.2/plugin/include/gcc-plugin.h
/usr/gcc/4.8/share/locale/de/LC_MESSAGES/gcc.mo
/usr/gcc/4.8/share/locale/ja/LC_MESSAGES/gcc.mo
/usr/gcc/4.8/share/locale/fr/LC_MESSAGES/gcc.mo
/usr/gcc/4.8/share/locale/zh_CN/LC_MESSAGES/gcc.mo
/usr/gcc/4.8/share/locale/zh_TW/LC_MESSAGES/gcc.mo
/usr/gcc/4.8/share/locale/es/LC_MESSAGES/gcc.mo
/usr/gcc/4.8/share/gcc-4.8.2
/usr/gcc/4.8/share/info/gccinstall.info
/usr/gcc/4.8/share/info/gccint.info
/usr/gcc/4.8/share/info/gcc.info
/usr/gcc/4.8/share/man/man1/gcc.1
/usr/bin/gcc
/usr/local/share/emacs/24.5/lisp/cedet/semantic/bovine/gcc.el
/usr/local/share/emacs/24.5/lisp/cedet/semantic/bovine/gcc.elc
/usr/include/gc/atomic_ops/sysdeps/gcc
/usr/include/avahi-common/gccmacro.h
/usr/include/pulse/gccmacro.h
/export/home/jwalton/botan/src/scripts/ci/circle/gcc-sanitizer.sh
/export/home/jwalton/botan/src/scripts/ci/circle/gcc-static-debug.sh
/export/home/jwalton/botan/src/scripts/ci/circle/gcc-shared-debug.sh
/export/home/jwalton/botan/src/build-data/cc/gcc.txt
/export/home/jwalton/zlib-1.2.8/contrib/gcc_gvmat64
/opt/developerstudio12.5/lib/compilers/CC-gcc/lib/gcc
/opt/developerstudio12.5/lib/compilers/CC-gcc/gcc_version.map
/opt/solarisstudio12.4/lib/compilers/CC-gcc/gcc_version.map
/opt/solarisstudio12.4/lib/compilers/CC-gcc/lib/gcc

And:

~$ pkg search -l gcc | grep ^basename
basename             dir    opt/developerstudio12.5/lib/compilers/CC-gcc/lib/gcc               pkg:/developer/developerstudio-125/library/studio-gccrt@12.5-1.0.0.0
basename             dir    opt/solarisstudio12.4/lib/compilers/CC-gcc/lib/gcc                 pkg:/developer/solarisstudio-124/library/studio-gccrt@12.4-1.0.0.0
basename             dir    usr/include/gc/atomic_ops/sysdeps/gcc                              pkg:/library/gc@7.2-0.175.2.0.0.39.0
basename                    link   usr/bin/gcc                                                        pkg:/developer/gcc-4/gcc-c-48@4.8.2-0.175.3.0.0.30.0
basename                    file   usr/gcc/4.8/bin/gcc                                                pkg:/developer/gcc-4/gcc-c-48@4.8.2-0.175.3.0.0.30.0
pkg: Search performance is degraded.

Best Answer

TL;DR:

# pkg change-facet \
      version-lock.system/library/gcc/gcc-c-runtime=false \
      version-lock.system/library/gcc/gcc-c++-runtime=false

and try again.

So the issue is that gcc-5 is what's known as a "group" package. That is, it consists (at least primarily) of a bunch of group dependencies. A group dependency is one that will be installed if possible, but ignored if not. In this case, it was not possible to install one or more of the dependencies of gcc-5, so they were ignored, and you ended up with less than you expected.

When that happens (whether it's fewer packages, or packages at a different version), the first thing you should do is tell pkg what you actually expect. (Now, the disconnect here is how to know what to expect; without knowing how to inspect gcc-5 for that information, or even knowing that you might have to, I'm not sure how to answer that.) In this case, choose one of its dependencies to see if it helps; say, gcc-c-5 (you followed this step for gcc-c++-5, which gave you the same problem as I show here, but I wanted to put it all together in one answer). This tells pkg not to ignore its inability to install gcc-c-5, but to actually complain in detail about why it couldn't be installed. Hopefully there will be something in the output to give us a clue about what to do next:

# pkg install -nv gcc-5 gcc-c-5
Creating Plan (Solver setup): |
pkg install: No matching version of developer/gcc-5 can be installed:
  Reject:  pkg://solaris/developer/gcc-5@5.4.0-5.12.0.0.0.115.0
  Reason:  No version matching 'group' dependency developer/gcc/gcc-c++-5 can be installed
    ----------------------------------------
    Reject:  pkg://solaris/developer/gcc/gcc-c++-5@5.4.0-5.12.0.0.0.115.0
    Reason:  No version matching 'require' dependency developer/gcc/gcc-c-5 can be installed
      ----------------------------------------
      Reject:  pkg://solaris/developer/gcc/gcc-c-5@5.4.0-5.12.0.0.0.115.0
      Reason:  No version matching 'require' dependency system/library/gcc/gcc-c++-runtime@5.4.0,5.11-5.12.0.0.0.115.0 can be installed
        ----------------------------------------
        Reject:  pkg://solaris/system/library/gcc/gcc-c++-runtime@5.4.0-5.12.0.0.0.115.0
        Reason:  No version matching 'require' dependency system/library/gcc/gcc-c-runtime@5.4.0,5.11-5.12.0.0.0.115.0 can be installed
          ----------------------------------------
          Reject:  pkg://solaris/system/library/gcc/gcc-c-runtime@5.4.0-5.12.0.0.0.115.0
          Reason:  This version is excluded by installed incorporation consolidation/userland/userland-incorporation@0.5.11-0.175.3.19.0.2.0
          ----------------------------------------
        Reason:  This version is excluded by installed incorporation consolidation/userland/userland-incorporation@0.5.11-0.175.3.19.0.2.0
        ----------------------------------------
      ----------------------------------------
    ----------------------------------------
No matching version of developer/gcc/gcc-c-5 can be installed:
  Reject:  pkg://solaris/developer/gcc/gcc-c-5@5.4.0-5.12.0.0.0.115.0
  Reason:  [already rejected; see above]

When you get a mess of solver output like this, you typically want to look for the deepest-indented issue and see if you can correct that. In this case, you see that it's unable to install gcc-c-runtime@5.4.0-5.12.0.0.0.115.0 because it's excluded by an installed incorporation.

Perhaps a digression is necessary: what's an incorporation? Like a group package, it's a package that primarily delivers dependencies, in this case, incorporate dependencies. These dependencies never actually cause packages to be installed; they simply place constraints on packages that may be installed. Specifically, incorporating foo@1.2 means that if foo is installed, it must be in the version range [1.2, 1.3); that is, a minimum of 1.2 (inclusive), and a maximum of 1.3 (exclusive), or anything that matches 1.2.x.y.z.....

In this case, the incorporation userland-incorporation that's already installed on the system has placed a constraint on gcc-c-runtime that's incompatible with the version of gcc-c-runtime that installing gcc-c-5 requires.

That's where we run into one of the oddities of the Solaris FOSS evaluation program. The packages made available there are not well integrated with the rest of the system; they're designed to be installed on a newer version of Solaris. But they've been built such that the system can at least be sanely massaged into letting them be installed. In this case, you have to change a few facets.

Most of the FOSS packages in Solaris are incorporated in such a way that the constraint delivered by that incorporate dependency can be relaxed. You can do that by changing the facet named by version-lock.<pkg-name> to false. In this case, gcc-c-runtime and gcc-c++-runtime are the two packages blocking the installation you want, so (as above):

# pkg change-facet \
      version-lock.system/library/gcc/gcc-c-runtime=false \
      version-lock.system/library/gcc/gcc-c++-runtime=false

This will give a bit of output, but not seemingly do much. Once it's done, though, we can try again:

# pkg install -nv gcc-5 gcc-c-5
           Packages to install:      20
            Packages to update:       2
           Mediators to change:       1
            Services to change:       1
     Estimated space available: 8.54 GB
Estimated space to be consumed: 1.49 GB
       Create boot environment:      No
Create backup boot environment:     Yes
          Rebuild boot archive:      No

Changed mediators:
  mediator gcc:
           version: None -> 5 (system default)

Changed packages:
solaris
  developer/assembler
    None -> 0.5.11,5.11-0.175.3.9.0.2.0:20160528T012706Z
  developer/gcc-5
    None -> 5.4.0,5.12-5.12.0.0.0.115.0:20170111T170530Z
  developer/gcc/gcc-c++-5
    None -> 5.4.0,5.12-5.12.0.0.0.115.0:20170111T164822Z
  developer/gcc/gcc-c-5
    None -> 5.4.0,5.12-5.12.0.0.0.115.0:20170111T165027Z
  developer/gcc/gcc-common-5
    None -> 5.4.0,5.12-5.12.0.0.0.115.0:20170111T165220Z
  developer/gcc/gcc-gfortran-5
    None -> 5.4.0,5.12-5.12.0.0.0.115.0:20170111T165431Z
  developer/gcc/gcc-gobjc-5
    None -> 5.4.0,5.12-5.12.0.0.0.115.0:20170111T165624Z
  developer/gnu-binutils
    None -> 2.23.1,5.11-0.175.3.0.0.30.0:20150821T164528Z
  library/gmp
    None -> 4.3.2,5.11-0.175.3.0.0.30.0:20150821T165358Z
  library/isl
    None -> 0.12.2,5.12-5.12.0.0.0.115.0:20170111T171737Z
  library/mpc
    None -> 0.9,5.11-0.175.3.0.0.30.0:20150821T165558Z
  library/mpfr
    None -> 2.4.2,5.11-0.175.3.0.0.30.0:20150821T165559Z
  release/evaluation
    None -> 1.0,5.12-5.12.0.0.0.115.0:20170111T175931Z
  system/header
    None -> 0.5.11,5.11-0.175.3.19.0.2.0:20170328T014052Z
  system/library/gcc/gcc-c++-runtime-5
    None -> 5.4.0,5.12-5.12.0.0.0.115.0:20170111T181800Z
  system/library/gcc/gcc-c-runtime-5
    None -> 5.4.0,5.12-5.12.0.0.0.115.0:20170111T181840Z
  system/library/gcc/gcc-gfortran-runtime
    None -> 4.8.2,5.11-0.175.3.0.0.30.0:20150821T172507Z
  system/library/gcc/gcc-gfortran-runtime-5
    None -> 5.4.0,5.12-5.12.0.0.0.115.0:20170111T181902Z
  system/library/gcc/gcc-gobjc-runtime
    None -> 4.8.2,5.11-0.175.3.0.0.30.0:20150821T172513Z
  system/library/gcc/gcc-gobjc-runtime-5
    None -> 5.4.0,5.12-5.12.0.0.0.115.0:20170111T181919Z
  system/library/gcc/gcc-c++-runtime
    4.8.2,5.11-0.175.3.0.0.30.0:20150821T172447Z -> 5.4.0,5.12-5.12.0.0.0.115.0:20170111T181825Z
  system/library/gcc/gcc-c-runtime
    4.8.2,5.11-0.175.3.0.0.30.0:20150821T172458Z -> 5.4.0,5.12-5.12.0.0.0.115.0:20170111T181848Z

And voila, we get a bunch of packages installed, which actually contain stuff. From here, you should now be able to type gcc --version and see that it is indeed 5.4.0. Note also that the two packages whose facets we unlocked got upgraded, a possibility available after the unlocking.

You might ask why we didn't need to unlock any other facets. The reason for that is that Solaris 11.3 didn't deliver GCC 5, and so didn't deliver any constraints on its package versions. So all the gcc-*-5 packages are already unconstrained, and needn't be unlocked in order to relax constraints.

You might notice that the gcc-gfortran-runtime and gcc-gobjc-runtime packages got installed at their 4.8 versions. That's because they're still constrained, but nothing we did conflicted with those constraints. For consistency, you probably should unlock them as well, and then upgrade them to their 5.x versions (or, if you've gotten this far before trying anything, just unlock them from the start).

Related Question