Try Zig for all your compilation needs
First of all, “lightweight thread” is a lie. On my machine™, it takes Erlang/OTP 80µs to create (but not run) a Erlang Process. It takes Fish+btrfs+linux-zen 214µs to run (fork+execve) a Linux process. The said Linux process is created from a manually-written ELF that syscalls exit.2 with whatever garbage that happens to lie on the CPU registers at that time. Both numbers are amortized with little effort.
pub fn main() void {} in Zig exhibits no statistical difference in time to that manually-written ELF.
The zig command comes with its own cache by default.
Stick to -ODebug and -OReleaseSafe unless you enjoy living in UB hell. You may adjust the optimization level of LLVM or use Zig’s builtin codegen.
If that’s too slow, try feeding the compiler ZIR instead of Zig code.
If that’s still too slow, you don’t need a general-purpose compiler. Simply spray machine code into memory and run it.
That’s all I have to say on this matter. Thanks for coming to my TRASHx talk.