Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compare compilers

What pointers do you use to compare between compilers?

I'm told gcc is the best C compiler, is this true? If so, why?

I mean this generally, so you can state which compiler is more appropriate for which architecture.

(I hear igc would be more appropriate for Intel for instance, but I don't know why)

Personally I intend to use AMD 64 bit, develop both in Linux and Windows, GUI and non GUI apps.

like image 986
Ric Tokyo Avatar asked Jan 26 '09 12:01

Ric Tokyo


2 Answers

Um, dunno where you heard that gcc is the "best C compiler". It's simply the most ubiquitous and also a lot better than the native C compilers provided by most commercial UNIX vendors when gcc came about in the 1990s.

But what defines the "best"?

  • Time to compile code;
  • Size of compiled code;
  • Speed of compiled code;
  • Memory usage of compiled code;
  • Bugs and probability of seg faulting;
  • Support;
  • Community;
  • etc.

Different things matter to different people.

Here's one set of metrics comparing gcc to Intel's compiler and another comparison with clang. I'm sure you can find some comparisons to Microsoft's compiler too.

Generally speaking, people aren't all that concerned with the relateive size or speed or a compiler (or even necessarily with the size or speed of the output less than a factor of two) but whether it works or not (this was a real issue a decade or two ago), whether it supports the relevant standards and whether it has any oddities/bugs/features you have to workaround.

like image 162
cletus Avatar answered Oct 29 '22 16:10

cletus


In general: first of all, the most important aspect of compiler quality is correctness. A compiler with bugs or unexpected behaviour can really wreck your day. The quality of the resulting code, like speed, size and memory usage, is also at the top of the list.

The speed of compilation is another aspect, especially when compiling large projects.

One thing I find particularly important is error handling, the quality of messages you get when the compiler encounters stuff it can't (or won't) handle.

like image 34
Rik Avatar answered Oct 29 '22 16:10

Rik