Multiple architecture compiling (of ruby extensions) on OS X: The Killer -E Flag

At work I’ve had to compile a lot of extremely heavyweight Perl extensions for OS X. I have had a lot of trouble with it when I try to make Universal Binaries. I thought this was a problem with Perl or with the GUI toolkit I was trying to use, but just now I’ve run into some serious trouble trying to compile some simple extensions for a Universal Binary of Ruby. Ruby compiled OK, but I could not for the life of me compile the SQLite extension for it — which was absolutely trivial to compile and install when I was using a non-Universal-Binary Ruby.

I tracked down what was stopping me and it was this:

“gcc -E -I. -I/usr/local/lib/ruby/1.8/i686-darwin8.9.1 -I. -I/usr/local/include -O -g -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc -pipe -fno-common conftest.c -o conftest.i”
gcc: -E, -S, -save-temps and -M options are not allowed with multiple -arch flags

I looked up what the -E flag is and it’s “Stop after the preprocessing stage; do not run the compiler proper. The output is in the form of preprocessed source code, which is sent to the standard output.”

Well… as far as I can tell, running GCC with the -E flag is a fairly standard method to determine whether you’ve got a library installed. If I can’t do that with a universal binary Ruby because of the build flags that it carries along with it, I’m not going to be able to build *any* native extensions without huge headaches, and to be honest, if I wanted huge headaches, I’d be using Perl.

I may be missing something here — there may be a way to suppress those flags, and get on with life. But I sure don’t know what it is, and the Ruby extension build mechanism doesn’t know what it is either, so as far as I’m concerned, it’s time to kiss my universal-binary Ruby goodbye, and with it my dreams of putting together RubyCocoa applications which will work equally well on PPC and Intel macs.

Ah well.