New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GCC compiler with OSX #2423

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

Comments

Projects
None yet
5 participants
@bchretien

bchretien commented Jun 13, 2014

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

This comment has been minimized.

Show comment
Hide comment
@bchretien

bchretien Jun 13, 2014

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 commented Jun 13, 2014

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

This comment has been minimized.

Show comment
Hide comment
@BanzaiMan

BanzaiMan Jun 13, 2014

Member

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

Member

BanzaiMan commented Jun 13, 2014

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

@sarahhodne sarahhodne added this to the Next OS X environment update milestone Jun 17, 2014

@sarahhodne

This comment has been minimized.

Show comment
Hide comment
@sarahhodne

sarahhodne Jun 17, 2014

Contributor

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.

Contributor

sarahhodne commented Jun 17, 2014

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

This comment has been minimized.

Show comment
Hide comment
@bchretien

bchretien Jun 17, 2014

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?

bchretien commented Jun 17, 2014

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?

@sarahhodne

This comment has been minimized.

Show comment
Hide comment
@sarahhodne

sarahhodne Jun 17, 2014

Contributor

@bchretien That looks right.

Contributor

sarahhodne commented Jun 17, 2014

@bchretien That looks right.

miwob added a commit to ircd-hybrid/ircd-hybrid that referenced this issue Jun 24, 2014

- .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
@miwob

This comment has been minimized.

Show comment
Hide comment
@miwob

miwob 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?

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?

@sarahhodne

This comment has been minimized.

Show comment
Hide comment
@sarahhodne

sarahhodne Jun 25, 2014

Contributor

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

Contributor

sarahhodne commented Jun 25, 2014

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

@sarahhodne

This comment has been minimized.

Show comment
Hide comment
@sarahhodne

sarahhodne Jul 18, 2014

Contributor

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

Contributor

sarahhodne commented Jul 18, 2014

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

@sarahhodne sarahhodne closed this Jul 18, 2014

@bchretien

This comment has been minimized.

Show comment
Hide comment
@bchretien

bchretien Jul 18, 2014

@henrikhodne great, thanks for the information!

bchretien commented Jul 18, 2014

@henrikhodne great, thanks for the information!

miwob added a commit to ircd-hybrid/ircd-hybrid that referenced this issue Aug 21, 2014

- .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

miwob added a commit to ircd-hybrid/ircd-hybrid that referenced this issue Jan 20, 2015

- .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

eikel added a commit to eikel/Geometry that referenced this issue Dec 14, 2015

@larsbrinkhoff

This comment has been minimized.

Show comment
Hide comment

ehsan added a commit to mozilla/spidernode that referenced this issue May 14, 2016

darnir added a commit to darnir/wget2 that referenced this issue Oct 6, 2016

thomas-weber pushed a commit to thomas-weber/Little-CMS that referenced this issue Oct 14, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment