5 ms·
gcc is better than clang on every metric. Sorry, it's the facts. ¯\_(ツ)_/¯
by otabdeveloper4 4y ago
gcc is better than clang on every metric. Sorry, it's the facts. ¯\_(ツ)_/¯
- spoiler 4y agoI've always preferred clang for its better lints, and friendlier error messages (sans some decrepit parts around templates that are equally horrendous everywhere)... And theoretically clang has better ASM output in some cases I say theoretically, because it's been shown that GCC's "worse" ASM performs better; I'm not really an architecture aficionad, so I can't comment as to why that is. Also, it's been a few years now since I did C/C++. So, maybe these are no longer the case. Anyway, I've kinda pointed out what I like about clang over gcc, but I'd be curious what you prefer in gcc.
- hi_herbert 4y agoI wonder how up to date is the old belief of better error messages. The was some great redhat blogs about structured error messages in newer GCC.
- spoiler 4y agoOk, that's kinda true I suppose; I remember that GCC's error messages have indeed gotten better after a major version release. Also, when you say structured, do you mean errors over LSP, or do you mean more structure in the formatting when reporting in CLI?
- bayindirh 4y agoGCC returns pretty nice, colored and structured error messages in CLI for quite some time.
- hi_herbert 4y agoI meant in cli a bit like rust arrows logs
- yakubin 4y agoGCC has gotten better indeed, but it's still in a different league than Clang. I still get into situations where I can't make heads-or-tails of what GCC is saying to me, which can usually be easily solved by switching to Clang.
- hi_herbert 4y agoI don't do C++ anymore but I will forever remember the Vtable hell "messages" when doing OOP and doing a slight unintuitive mistake about destructor or constructor. Is this still a thing in clang?
- nikic 4y agoOne problem here is that GCC emits certain warnings as part of the optimizer, which results in many false positives that are essentially impossible for the lay programmer to understand. For example, jump threading might duplicate some code path and propagate constants in it, and then warn about an uninitialized variable / out of range access / etc in that code-path, even though it does not exist in that form in the original program.
- MauranKilom 4y agoFunny enough, this is exactly the kind of situation where other people cry "why did the compiler not warn me about basing optimizations on UB".
- newobj 4y agoclang doesn't output asm
- spoiler 4y agoI'm not sure what you mean? You can use `-S`
- hi_herbert 4y agoWhat is the status of ubsan, msan, tsan and others support for GCC though? Last time I checked they were a bit behind. I agree GCC make clang obscolete regarding C++ support and even performance. I don't know a comprehensive alternative to clang linter but I'm sure there are a few. Given that llvm receive more human resources than gcc by far, I once expected it to outperform gcc generally (e.g support for polyhedral optimizations, BOLT, etc) Unfortunately weirdly it seems llvm performance is mostly stagnant. I personally suspect we are reaching increasingly diminishing returns with AOT and that the performance graal would be a hybrid that also does JIT at runtime (beyond PGO therefore) and more interpretable than BOLT
- ghosty141 4y agoAt work GCC is a lot slower than clang, the project uses a bit much template magic but still, clang is faster. Where does this GCC is faster thing come from? I personally havent experienced it
- pyler 4y agoOld hype thing created by gcc fanboys :) They always claims so.
- hi_herbert 4y agoI mean faster runtime performance, I have no clue about compilation time. Well I'm basing this on the countless benchmarks I've seen, e.g. on phoronix over the decade. Also you have to understand that Clang -O2 is (was) "unfair" as GCC did not enable autovectorization until -O3. This has (is being?) changed.
- loxias 4y agoWhoa, really? Since when?? After a lifetime of using GCC, I (like many others) moved to clang a few years ago, out of frustration with the slow development of GCC, a desire to use new C++ features, and stayed because of the superior error messages and, in my use cases anyway, superior code generation. In addition, I gather it's a much cleaner and easier to maintain code base. As a result, we get to have cool things like emscripten, llvmpipe, all sorts of static analysis tools that would be more challenging to build in the GCC universe, and much more. Honestly, I thought GCC was slowing down development wise. Is GCC worth trying again? Can you name a few "cool new things" I can do with GCC that I can't with clang? There's plenty of the opposite...
- intelVISA 4y agoLLVM always delivers the cooler stuff I'll admit but GCC is ahead as an optimizing compiler, general lang support and generating cryptic messages.
- secondcoming 4y agoInteresting, I've generally found that clang is better at optimising, especially when it comes to auto-vectorisation.
- superdimwit 4y agoAgreed, autovec is in my experience where clang really shines.
- ncmncm 4y agoGcc pretty consistently delivers slightly faster code.
- pyler 4y agoproof?
- 4y ago