For my perspective, the problem is the lack of mature AVX support for Clang/LLVM. To be fair, Clang does a quite well with scalar code. I also think that the Clang/LLVM team is doing an excellent job with the compiler. However, it still lags behind GCC 4.2 in SSE code and the AVX code isn't quite ready yet. While the GCC 4.5/4.6 C/C++ compiler will generate the newer assembler code, the cctools package (as and ld tools) will not handle the newer AVX assembler instructions. The GCC Binutils package will build some components on Mac OS X, but I don't believe that the linker (ld) is one of them. I would recommend GCC 4.2 for pre-AVX vector code, but Clang is just fine for scalar code.
As far as I know, the Intel C/C++ compiler is the only option for generating AVX vector code from AVX intrinsics. The drawbacks of the Intel tool is the lack of Objective C and Blocks support and the fact that it is not free. The compiler also ships with optimization, math, and threading libraries packages. When you build with the Intel compiler, you will need to distribute the Intel dynamic libraries or use static linking for the Intel libraries. An alternative for AVX is to write assembler code that would be compiled via nasm or yasm.
I have been building Clang/LLVM from the LLVM svn repositories approximately every other week. They will build and then install into the /usr/local directory. An XCode plug-in for 3.2.6 can be used to directly use the new build from XCode. With this approach, the developer can always switch back to the Apple-supplied GCC or Clang compilers if the one built from the LLVM svn repository is problematic.
Overall, I don't take issue with Apple's approach of putting the major effort into Clang/LLVM. It would be nice if the vector support was more mature, especially since AVX-capable machines are already shipping. Perhaps some of the Intel compiler folks could help out if they are not already doing so.
Steve
On May 29, 2011, at 3:05 PM, email@hidden wrote (from David Frantz): You are right that Apple does not support newer versions of GCC. More specifically they don't like GPL3 from what I understand.
As to your question about XCode I can't honestly say as I've never tried alternative compilers with the IDE. However there is an easy way to install newer compilers and that is through MacPorts. I ended up really hating MacPorts so it was un-installed sometime ago. A second choice would be a project called HomeBrew which I've been considering. If all else fails you can go the DIY route with GCC.
Out of curiosity I have to ask: why the need for a newer GCC? In the end it really looks like Apple is going the CLang/LLVM route, so if you want to migrate to a newer compiler tech this would be the way to go. CLang is obviously a bit immature but it does surprisingly well considering it's relatively new status. Plus the entire suite has many eyes looking at it, thus a state of the art diagnostic capability.
Sent from my iPad
On May 29, 2011, at 6:46 AM, Brian Norh <email@hidden> wrote:
Hello.
I have a piece of software that I'm building using Xcode 3.2.6 and GCC 4.2. I'm going to upgrade to Xcode 4 and at the same time I'm thinking about also moving to a newer compiler. As far as I know Apple doesn't ship a version of GCC newer than 4.2 so I guess my option would be to download and install it myself. I'm a bit shaky about using a non-Apple supplied compiler so therefore I'm asking if anyone have any comments on how to do that. I have found several resources about actually building it so that will probably go well. However, I'm a bit shaky on a few other things, mainly:
* Will I be able to ship binaries produced with the new compiler or will they depend on a newer runtime being present on the machine?
* Can I use it together with Xcode?
Any suggestions and ideas are highly appreciated. I'm only targeting 10.6 and 64 bit Intel so PowerPC or ARM support is not necessary.
Brian
|