[geeks] GCC vs Sun Studio

Charles Shannon Hendrix shannon at widomaker.com
Fri Oct 7 11:17:00 CDT 2005


Jonathan C. Patschke wrote:
> I'd like to rebuild[0] of all the software I run on my Solaris systems,
> and I'm faced with that same old question: "GCC or Sun cc?".
> 
> For my code, there's no thinking to it; I want to build the stuff I
> write with the most anal-retentive compilers available, so that leaves
> GCC out in the cold.  However, not everyone thinks like I do, so a large
> amount of the time I spend in a rebuild is tweaking others' code so that
> it compiles cleanly with compilers that actually expect to receive valid
> C and C++ source code as input.

I hear you screaming.  Don't you just love it when someone writes code 
for a multi-platform operating system and language, and makes it 
proprietary?

It's not just code though: scripts and makefiles often need tweaking too.

The whole GNU autoconf mess really gets to me sometimes.  When it works, 
it is wonderful.  When it breaks, it is the most indecipherable mess I 
have ever seen.

I wish someone would replace autoconf with something better, and that it 
would start getting used.

Regarding GNU compilers: all compilers have faults.  I've had some 
serious issues with Sun's C compiler not catching things before, and 
even DEC's well respected compilers have bit me with math bugs on the 
Alpha systems.

Most programmers trust their compilers without question, which is 
amazing given how complex they are, and how easy it is for them to do 
something stupid.

In 1995 I was doing embedded programming, and found out that GNU C 1.x 
was spitting out 32-bit opcodes even when I asked for 16.

It had no effect on most programs, so I suppose it didn't get caught for 
that reason.

However, on an embedded system, there is a world of difference between 
writing a 16-bit value to some hardware and writing a 32-bit value.

Stuff in my hardware was going nuts, and I could not figure out why 
until I started looking at assembly output of the GNU C compiler, and 
saw 32-bit ops where it should have been 16.

It also failed to zero bits in 32-bit values when it should have, 
resulting in garbage in high words instead of zeroes.

Combine those two bugs, and life is not fun.

> Historically, I've seen enough performance benefit in the output of
> Sun's C and C++ compilers to justify the time spent fixing things.  But,
> the latest versions I've used are GCC 3.3 and Sun Studio 8; GCC 4.0.2
> and Sun Studio 10 are current, and I have both of them.

GCC 4.0.2 is not current, it is a test release.  It's performance can 
range from better to dismal, depending on what you are doing.

It's also not been through extensive verification yet.

The release was made to generate public debugging.

Use it with extreme caution.



More information about the geeks mailing list