Is clang finally better than gcc?
I know gcc is more portable thanks to mingw on windows, but how does clang fare?
CLANG
>I know gcc is more portable thanks to mingw on windows,
There are official Clang binaries for Windows...
> clang
Enemy of freedom.
I know.
But compiling "cross-platform" code doesn't always work, at least with gcc, I want to know if Clang is any better at this.
how come?
Google finally dumped GCC with Oreo, so probably yes.
Clang is much better for development than GCC. It has better compiler warnings, faster compile times, static analysis, and run time sanitizers. Most of the new features in GCC are just ported from Clang. Clang and GCC are equally portable on Windows; look into MSYS2.
noob here
what the fuck is clang, really? is it clang or llvm doing the compiling?
Put simply, Clang compiles C-like languages in to LLVM IR. LLVM compiles that in to machine code.
llvm is a compiler backend, it specifies it's own IR (intermediate representation (very low level programming language)) and produces optimized machine code from it for various architectures.
Clang if frontend for C, it parses C code to syntax tree and produces IR from it.
he's a GNU/Freedom defender
objectively superior
more portable
llvm -> more portable
makes faster and the binaries are faster too
The point being that all the tooling can be written for just LLVM IR so every language benefit from improvements to LLVM (e.g. you don't need to write an optimizer for each specific language).
can it compile kernel?
Which one?
the
it can compile freebsd and openbsd kernel, probably other bsd kernels as well, plan 9 kernel and specific branch of linux kernel (not the mains afaik, linux is built against gcc and its specific features and behaviors)
GCC > Clang
Plain and simple. Clang is a nice alternative, probably second-in-line, but
...but i'm living in 2009
GCC binaries, when the sources are written to take advantage of GCC-exclusive behavior, are faster than the LLVM+Clang equivalent when optimizing for LLVM-exclusive behavior.
That said, LLVM is much better designed and faster to compile. It is also easier to develop with as well because of its compiler warnings, analysis tools, and its modularity.
>mingew
Not really. GCC is usually faster nowadays and its error messages have the same quality.
Clang is a compiler front end, and LLVM is its backend. GCC is a collection of different compiler programs developed by the FSF.
It's better than MSVC at least.
Clang is a meme. They had better error messages out of the gate and the non gpl license makes BSD guys hard. But gcc has caught up in error messages and still produces faster code.
>Most of the new features in GCC are just ported from Clang.
Can you give me the source for that allegation?
I bet Stallman would agree with you too.
desu you didn't get the joke minge is a British word for vagina, fucking disgusting words though
Which of gcc and g++'s extensions are supported by clang and clang++?
I don't care about the other features clang has, the better compiler messages are nice though, and so are the sanitizers.
I care mostly about the optimisations. Clang seems to make different optimizations than GCC.
For example, clang will convert if-else chains to a jump table when possible, GCC doesn't do this. This is a useful optimisation in recursive template metaprogramming.
Clang also seems to be much more willing to unroll a loop with a lot of iterations, GCC seems to only do it when the number of iterations is lower than 4.
I'm not exactly sure which one is objectively better at optimising. Sometimes clang produces faster binaries, and sometimes GCC does.
As for compilation times, lately it seems to be closer to GCC compile times now.