My coworker has been burdened with the task of building our product for Apple devices, which, it turns out, means that he has to use clang instead of gcc. On discovering this I did a couple of laps around the room shouting "EXTERMINATE" but when I settled down I wondered if there was a reason they used this. Is this just apple being hipsters or is there a reason to switch compilers?
I know next to nothing about compilers, but from my experience with clang it has much saner warning and error messages than gcc or others.
Also from what i could gather the idea behind clang is to have a gcc compatible but actually maintainable compiler.
Name:
Anonymous2014-01-16 19:43
Those who use clang say it has good warning messages. They also keep saying things like ``GCC may produce faster executables, but Clang itself compiles the code faster!'', so I don't take their opinions very seriously. That said, competition among compilers is a damn good thing.
Name:
Anonymous2014-01-16 21:00
Clang uses LLVM which is an exposed (i.e. to the user via files and a small executable dictionary (i.e. tools)) intermediate representation which then gets compiled to machine code. It can also be interperted.
Also the target architecture is not a build time thing in LLVM so you don't have to rebuild your compiler if you want to target ARM, AVR, PIC etc. from your x86 or (different executable formats for that matter e.g. ELF, whatever Windows uses). On the other hand, LLVM can't (yet) target even 5% of what GCC can.
It's also easy for languages all compiling to LLVM to communicate with eachother (one O.K sounding one is Julia).
Name:
Anonymous2014-01-16 23:42
Even OpenBSD is moving away from GPL. They are fucking insane. RMS is, I think, literally autistic. Have you heard the man speak?
Name:
Anonymous2014-01-16 23:45
I, by stark contrast, am autistic only figuratively.
>>9 He got pissed when I tried to hug him. I didn't even ask him for permission and I know I should have, but that makes me think he's literally autistic, without abusing the meaning of the word "literally" or using it for pure emphasis. I really mean it.
In the case of GCC, if you want to e.g. target ARM from x86 you have to build a compiler specifically for that from the GCC sources (i.e. the compiler target architecture is a build time option)
In the case of Clang, it always targets LLVM. The target architecture is a per invocation option for LLVM. You do not have to rebuild LLVM to target different architectures, you just invoke it with different options.
Your program will always have to be rebuilt to target a different architecture, in both cases. There have been efforts to make ``fat'' executable formats, (i.e. where the same file has machine code for various architectures and then a pointer for the loader) but AFAIK there has been little agreement between vendors.
>>12 Oh right. I've even used the Android gcc compiler. What a fool I am.
It seems like jamming all possible versions into a single executable is a bad idea. I mean, I see why, but there must be a better way.
Name:
Anonymous2014-01-17 6:40
>>13 Compile code into LLVM intermediate representation. Have a LLVM interpreter on each platform to translate the LLVM compiled binary into native code.
Name:
Anonymous2014-01-17 7:14
>>14 Compile code into Java bytecode representation. Have Java bytecode interpreter on each platform to translate the Java bytecode into native code.
>>14 Yeah, I get that part, but the way >>12 is worded it looks like he's saying they're talking about putting "machine code for various architectures," i.e. totally different compiler output, into a single file, which is appealing but mostly crazy.
>>17 Yes that's what I was saying. However, I did not mean the ``they'' you speak of to refer to the clang and llvm people, just the various efforts to standardize fat binaries throughout the years.
Name:
Anonymous2014-01-19 3:59
ree--re--e--e--ve-cer-se- -e ennecooeroner--rr
Name:
Anonymous2017-01-05 18:25
>>6 What compiler should I use if my main priority is minimal binary size?
>>7 Couldn't they make a modular compiler where the architecture targets are described by some kind of data file external to the compiler program itself? So the compiler itself only knows how to convert from source to IR, but you could "plug in" different configuration files to tell it how to go from the IR to object code?