Linuxbrew gcc Formula lagging

Apologies if this isn’t the proper place to request information. I thought the lagging formulae would be a bug, but it didn’t match any of the templates and I didn’t want to get banned from the project.

The linuxbrew-core and homebrew-core GCC formulae have diverged substantially. gcc in homebrew-core installs 10.1.0 whereas in linuxbrew-core it installs 5.5.0 (or 9.3.0 on macOS). Likewise, gcc@9 installs 9.3.0 on homebrew-core and 9.2.0 on linuxbrew-core (a bit of a conflict with the gcc formula, too). gcc@10 doesn’t exist in linuxbrew-core at all.

Having such an old version of gcc appear on the PATH can create conflicts. I initially thought this was an issue with Homebrew, but it appears to be specific to the Linux variant. It looks like holding back the various gcc formulae is deliberate. Is there anything I can do to help advance it?

There is a plan to switch the gcc formulae around:

It’s not an easy task, and it needs a lot of testing. I will work on this during the next weeks but do not expect a quick progress.

To ensure that our precompiled binary packages (called bottles) are usable on as many systems as possible, they’re compiled on Ubuntu 16.04 LTS, which ships with GCC 5 by default. We use GCC 5 to build our bottles. Life is simpler and more reliable if the the default Homebrew compiler is the same one used to build the bottles, namely GCC 5. We realize that GCC 5 being the default compiler is surprising behaviour and also causes its own issues, and we’re thinking of ways to better resolve this issue. Ubuntu 16.04 LTS will be end of life next year, at which point we plan to replace it.

In the mean time, you can modify your PATH and/or modify the symlinks in $HOMEBREW_PREFIX/bin to change cc , c++ , gcc , and g++ to your preferred compiler.

Thanks for the explanation. Once I realized what was happening, the fix was straightforward. The problem is I was tracking down a build error in some other Homebrew package and had no idea an outdated GCC was being picked up (or that Linuxbrew had even installed GCC). So my debugging process was searching for build error messages for that particular project before hitting upon someone indicating an old GCC would be to blame. But when I looked at the Homebrew formula and then through Homebrew, it looked like a newer GCC should be used. I finally hit upon Linuxbrew using a version different than Homebrew core.

Is there a way to opt out of using bottles and adopt a system closer to what Homebrew on macOS provides? I’d prefer to avoid conflicts with software that Homebrew is compiling.

You can delete the symlink ~/.linuxbrew/bin/gcc. That’s the easiest fix.

Hello. I’m having a related issue on my c++ project.
I tried to use gcc@9 by specifying -DCMAKE_CXX_COMPILER=g+±9 and it succeeded at a compile stage. However, it failed to link some libstdc++ functions. It seems ld still tried to link libstdc++ in gcc@5.5.

I could solve this problem temporarily by overwriting library paths before installation

brew install gcc@5.5
brew unlink gcc@5.5 //this unlink default gcc
brew install gcc@9

Now I’m trying to maintain a bottle on my tap repository. Doing brew unlink causes an error in brew doctor in brew test-bot. Is there any way to prevent from using libstdc++ in gcc@5.5 safely?
Here is a log.

Try adding fails_with gcc: "5" to your formula.
See for example

Thanks. I tried it but still fails to link…

I could fix this by adding

    unless OS.mac?

Related to this issue