3 ms·
Probably a stupid question, but is LLVM a sort of cheat for "self compiling"? Shouldn't you need to compile LLVM as well?
by orblivion 5y ago
Probably a stupid question, but is LLVM a sort of cheat for "self compiling"? Shouldn't you need to compile LLVM as well?
- okareaman 5y agoIt used to be the case that a compiler compiled itself to bare metal machine instructions, but now with so many cpu instruction set targets that's no longer the case. LLVM uses an intermediate language like an assemby language. Another way to look at it is the TypeScript compiler compiles itself which is written in TypeScript but the intermediate language is JavaScript. V8 handles the translation of JavaScript to machine code, similar to LLVM translating LLVM IR to machine code
- orblivion 5y agoOkay, so we're treating LLVM intermediate language or javascript as if "assembly" in the bare metal days. Makes sense.
- chrisseaton 5y ago> It used to be the case that a compiler compiled itself to bare metal machine instructions, but now with so many cpu instruction set targets that's no longer the case. Tons of compilers emit machine code.
- okareaman 5y agoSure, I didn't say they didn't. Are you refuting what I said and implying that a compiler is not self-hosted if it doesn't compile to machine code?
- chrisseaton 5y ago> I didn't say they didn't You said 'that's no longer the case'. Isn't that the same as saying they don't?
- okareaman 5y agoIn the context of the question, it is no longer the case that a compiler has to compile to machine code to be considered self-hosting. I thought this was clear, but I guess it wasn't
- dundarious 5y agoThey’re working towards having native backends for x86-64, aarch64, etc., that are all written in Zig, making LLVM an optional dependency, and eliminating literally all uses of non-Zig code (including no mandatory use of C standard library, for example) for those builds. https://news.ycombinator.com/item?id=31052234 https://news.ycombinator.com/item?id=31052234 I’m assuming these will primarily be for super fast debug builds (at least to start), and LLVM (and maybe C backend too) will still be the favored backend(s) for release builds.