QBE - Compiler Backend: Version 1.3
51 points by orib
51 points by orib
One of my long-running hobbyist projects is a TRIPOS/Amiga Exec style little OS. No memory protection, flat memory map, message passing is just passing a pointer.
Having such a system be self-hosted is much easier with a small compiler that can produce PIE/PIC. Amiga-style libraries of course have to be PIC (obviously), but it’s also nice to not have to do a lot of extra load time patching of executables when they are loaded somewhere in the shared memory map.
GCC and Clang of course can do it but they’re enormous. TCC last I checked couldn’t do PIC. I need to look more into QBE.
Does this project have overlapping goals with Cranelift? Can't quite seem to figure out when one would use QBE
QBE is the "OpenBSD" of compiler backends, simplicity and minimalism are their philosophy, in their own words, they aim "to provide 70% of the performance of industrial optimizing compilers in 10% of the code." Its competition are indeed Cranelift and LLVM.
Unfortunately in the past it has mostly been used by hobbyist languages and compiler implementation such as myrddin a new-C (I see it was the OG zig, hare or odin) which seems dead, or cproc a hobbyist C compiler implementation which is still alive.
But since it has been picked up by Hare, my hopes have been up. Here is the answer to your question: https://harelang.org/documentation/faq.html#why-qbe-instead-of-llvm
I think it does, as well with LLVM.
I'm not that familiar with them, but there are plenty of comparisons out there. As far as I know QBE is supposed to be way simpler than those other two.
Really happy to have the new extern keyword. Although not mentioned in the release notes, this also works with thread, enabling initial-exec TLS. This is needed to access thread-local globals defined in other shared libraries (needed for ctype.h on FreeBSD). extern is also needed for regular global access in shared libraries (such as stderr) on platforms like macOS and Haiku. QBE-based compilers are now able to support a much larger set of operating systems and use-cases.
The performance improvements by Roland are also very appreciated. He did some really great work!