Monday, April 23, 2007

Another gcc bug

If you're running Mac OS X, check your gcc version before compiling Factor. If you have this version, the resulting VM executable will be useless:
powerpc-apple-darwin8-gcc-4.0.0 (GCC) 4.0.0 20041026 (Apple Computer, Inc. build 4061)

The following version is OK:
powerpc-apple-darwin8-gcc-4.0.0 (GCC) 4.0.0 (Apple Computer, Inc. build 5026)

Thanks to Robbert van Dalen for first noticing this issue. Unfortunately there is no workaround. You have to upgrade your gcc.

gcc seems to have chronic issues with global register variables. This latest one is caused by gcc compiling a function to save and restore all registers in the range r13-r31, however r14 is the datastack pointer, which is clobbered as a result. Thankfully it is fixed in Apple's latest gcc, but I really wish gcc was more stable.

In my entire Java career, I never found a single bug which I could blame on the HotSpot JIT compiler. The Java language and libraries suck, but I really give the HotSpot team credit for writing a compiler which is fast, stable, and generates efficient code.

On the other hand, in only a few years of working on the C implementation of Factor, I've encountered plenty of gcc bugs. This is embarrassing for a project which claims to be the cornerstone of both Linux and Mac OS X.

6 comments:

Anonymous said...

gcc is dated.

Anonymous said...

So what? There was egcs, which was a major step for GCC. I think they rewrote a lot. There was gcc3, now gcc4.

By now they *really* should use regression tests and the like.

Maybe C as an implementation language for something like a compiler sucks. (I strongly guess so. I'd never use it for that.)

Slava Pestov said...

So what? Well, after Factor 1.0 is done, I'm going to reduce the C to a minimum. Have the image loader in C so I don't need to mess with generating executables, and do the rest in Factor.

Anonymous said...

I meant "gcc is dated. So what?"

If anything, the number of rewrites and new implementations in gcc should have introduced more quality control into the project.

Apparently that did not happen, though.

Elie Chaftari said...

Thank you Slava!

That did the trick. I hadn't found a reason compelling enough to upgrade Xcode before.

Now I can happily hack on the Factor bleeding edge.

Matt said...

gcc, hehe. someone fell for it, hahaha. don't believe the hype.