Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clang and the default compiler in OS X Lion

In OS X Snow Leopard (10.6) I used the following lines in ~/.bashrc to force compilation with clang instead of standard gcc:

# Set Clang as the default compiler for the system
export CC=clang
export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments

I also (occasionally) had to use the following lines to use llvm-gcc when clang would fail to compile certain things (PostgreSQL was guilty of this for a long time):

# Set LLVM GCC as the default compiler for the system
export CPP='llvm-gcc-4.2'
export CC='llvm-gcc-4.2'
export CXX='llvm-g++'

On OS X Lion (10.7), are these lines still required? Is llvm-gcc (or clang) the default compiler for the system? Or will these lines still need to live in my ~/.bashrc?

like image 214
Bryson Avatar asked Jul 22 '11 22:07

Bryson


2 Answers

The default compiler on Lion is now llvm-gcc-4.2, although the standard selection (gcc-4.2, llvm-gcc-4.2, clang) remains unchanged from Snow Leopard. Try reading Using the right compiler.

like image 122
Chris Mowforth Avatar answered Sep 18 '22 05:09

Chris Mowforth


gcc is symlinked to llvm-gcc-4.2 on Lion.

lrwxr-xr-x 1 root wheel 12 Jul 21 20:51 /usr/bin/gcc -> llvm-gcc-4.2

lrwxr-xr-x 1 root wheel 12 Jul 21 20:51 /usr/bin/g++ -> llvm-g++-4.2

You can probably remove those environment variables without much harm.

like image 41
timwoj Avatar answered Sep 18 '22 05:09

timwoj