[racket-dev] Using clang to Build Racket on Mac OS X

From: Will M. Farr (wmfarr at gmail.com)
Date: Wed Jul 27 11:38:44 EDT 2011

Hello Racket Developers,

I thought I would write a quick note about building Racket on Mac OS X 10.6.8 with the new clang compiler (the new front-end to the LLVM compiler backend that is becoming the standard compiler on Mac OS X for XCode 4 and later).  Overall, it's been a good experience.  As promised, clang seems to compile the C sources in the racket distribution much more quickly than gcc, and has better-formatted error and warning messages.  I believe that the resulting native code libraries make racket run faster, but haven't run any detailed tests (there was quite a gap between my last gcc-based build and my first clang-based one, so the improvements may also be due to Racket development).  

The only wart in the process is the following: when compiling with clang or llvm-gcc with the -O4 option, which enables link-time optimization in the LLVM backend, the GC is unable to correctly determine the stack growth direction.  Unfortunately, the configure script doesn't realize that it cannot determine the direction---apparently the test gets it wrong, but appears successful---so supplying the direction manually via the configure argument doesn't work.  The build fails when first trying to run raco setup when the GC notes that the stack growth is inconsistent with its assumptions.  

I'm writing this email partly to see if anyone else has seen the error and knows what to do about it, and partly because I thought you might like to know how racket fairs on the newer OS X compiler.  If someone wants to test modifications to the configure script's stack growth test, I would be happy to take patches and test-compile them on my system.  For now, I am having great luck building with clang -O3; eventually, it would be nice to have the LTO, since that's one of the most exciting benefits of using the LLVM toolchain.

Thanks again for the Racket system!

Will
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 243 bytes
Desc: This is a digitally signed message part
URL: <http://lists.racket-lang.org/dev/archive/attachments/20110727/190c7ffe/attachment.sig>

Posted on the dev mailing list.