HI EVERYONE AND HAPPY SUNDAY!
Lately I’ve been trying to compile my ruby extensions with Clang. One reason I like trying out my extensions with Clang is because it catches some errors that GCC doesn’t. If you know the right things to set, it’s pretty easy to get your extension to compile with Clang. Unfortunately finding the right thing isn’t always easy, but I found the right bits to flip and I want to share!
Here’s how to do it. Add this line to your extconf.rb right after you require mkmf:
require 'mkmf' RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC'] # ... rest of your extconf goes here
Then when you compile your extension, just set CC to point at clang:
$ CC=/Developer/usr/bin/clang rake compile
You can see it in action in the nokogiri extconf. You can even see where clang helped me shake out some bugs, and I think that’s pretty cool.


rbconfig.rb may not be compatible?
@Nobu I suppose it’s possible. I believe the ABI output from Clang is compatible with GCC so the extension still works.
Nothing to do with Clang, but I don’t know your email.
It’s about racc : it apparently does not parse the new 1.9 hash syntax. As a consequence, flog and flay abort.
Am I right ? If so, do you plan something to fix it ? Or to have flog (and flay) use another parser ?
Flog is a nice tool. It would be a pity to let it go …
All th best,
M.