Fixes#10170 by preferring gcc@5 on linux
This makes sure ENV.cc and ENV.cxx is correctly set:
If a formula does not explicitely depend on a brewed gcc,
ENV.cc is set to gcc-5 (system gcc-5 or brewed gcc-5) with this change,
even if other gcc versions are installed on the system.
When GCC is used (default for Linux), we should prefer the gcc offered
by the gcc formula. As such even if users install a gcc with higher
version from `gcc@*` formula, it will not be picked up to build other
formulae. This would also allow users to safely delete `gcc@*` formula.
Closes#5953.
Clang has fully implemented OpenMP support as of LLVM 3.7, so if OpenMP
is required by a formula gcc is no longer the only choice of compiler.
Clang should be preferred over gcc because using gcc meant linking
against libstdc++, which is ABI incompatible with libc++. This may be
unnoticeable for some users, but it causes other builds to fail, e.g.
pstoedit when imagemagick was built with OpenMP. pstoedit is required
for the octave formula, so for some users this could be a significant
problem.
Building gcc with --HEAD results in most of the executables not having a
version suffix, e.g. Building/installing gcc 6 would result in gcc-6,
g++-6, etc. being installed, while building/installing gcc --HEAD would
result in gcc-, g++-, etc. being installed.
The lack of a version suffix prevented brew from recognizing a valid gcc
install, resulting in brew instructing users to install gcc before
building certain formulae even though gcc is installed.
A patch to the gcc formula makes the version number for --HEAD builds
the major version number of the stable version + 1 (7 at this time).
This patch teaches brew to recognize current --HEAD builds as valid
compilers.