(Discussion) Clang Versus GCC : Better Compiler ?

This thread is open for discussion for anyone who have interest in discussion related Clang & GCC. Clang is replacement to GCC, so you might be thinking that argument syntax & semantics would be different & you gotta learn it again from scratch to use Clang. Well in that case, you're wrong. Clang have copied its argument syntax & semantics so you can easily switch to Clang from GCC, and you won't have to learn anything new again to use Clang.

But why someone would do that ? Couple of main reasons are :
- Compilation time : It is pretty fast than GCC, as they claim. Try executing your big fat C code & compare its compilation time. It's almost ~1.7 times faster, which is BIG deal!
- Better Disgnostics : Just incase your code fails to execute, it will give you precise detail on error. So, less time wasted in iterating the error.

Nor Clang or GCC is better in all classes, so it needs a discussion!
So, if you're keen to test both compilers & planning to switch from GCC to Clang. Let's discuss in here, the Pros & Cons of both compilers & differentiate on the fact that which compiler outperforms other in what aspect. Let's talk about optimization, memory footprint, code compilation speed, code diagnosis, C++11 support & speed of resulting binary.

Replies

  • avii
    avii
    Clang fan here. At my former company, I came to know about clang and I was a GCC user earlier. It was so fast, in our case, it was more than 12 times faster. However I have no major complaints with GCC also. Just that its code base is horribly large and I find it, not so well organized, well thats my opinion.

    My complain with Clang is that Apple (or its core devs) change internal APIs with new versions and for some, no backward compatibility at all. So this would break our code. And the apple engineers would say, we are making progress and we are brining change and this is essential. Though I agree, it was a frustration for us.

    Do read about history of Clang and how it came to existence, it would be a very interesting read and shows why Apple had to ditch GCC.
  • Kaustubh Katdare
    Kaustubh Katdare
    Curious to know why are people obsessed with speed of the compiler? Are milliseconds going to make a difference to your projects? ☕
  • avii
    avii
    Kaustubh Katdare
    Curious to know why are people obsessed with speed of the compiler? Are milliseconds going to make a difference to your projects? ☕
    I am currently compiling something from last night, it will take 8 more hours.

    The people who write device drivers and low level code, it will take lots of time to compile and errors are very difficult to debug
  • Void Runner
    Void Runner
    #-Link-Snipped-# : It makes a huge difference. Compilation/build time, for one. If you are doing a run-time compile, it is of the essence. Sometimes the compilation process takes hours. Certain compilers also tend to work better on certain CPU architectures. All this must be taken into consideration.

    I was more of a GCC user, but my work mostly involves simulation work and not real world applications. That being said, I do not generally face a huge issue. Will need to check Clang out.
  • Kaustubh Katdare
    Kaustubh Katdare
    If it's run time, I agree. I've spent hours and hours just to ensure that the PHP compiling time is cut down and we've minimal page loading times. I'm not a programmer myself, and have never seen anything that'd take more than a few minutes to compile. This thread is quite informative, will keep an eye on it.
  • Abhishek Rawal
    Abhishek Rawal
    Void Runner
    Certain compilers also tend to work better on certain CPU architectures. All this must be taken into consideration.
    Like Intel's ICC for x86/x86-64 architecture if you really care about every single percentage of optimization, it usually beats GCC.

    avii
    However I have no major complaints with GCC also. Just that its code base is horribly large and I find it, not so well organized, well thats my opinion.
    Agreed.
    BTW does Clang support optimization for code size ? or have optimization feature like GCC's -0, -0g, -0s, -0fast ?

    Kaustubh Katdare
    If it's run time, I agree. I've spent hours and hours just to ensure that the PHP compiling time is cut down and we've minimal page loading times. I'm not a programmer myself, and have never seen anything that'd take more than a few minutes to compile. This thread is quite informative, will keep an eye on it.
    Check this latest benchmarks, Clang looks impressive : #-Link-Snipped-#

    I installed Clang on Arch & funny thing is it depends on GCC's libstdc++ , that's ridiculous ?

    I have incoming exams, after it's done I will jump back in this thread, hoping to do some comparative test between GCC & Clang.

You are reading an archived discussion.

Related Posts

Hello I am a mechanical Engineer 2014... Passout .....I just wanna know that is TCS EIS(Engineering & Industrial Service)domain good for mechanical engineers .???.can a mechanical engineer stick to core...
Group of researchers from University of California , Riverside (Bourns College of Engineering) used a material found in Silly Putty and surgical tubing, for making lithium ion batteries that lasts...
Have you ever visited France, Spain, Japan, China, Korea or countries where English is not the primary language? You must have faced issues while reading sign-boards or restaurant menu. At-least,...
Are there job openings for Mechanical freshers...??
Nokia India has come up with a new low-budget smartphone with Nokia 225 priced at Rs. 3199. The phone weighs 99.8 g and has a 2.8 inch screen with QVGA...