CrazyEngineers
  • (Discussion) Clang Versus GCC : Better Compiler ?

    Abhishek Rawal

    Abhishek Rawal

    @abhishek-fg9tRh
    Updated: Oct 23, 2024
    Views: 1.3K
    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.
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • avii

    MemberMay 16, 2014

    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.
    Are you sure? This action cannot be undone.
    Cancel
  • Kaustubh Katdare

    AdministratorMay 16, 2014

    Curious to know why are people obsessed with speed of the compiler? Are milliseconds going to make a difference to your projects? ☕
    Are you sure? This action cannot be undone.
    Cancel
  • avii

    MemberMay 16, 2014

    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
    Are you sure? This action cannot be undone.
    Cancel
  • Void Runner

    MemberMay 17, 2014

    #-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.
    Are you sure? This action cannot be undone.
    Cancel
  • Kaustubh Katdare

    AdministratorMay 17, 2014

    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.
    Are you sure? This action cannot be undone.
    Cancel
  • Abhishek Rawal

    MemberMay 17, 2014

    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<number>, -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.
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register