5 ms·
Glad that the concept of compiler driver gets more exposures. "The `gcc` program itself is actually not a compiler...but a compiler driver" [1] is one of my fav
by mshockwave 3y ago
Glad that the concept of compiler driver gets more exposures. "The `gcc` program itself is actually not a compiler...but a compiler driver" [1] is one of my favorite things to tell newbie compiler engineers.
[1]: Clang, on the other hand, is not the case (at least the modern one). The `clang` program is a compiler driver and compiler AND assembler for majority of the platforms.
- fooker 3y agoclang is the gcc-compatible compiler driver. You can access the actual compiler frontend with clang -cc1.
- jcranmer 3y ago> [1]: Clang, on the other hand, is not the case (at least the modern one). The `clang` program is a compiler driver and compiler AND assembler for majority of the platforms. This framing is more likely to cause confusion than not, I think. `clang` is a compiler driver. `clang -cc1` is the compiler, and `clang -cc1as` is the assembler. They may all be the same executable, but the distinction between the tools is basically the first thing that happens. (Also note that the -cc1/-cc1as option has to be the very first option, it's not recognized in any other position).
- fsckboy 3y agoi could easily google it but, what's LLVM? (me googling it would not translate automatically into me writing up an answer for everybody, however, LLVM seems to be the name of a project that includes clang)
- mshockwave 3y agoFrom https://llvm.org https://llvm.org : "a collection of modular and reusable compiler and toolchain technologies"
- jcranmer 3y agoLLVM is a series of projects, of which the core project is an assembly-like language (more specifically a compiler IR (or five)), optimization passes for said language, code generators to convert it to several major assembly languages (or their machine code representation), and a few associated tools that are similar to things provided by GNU binutils. Other projects are included in LLVM. Clang is the C/C++ compiler. There is a C standard library, an OpenCL standard library, a C++ standard library (all inventively named lib<language>). There is also a library to support compiler builtins called compiler-rt, and a library to support OpenMP called openmp, and an implementation of C++ parallel executors in pstl. There is also a linker (lld) and a debugger (lldb). There is also a machine code optimizer called bolt, and yet another compiler framework called MLIR. Finally, there are several different Fortran compilers all called flang (don't ask).
- josephg 3y agoLLVM is also notably used as the compiler backend for Rust, Swift and (I think) Zig and more. Rust is as fast as C because llvm includes all the optimizations used to make C programs fast, and rust gets to reuse all of those optimizations. Llvm can compile working binaries for all modern platforms (windows, Mac, Linux, FreeBSD, iOS, android, etc) and basically all modern architectures (x86, arm, riscv, wasm, etc). It’s also the official compiler toolchain used by Apple on all their platforms (and apple fund a lot of llvm development). I think Google also uses it for their C/C++ code and some Linux distributions use llvm instead of gcc as a compiler toolchain. Llvm is everywhere. There’s a good chance llvm compiled some or all of the software you’re using to read this comment.
- astrange 3y ago> Rust is as fast as C because llvm includes all the optimizations used to make C programs fast, and rust gets to reuse all of those optimizations. I mean, that's not the reason Rust is as fast as C. It's because Rust semantically doesn't include mandatory slower things. The compiler it uses is an implementation detail.
- 3y ago
- zabzonk 3y ago> he `clang` program is a compiler driver and compiler AND assembler um, gcc does all those things.
- jcranmer 3y agogcc uses gas (from binutils) as its assembler, unlike clang.
- citizen_friend 3y agoAs a user, why would I care if the actual compilation occurs: - in the process - in a fork of the process - in a child process The outcome to me is the same.
- jcranmer 3y agoIn the gcc/gas distinction, the fact that gas is part of binutils, a completely separate project from gcc, means that there is another package you might have to update to use a new feature.
- fhuygfthdsafrsd 3y agoThe parent comment did say: > is one of my favorite things to tell newbie compiler engineers.
- sigjuice 3y agoExactly. This is all implementation trivia that is of absolutely no concern to me as a user.
- bregma 3y agoThat's right, It's all just stuff that happens when you hit F5 in your IDE. It's like not needing to know how an internal combustion engine works since all you have to do is tell the driver where you want to go.
- izacus 3y agoBecause it helps when the process breaks and you don't end up being helpless and unable to fix the most important tool you use at your work. Being ignorant is cute until its your job to be an engineer and fix problems.