GCC compiler with OSX #2423

Closed
bchretien opened this Issue Jun 13, 2014 · 10 comments

Projects

None yet

5 participants

@bchretien

Hi,

We are in the process of testing one of our CMake-enabled C++ projects in the osx environment. We currently use two compilers in the linux environment: gcc and clang, and we would like to do the same thing in osx. Hence, our .travis.yml file contains:

compiler:
  - gcc
  - clang
os:
  - linux
  - osx

When we check our environment variables in the log, we can indeed see:

Using worker: saucelabs-mac.worker.travis-ci.org:travis-mac_osx-11
...
$ export CXX=g++
$ export CC=gcc
...
$ gcc --version

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1

Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)

Target: x86_64-apple-darwin13.1.0

Thread model: posix
...
TRAVIS_OS_NAME=osx

And when running cmake as we do for Linux (for instance when installing Eigen):

-- The C compiler identification is Clang 5.1.0
-- The CXX compiler identification is Clang 5.1.0
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/g++
-- Check for working CXX compiler: /usr/bin/g++ -- works

clang is indeed being used instead, which was confirmed by a clang-specific error we fixed recently (cf. this g++ log file vs this clang++ log file with the same clang error):

In file included from /Users/travis/build/roboptim/roboptim-core/include/roboptim/core/differentiable-function.hh:251:
/Users/travis/build/roboptim/roboptim-core/include/roboptim/core/differentiable-function.hxx:54:27: error: implicit conversion changes signedness: 'jacobian_t::Index' (aka 'int') to 'const unsigned int' [-Werror,-Wsign-conversion]
              (triplet_t (i, idx, it.value ()));
               ~~~~~~~~~  ^
/Users/travis/build/roboptim/roboptim-core/include/roboptim/core/differentiable-function.hxx:54:30: error: implicit conversion changes signedness: 'const jacobian_t::Index' (aka 'const int') to 'const unsigned int' [-Werror,-Wsign-conversion]
              (triplet_t (i, idx, it.value ()));
               ~~~~~~~~~     ^~~
2 errors generated.

Are we missing something here? Is there any extra step that needs to be taken in order to force the use of gcc?

@bchretien bchretien referenced this issue in roboptim/roboptim-core Jun 13, 2014
Closed

Travis: fix the use of gcc on osx #63

@bchretien

According to this, "the GCC that came with 10.8 was really GCC front-end with LLVM back-end". Will it be the same philosophy on Travis? (i.e. we will need to use Homebrew to get the actual GCC ourselves, although compilation is likely to take too much time)

@bchretien bchretien changed the title from CMake and GCC compiler with OSX to GCC compiler with OSX Jun 13, 2014
@BanzaiMan
Member

It makes sense to have the real GCC preinstalled on the Mac VMs.

@henrikhodne
Member

GCC 4.8 will be installed in the next OS X environment update.

Note that the GCC is installed as gcc-4.8. gcc still points to Apple's LLVM-gcc for compatibility.

@bchretien

Ok, thanks! So if in the build matrix, gcc is used for both linux and macosx, and we want to use GCC 4.8 on macosx rather than the LLVM version, we'll just need to export CC/CXX, i.e. something like:

if [[ ${TRAVIS_OS_NAME} = osx ]]; then
    # Since default gcc on osx is just a front-end for LLVM
    if [[ ${CC} = gcc ]]; then
        export CXX=g++-4.8
        export CC=gcc-4.8
    fi
fi

Right?

@henrikhodne
Member

@bchretien That looks right.

@miwob miwob added a commit to ircd-hybrid/ircd-hybrid that referenced this issue Jun 24, 2014
@miwob miwob - .travis.yml: on OS X build with true gcc, see: travis-ci/travis-ci#…
…2423

git-svn-id: svn://svn.ircd-hybrid.org/svnroot/ircd-hybrid/trunk@4051 82007160-df01-0410-b94d-b575c5fd34c7
9cacf47
@miwob
miwob commented Jun 25, 2014

For some reason the suggested solution does not work for me. What I have currently in .travis.yml:

script:

  • if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$CC" = "gcc" ]; then export CC=gcc-4.8; fi

The job ( https://travis-ci.org/ircd-hybrid/ircd-hybrid/jobs/28416086 ) then errors out because:
checking for gcc... gcc-4.8
checking whether the C compiler works... no
configure: error: in `/Users/travis/build/ircd-hybrid/ircd-hybrid':
configure: error: C compiler cannot create executables

Any ideas what's wrong there?

@henrikhodne
Member

Sorry, gcc-4.8 is not installed yet, but will on the next environment update.

@henrikhodne
Member

gcc-4.8 is now preinstalled. Sorry for the delay.

@bchretien

@henrikhodne great, thanks for the information!

@miwob miwob added a commit to ircd-hybrid/ircd-hybrid that referenced this issue Aug 21, 2014
@miwob miwob - .travis.yml: on OS X build with true gcc, see: travis-ci/travis-ci#…
…2423

git-svn-id: svn://svn.ircd-hybrid.org/svnroot/ircd-hybrid/trunk@4051 82007160-df01-0410-b94d-b575c5fd34c7
5e8d577
@miwob miwob added a commit to ircd-hybrid/ircd-hybrid that referenced this issue Jan 20, 2015
@miwob miwob - .travis.yml: on OS X build with true gcc, see: travis-ci/travis-ci#…
…2423

git-svn-id: svn://svn.ircd-hybrid.org/svnroot/ircd-hybrid/trunk@4051 82007160-df01-0410-b94d-b575c5fd34c7
feca821
@eikel eikel added a commit to eikel/Geometry that referenced this issue Dec 14, 2015
@eikel eikel Travis CI: Use updated compilers on Linux
Change gcc on OS X (see
travis-ci/travis-ci#2423)
7f26177
@ehsan ehsan added a commit to mozilla/spidernode that referenced this issue May 14, 2016
@ehsan ehsan travis-ci: Use gcc 4.8 for reals on OSX
See travis-ci/travis-ci#2423 for why this is
needed.
993e71a
@darnir darnir added a commit to darnir/wget2 that referenced this issue Oct 6, 2016
@darnir darnir * .travis_setup.yml: Use real gcc on mac osx travis builds
See travis-ci/travis-ci#2423 for more details
6a09f64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment