3 ms·
Ask HN: Lighter alternatives to LLVM
Is it the only way to produce fast cross-platform binaries?
LLVM is huge and compile times can be slow.
I found several compilers related:
0. GCC
1. Zig started as LLVM frontend, finally with self-hosting, can do cross-platform codegen without LLVM.
- albinahlback 4y agoI presume you compile C/C++ code. How does your file structure look like? Do you have a lot of files with little to no content? You can speed things up by merging files. I have managed to reduce the building speed by around 95% by doing such simple things. Reducing the amount of unnecessary headers is also beneficial, but in comparison to merging files it barely makes a difference.
- cstrahan 4y agoSee QBE: https://c9x.me/compile/ https://c9x.me/compile/ > QBE is a compiler backend that aims to provide 70% of the performance of industrial optimizing compilers in 10% of the code. QBE fosters language innovation by offering a compact user-friendly and performant backend. The size limit constrains QBE to focus on the essential and prevents embarking on a never-ending path of diminishing returns. > The current version of QBE can target amd64 (linux and osx), arm64, and riscv64. "QBE vs. LLVM": https://news.ycombinator.com/item?id=25273907 https://news.ycombinator.com/item?id=25273907
- gavinray 4y agoI'd say QBE probably
- tester756 4y agoThat's interesting question We definitely need to see some modern alternatives
- TUSF 4y agoThe Go compiler doesn't use LLVM. They pretty much built all their codegen for every platform from the ground up. But that's only possible because they have the resources to do that. As far as I know, the only viable alternative to LLVM, is GCC, which I don't think is "lighter". Also, Zig still uses LLVM. It's just that because LLVM is C++, the Stage 1 compiler had to be in C++ as well, and they've since slimmed it down by having LLVM expose a C API that the (now "self-hosted") Zig compiler can directly talk to instead.
- stealthcat 4y agoReally, last time I read there’s zig compiler flag to not use LLVM at all (but not all features supported yet)
- TUSF 4y agoOk, it seems you're right. There is a flag for preventing the use of LLVM, and using a native backend for codegen, although without all the optimizations and such that LLVM has.
- JonChesterfield 4y agoLibfirm and cranelift are vaguely similar ideas, not yet mentioned here
- marssaxman 4y agoLLVM really is the tail that wags the dog for smaller compiler projects. In addition to QBE as many have suggested, you might take a look at AsmJit, if you are using C++.
- hulitu 4y agoGCC.