Slashdot Mirror


Comparing Linux C and C++ Compilers

ChaoticCoyote writes "I've posted a comparison of recent GCC versions (3.3, 3.4, and the coming 4.0) with Intel C++ 8.1, including several benchmarks and "state-of-the-product" reviews. The new article replaces an older piece I published in late 2002. This new comparison marks what I hope will be an ongoing series that tracks the quality of Linux compilers."

33 of 379 comments (clear)

  1. gcc! by dosius · · Score: 4, Insightful

    well, GCC has one thing going for it - it's open source - and that's why I'm sticking with it. XD

    FP?

    Moll.

    --
    What you hear in the ear, preach from the rooftop Matthew 10.27b
    1. Re:gcc! by Anonymous Coward · · Score: 5, Informative

      GCC has other things going for it, too.

      ProPolice stack smashing protection patches for one. (and many others besides.)

      And cross-platform compatability. I can compile for targets. Like working on embedded products.

      Oh, and Distcc for realy big projects to get compiled quickly using easy to setup clusters.

      It's "correctness" is pretty high up their, too.

      Remember, for Unix:
      compatability, portability, flexibility > speed.

      If all you ever have to worry about is x86, then it's not that big of a problem, but for anything else there is no comparision to GCC that I am aware of.

      That it having it free software rocks.

    2. Re:gcc! by antifoidulus · · Score: 4, Insightful

      Yeah but how important is ultra-high performance for you? If you are in charge of a multi-million dollar super computer, I would hope that you wouldn't say, "Well, I can get better performance out of this commerical compiler, but I disagree with commercial software, so I'll use open source"
      My view on the whole open-vs-closed debate is whatever gets the job done. There are a lot of open source tools that get the job done quite well, and I use those. But there are also occaisions where proprietary software gets what I need done quicker and easier, so I'll use that.

    3. Re:gcc! by k4_pacific · · Score: 4, Funny

      In other words, you can compile GCC with the Intel compiler, but not the other way around.

      Seems like there's an "In Soviet Russia" joke in there somewhere.

      --
      Unknown host pong.
    4. Re:gcc! by UnderScan · · Score: 5, Informative

      Nope, no troll.
      Icecream is created by SUSE and is based on ideas and code by distcc. Like distcc it takes compile jobs from your (KDE) build and distributes it to remote machines allowing a parallel build on several machines you've got. But unlike distcc Icecream uses a central server that schedules the compile jobs to the fastest free server and is as this dynamic. This advantage pays off mostly for shared computers, if you're the only user on x machines, you have full control over them anyway.

    5. Re:gcc! by vadim_t · · Score: 4, Informative

      I don't know what's up with distcc, but every time I try it, it ends failing at some point. For example a few days I was installing Gentoo, with CFLAGS having -fstack-protector, and distcc crashed somewhere in the bootstrap due to the stack protection. I didn't figure out if it's some kind of conflict, or the stack protector kicked in due to a bug.

      I also heard reports from people about Gentoo not completing the basic installation when trying to do with with distcc even without the stack protector.

      The idea itself is really nice, but at least for me doesn't seem to work nearly as well as it should.

    6. Re:gcc! by Xabraxas · · Score: 4, Insightful
      Sorry but... ProPolice sucks.

      Why?

      Nobody cares about stack smashing protection anymore these days.

      OpenBSD

      Hardened Gentoo

      GCC 4.0 has libmudflap and -fmudflap for C and C++. While this isn't exactly the same as stack smashing protection, it is still very effective and much more efficient.

      Last time I checked GCC 4.0 wasn't stable.

      It's not entirely without reason that IBM still hasn't posted ProPolice for inclusion in the FSF GCC mainline. The patch against SUSE's hammer branch has been floating around literally for years, but they know really only very few people truely believe it makes a difference.

      That's crap. Propolice does exaclty what it is supposed to do. It doesn't protect against all stack smashing attacks but no one ever claimed that it did.

      --
      Time makes more converts than reason
    7. Re:gcc! by Sipos · · Score: 4, Insightful

      It seemed to be surprisingly fast in these benchmarks. Did you see the size of the icc binaries. I am not sure what the options for icc mean but I guess they must be doing loop unrolling/peeling and aligning functions to improve the cache useage. If you enable these on gcc you can gain a huge increase in performance (at the expense of larger code size). It may well be able to produce faster binaries than icc for the same size in many of the tests.

    8. Re:gcc! by ken_i_m · · Score: 5, Informative

      The gcc is not a linux compiler. The g stands for Gnu. The linux kernel and the systems built around it are most often compiled with the gcc. The gcc existed long before Linus's first kernel release.
      --
      ken_i_m
      Founder, Bozeman Linux User Group

    9. Re:gcc! by adamwood · · Score: 5, Interesting

      Erm. If you look at the current top500 you'll see that there's a Xeon machine in the top 5.

      Have you actually tried other platforms? The best compiler on a given architecture is usually the chip vendor compiler -- IBM's compiler beats GNU on PPC 970, HP's beats GNU on Alpha, etc.

      Sure you can find the odd piece of code where Gnu will beat vendor compilers but overall, and particularly for large scientific workloads, vendor compilers win for raw speed.

    10. Re:gcc! by bit01 · · Score: 4, Insightful

      "is $x > $y?"

      This is only true if you include all costs and benefits, not just the sticker price.

      Commercial vendors would love for customers to consider only the sticker price without taking into account the many hidden and recurring costs in most commercial software solutions.

      ---

      Astroturfers are scum.

  2. Re:GOT IT! by neil.pearce · · Score: 4, Informative

    by default, gcc (with a .c or lang-spec set to c)
    let's you forget the #include, and the missing return value

  3. Re:3.5 vs. 4.0 by kristofme · · Score: 5, Informative

    The current version of GCC is 3.4.2, and the next planned version will be called 4.0.0
    More info on the GCC site

  4. Performance isn't everything. by acceleriter · · Score: 5, Insightful

    Even if the Intel compiler is faster, it's best not to get in the habit of becoming locked into any proprietary platform. How likely is it that features on which one could come to depend will be kept available on free platforms, much less future processors not made or controlled by Intel?

    --

    CEE5210S The signal SIGHUP was received.

    1. Re:Performance isn't everything. by Screaming+Lunatic · · Score: 5, Insightful
      Even if the Intel compiler is faster, it's best not to get in the habit of becoming locked into any proprietary platform.

      That is why it is important to compile your code using multiple compilers. Prefer to write code to the C/C++ standards rather than to a particular compiler's idiosyncracies, GCC included. Different compilers also emit different warnings, helping one find bugs sooner.

  5. Re:Binary size by multipart · · Score: 4, Informative

    This mostly comes from specializing loops and jumps. ICC does aggressive loop versioning (even including runtime CPUID checks) and, especially with profile feedback (not tested in this benchmark, unfortunately) ICC will try aggressively to try cheap alternatives before trying the generic approach. Think about expensive instructions such as divides and indirect jumpes here. GCC doesn't do that.

  6. I am dissapointed in Intel by Billly+Gates · · Score: 4, Interesting

    I hear people complain about gnu C++ alot because its not as good as commercial compilers.

    However from what I see is the performance of the compiled code is the same with the exception that the resulting binaries are alot bigger.

    Maybe gcc is good on x86 but sucks on other architectures? I know the Sun and SGI geeks have complained for years that gcc does not run well on their platforms compared to expensive alternatives by their vendors.

    Has anyone run ICC and VC++.net on Windows? How does it compare to Borland and MS compilers under Windows2k?

  7. Vectorization? by r6144 · · Score: 4, Interesting
    On some numerical tests icc seems to give twice faster code than gcc, and I think it is probably due to icc's automatic vectorization (the difference in almabench is said to be mainly due to the superior software SSE-based sin() and cos() functions used by ICC, correct me if this is wrong).

    I think the author had better mark the tests whose inner loops have been vectorized, since while some algorithms are easily vectorizable, some are not, so the performance of both are interesting. After all, we care most about the features (such as automatic vectorization) of the compiler, while benchmarks only very roughly reflect the existence of such features, the applicability of them, and their effects.

    1. Re:Vectorization? by ChaoticCoyote · · Score: 5, Informative

      GCC 4.0 (which is, of course, "in development") has recently included automatic vectorization -- another of the "good things" that will be coming with the new architecture.

      My next article will compare automatic vectorization and profiled optimizations.

  8. Re:Not a lot of selection for Linux compilers, eh? by tomstdenis · · Score: 5, Insightful

    Actually there are. LCC and TinyC come to mind. They're not used much in production [well LCC was reborn as LCC-Win32 for a while] but really GCC is the better choice.

    The problem with the "good old days" was that as my friend Dave Dunfield said once "C compilers are a dime a dozen".

    Just because you had a dozen C compilers for your 8086 doesn't mean you were better off. In fact most compilers for the 86 were crap [e.g. smallC, byteC, Zortech, paradise, etc...]. In fact the only half-way decent 86 compilers I recall are Turbo C [v3.01 was ok] and Micro-C [by Dave Dunfield so maybe I'm a bit biased there...].

    Note I'm not saying more compilers is bad. The problem is like any field "new" doesn't imply better. You have to tackle problems and answer them.

    For instance, GCC is rather large and can be slow/memhog on some files [C++ in particular]. A viable competitor for Linux would be one which optimizes decently while not being such a hog. It could pitch in when you can't build a file [say from VisualBoyAdvance which requires ~1GB of ram to build with GCC 3.4.2]...

    For the most part though, contributing to GCC makes more sense than writing your own compiler. First off, GCC is a "standard". So you're likely to get a huge audience that way. Second, GCC is already well established. It's a very good suite of tools and frankly hard to compete with. Third, you'll save a lot of time.

    For all intents and purposes you could change your argument to why do "linux" boxes only run the Linux kernel? I mean for all intents and purposes you could write your own kernel that was interoperable and use instead. For the same reason why contributing to GCC is a good idea so is contributing to the kernel [instead of writing your own] is a good idea.

    One last caveat before I send this post. I do agree though that writing such said tools [kernels or compilers in this case] are a good idea for educational purposes. It means a lot to know how to write a functional [and ideally half-way decent] compiler even if it only targets one platform and covers only part of a language. :-)

    phew...

    Tom

    --
    Someday, I'll have a real sig.
  9. This guy must be a nerd... by Isldeur · · Score: 5, Funny


    You can tell this guy is a nerd, but it goes far beyond the pizza and mountain dew... Is that really an empty tub of frosting sitting my his computer?? :)

    1. Re:This guy must be a nerd... by ChaoticCoyote · · Score: 5, Funny

      Yes, it is frosting. Chocolate frosting. How else can I maintain my svelt figure?

  10. Re:illogical hostility? by ChaoticCoyote · · Score: 4, Insightful

    The hostility mystifies me. I'm a semi-active participant in the GCC mailing list, and the people who work on GCC are very helpful, open, and communicative. Some even thank me for my QA efforts.

    I don't see that my article is negative about GCC; in fact, I'm very clear that Intel's compiler isn't a replacement for GCC, and that GCC is a fine product. Maybe the complainers can't read?

  11. Re:I don't get it... by ChaoticCoyote · · Score: 4, Informative

    It's called a "typo". Fixed.

  12. Re:ProPolice by DrSkwid · · Score: 4, Interesting

    The OpenBSD team use it, and I think they know better than you or I.

    Not by technical choice, they want to use plan9's C compiler but have licence quibbles.

    Quoting Theo : "in particular we were interested in the c compiler"

    --
    There are places where the networks are not touching,and there are places where they are-Boeing's Lori Gunter
  13. C/C++ vs. Fortran by Aardpig · · Score: 4, Interesting

    I find it interesting that there are only two C/C++ compilers available for Linux, as compared with seven Fortran 90/95 compilers (soon to be eight with the release of GCC 4.0). This not only dispels the myth that Fortran is a dead language, it also suggests that there is much more of a competitive market in compiling numerical code, than in producing other types of software.

    --
    Tubal-Cain smokes the white owl.
    1. Re:C/C++ vs. Fortran by Too+Much+Noise · · Score: 4, Informative

      Who said there are only 2 compilers? He only tested 2, that's all. Here's a bit of a list - and notice that some of these are targeted specifically to scientific computing:

      1. GCC
      2. Intel compiler (Intel only)
      3. Comeau
      4. PathScale (Opteron only)
      5. Portland Group (PGI)
      6. Borland

  14. Re:3.5 vs. 4.0 by ChaoticCoyote · · Score: 5, Informative

    The GCC Steering Committee changed the next version of GCC from 3.5 to 4.0 while I was in the midst of writing the article. I missed changing a reference; the typo is now fixed.

  15. Re:Not a lot of selection for Linux compilers, eh? by Jollyeugene · · Score: 5, Interesting
    Other compilers for Linux (Try google before you troll):

    TCC (tiny c compiler).
    Compaq Alpha C compiler.
    OpenWatcom C/C++ compiler
    TenDra C/C++ compiler
    egcs compiler (which merged into gcc- they saw that it had some advantages.)
    ChEmbeddable
    Cint c/c++ interpreter (not exactly a compiler)
    CC65 Commodore C compiler
    Absoft C/C++ Fortran compiler
    lcc

    These all run on linux. Some are open, some are not. GCC is used mainly because it is portable to just about anything-- so there goes your argument of GCC restricting choice. GCC exists to promote choice, and it does this.

    Take your code written for Visual Studio and compile it on Sun. Can't do that with Visual Studio? No MFC on Sun? Your best bet will probably be good old GCC with WINE. So how are you restricted by gcc?

    Now, if you want to make a cross compiler to compete with gcc- one with seperate front ends and back ends, so it can accept multiple languages, and can compile to just about every machine on earth-- then nothing is stopping you. Oh, what is that? Not interested. Neither is anyone else. Programers see no need to duplicate something that has been done well the first time. One good cross compiler is enough- GCC represents a NATURAL MONOPOLY.

  16. The even-odd thing... by devphil · · Score: 4, Informative


    ...does not apply to GCC. Never has. And it will not in the future, unless we radically change the way we do development and releases.

    3.4 follows 3.3 follows 3.2, and none of them were singled out as "developmental" or "experimentalal" or "extra stable". The experimental-vs-stable changes all take place before any release branch is made. There's more info on the website if you want.

    --
    You cannot apply a technological solution to a sociological problem. (Edwards' Law)
  17. Re:illogical hostility? by JoeBuck · · Score: 5, Informative

    The complainers can't read. I'm a member of the GCC steering committee, and I'm very happy with Scott's work (sorry, dude, I'm not going to call you "ChaoticCoyote"). It's not perfect, but it has helped to improve GCC.

  18. Re:3.5 vs. 4.0 by FullMetalAlchemist · · Score: 5, Interesting

    Tree-SSA is not new, it's new to GCC but the concept of Single Static Assignment itself is ancient and using it for optimizing trees in not new.
    The problem is the GCC codebase is so badly designed it takes major changes to many parts to introduce a very old concept of SSA into it. So you can't take advantage of a generic SSA but have to introduce different patches for the system.

    Back in my university days we did SSA in our own compilers, for a 5 week course! GCC needs a complete rewrite or a switch to something like TenDRA, which right now produces good solid code, but not extremely optimized machinecode. On the other hand TenDRA is really well designed so it would catch up really fast if more people worked on it.

  19. Re:apples and oranges by Anonymous Coward · · Score: 4, Informative

    This isn't true: V8.0 works fine on Athlons.