Clang 3.1 on MacOSX xcode?

Hi,

I have been working on a mac with XCode for 2 months now and I’d like to be able to use CLang 3.1 because of C++11 features that would help me a lot writing less verbose code.
I am not a unix/bsd-like massive user so I lack a lot of knowledge about how to connect things in my work environnement.
Here are some questions:

  1. are there official plans or release date for Apple to upgrade XCode to Clang 3.1 once it’s released? I assume that NO because I couldn’t find anything online.
  2. assuming that I get clang 3.1 from the release package or from sources, once built, how to make XCode use this version?

I’m sorry for such noob question, I’m a bit lost in this new environnement…
I have found these informations: http://stackoverflow.com/questions/1718597/using-llvm-clang-2-6-with-xcode-3-2
But I am not sure if it’s the good way to do it, as I need to be able to set the new compiler for a new project but keep the default compiler for previous projects…

Joel Lamotte

Any information about Apple products will come through official Apple channels. I suggest that you go to developer.apple.com for information about Xcode.

  - Doug

That's a good way to do it; it should only affect a single project.

-Eli

Hi Joël,

another way to do it is than the .xcconfig is to create a custom plug-in for Clang 3.1 or even Clang ToT or any version you install yourself. Then in your project Build Settings > Build Options > Compiler for C/C++/Objective-C, you will be able to add Clang 3.1 to the drop-down menu. The advantage is that you need to create that plug-in once and then you can use it for any future project without having to add that .xcconfig file every time you create a new project. Note also that several section banners in the Build Settings will have their name change to reflect your choice, e.g. "<here the name you chose for your compiler> - Code Generation".

Please find attached the one I have written for myself. You have to expand it in the directory "Library/Application Support/Developer/Shared/Xcode/Plug-ins". Note that this is not a hack by any mean as XCode (version 3 or 4) uses such plugin itself. You will notice that I called the compiler "LLVM/Clang ToT" and XCode is told to find it in /usr/local/bin. You can change those info to whatever you like. "LLVM/Clang 3.1" would be a better name in your case.

HtH,

Luc Bourhis

Clang LLVM Trunk.xcplugin.zip (4.39 KB)

Thank you all, you are very helpful! :smiley:
I will try Luc Bourhis’s plugin file but I think I’d better wait for the release first, as it should be imminent.

Joel Lamotte

I suppose you may need to (if you installed llvm+clang to /usr/local):

$ sudo mkdir /usr/local/lib/arc
$ sudo ln -s /usr/lib/arc/libarclite_macosx.a /usr/local/lib/arc

At least clang couldn't find that library in /usr/local, so I just linked the system one.

Regards,

Filipe

  Filipe

I suppose you may need to (if you installed llvm+clang to /usr/local):

$ sudo mkdir /usr/local/lib/arc
$ sudo ln -s /usr/lib/arc/libarclite_macosx.a /usr/local/lib/arc

At least clang couldn't find that library in /usr/local, so I just linked the system one.

I couldn't find an up-to-date, complete set of instructions that included these caveats, so I wrote one up when I went through this a couple of weeks ago.

The process is far from perfect, though. Xcode 4 doesn't appear to really support a custom-built toolchain.