Clang with Xcode 3.2.2?

I've been playing with clang on the commandline and I've had some success with it but I'd really like to try it out with some larger projects that are built with XCode. Should I just replace the clang binary that xcode 3.2.2 ships with, or does someone have an updated version of the xcplugin bundle that I can use?

Thanks,
Alex Macdonald

Hi Alex,

You can replace /Developer/usr/bin/clang with a symlink to the clang you have built.

Cheers,
Ted

hmm, but there's no clang++ provided with xcode 3.2.2 and looking into the clang xcplugin bundle it makes no mention of c++ support, maybe I need to update to the 4.0 beta, but I'd like to avoid that if possible...

This has worked well for me:
<http://shapeof.com/archives/2010/01/using_the_latest_llvm_with_xcode.html&gt;

XCode passes -x c++ or so to clang, which puts clang into c++ mode. No clang++ needed as far as I know.

(clang++ is mostly a symlink to clang)

clang++ is just a symlink to clang, so that's easy to add.

Teaching Xcode 3.2.2 to use clang++ is not possible since there is no way to tell it to use clang++ for linking C++ code, although it can be done with Xcode 3.2.3 by modifying the compiler .xcspec file. The hackiest way to get it working is to copy the .xcspec file from Xcode 4 to Xcode 3.2.3:

$ cp '/Xcode4/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/Clang LLVM 1.0.xcplugin/Contents/Resources/Clang LLVM 1.0.xcspec' '/Developer/Library/Xcode/Plug-ins/Clang LLVM 1.0.xcplugin/Contents/Resources/Clang LLVM 1.0.xcspec'

I recommend doing a backup of that file before you do this.

Hi Ted,

  I've done this and it works fine for building for the iPhonesimulator however when building for iPhoneos is falls back to the llvm-gcc4.2 compiler. I also changed the /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang with a link to clang from the trunk (build with arm support, of course). I've looked into 'Clang LLVM 1.0.xcspec' and added support for armv6 and armv7 but it still falls back to llvm-gcc4.2. So, what else should I change in this xcspec file or some other file.

Due to a fatal bug in llvm-gcc4.2 and gcc4.2 I can only use clang for my objective-C++ project.

With Xcode4 PR5 using llvm it all works, but the Xcode 4 source editor misses user scripts and has still many stability issues (make clean crashes consistently the session, etc).

Cheers, Fons.

Hi Ted,

I've done this and it works fine for building for the iPhonesimulator
however when building for iPhoneos is falls back to the llvm-gcc4.2
compiler. I also changed the
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang with a link
to clang from the trunk (build with arm support, of course). I've looked
into 'Clang LLVM 1.0.xcspec' and added support for armv6 and armv7 but it
still falls back to llvm-gcc4.2. So, what else should I change in this
xcspec file or some other file.

Hi Fons,

I'd strongly recommend getting Xcode 3.2.5. Xcode 3.2.2's version of clang is very very old and doesn't support iOS development.

With Xcode4 PR5 using llvm it all works, but the Xcode 4 source editor
misses user scripts and has still many stability issues (make clean crashes
consistently the session, etc).

Xcode 3.2.5 is best, Xcode 4 is still just a developer preview.

-Chris

Hi Chris,

   sorry for wasting bandwidth, of course I use 3.2.5. For my Objc-C++ project I need the latest clang as (llvm-)gcc has a fatal issue (see rdar: 7284383). So I got it to work for the simulator but not for generating native arm code.

Cheers, Fons.