Install modern GCC on OS X

Hi Everyone,

I need to test a C++ project build on OSX using a modern GCC. I selected OS X 10.14 (osx_image: xcode9.4) for testing. I’m having trouble installing GCC using Brew. A failed setup can be found at 768581004.

I have the following in my before_install:

- |
    if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
        # We need to test modern GCC and -Wa,-q
        brew update && brew install gcc
    fi

Attempting to install GCC results in an error “Error: gcc 9.3.0 is already installed”. GCC was not installed before brew update && brew install gcc. I am not sure why it is failing with “GCC is already installed”.

I am obviously missing something.

How do I install GCC on OS X?

First, if you’re using Homebrew, use a supported version of OSX:


Then, brew install errors out if any version of the package is already installed, it requires you to use brew upgrade in this case.

Thanks @native-api

So are you saying we should change:

brew update && brew install gcc

to

brew upgrade

Or are you saying something else?

Thanks in advance.

brew update && brew upgrade gcc should do.

Ack, thanks @native-api.

Thanks again @native-api
It looks like brew update && brew upgrade --quiet gcc || true results in this:

The job exceeded the maximum log length, and has been terminated.

Sigh. So much for that global option --quiet

I really despise Brew. I think it is junk software. It is poorly designed and even more poorly implemented.

Check the raw log to see why that is. It fails at update stage so --quiet as no effect.
And it’s ultimately because you ignored the advice to move to a newer OSX.

If you don’t like Homebrew, don’t use it, no-one forces you to…

Thanks again @native-api.

I was not aware we could skip Brew.

Where do we find a modern GCC? The system one is just a link to Clang.

When you’re doing brew update then brew upgrade gcc, this technique may be helpful.

Also, what @native-api mentioned was to use a later osx_image: setting from the documented options. By now there is actually a osx_image: xcode12.4 setting available, even though it isn’t formally documented yet.