Monday, November 30, 2009

Sun C++ compiler precompiled headers implementation sucks.

I'm using the Sun C++ compiler (Sun C 5.9 SunOS_sparc Patch 124867-01 2007/07/12) on Solaris (5.10 Generic_141444-09 sun4v sparc SUNW,SPARC-Enterprise-T5220) for work.

I noticed that the compiler supports precompiled header files recently, and thought, great, this is going to speed up compiling enormously. For a given C++ package, compiling on Windows under VC9, the time taken decreases from 55 seconds to 22 seconds when precompiled headers is enabled. That is a significant difference, and well worth the effort of setting it up to work for you.
On Solaris, without precompiled headers, this same package takes 2:30s to compile. OK, it's an older machine, but when precompiled headers is turned on (-xpch=autofirst), the time taken, incredibly, increases slightly to 2:40s. I mean, seriously, WTF!?
With some more digging, I work out that the Sun compiler's implementation of pchs is infantile. They just collect up the postprocessed code from the headers and lob into one large file. There is nothing precompiled about Sun's precompiled headers, If anything, it's preprocessed headers. And it has to be implemented badly to take longer! Sheesh! Even the link above shows a minimal improvement for a really simple case.
Get it together Sun! Oh, right, Oracle is buying, and they probably care less.

No comments: