On Building a Zig Compiler

Andy Keep is a software engineer who specializes in compilers. He built a Scheme to C compiler called ‘Nano Pass’.
Presentation at Clojurecon here:

Andrew W. Keep

Lead Compiler Engineer

http://andykeep.com/

When I heard Andrew Kelly say he was interested in building a stand alone compiler I thought immediately about Andy Keep.

I wrote to Andy,

“Currently, Zig uses llvm as it’s compiler, but the Zig devs are working towards building a Zig compiler. I don’t know if you are familiar with the project, but I thought your passion and their need would be a great opportunity for everyone.”

Andy Keep responded,

“I do not know a lot about Zig, but after taking a quick look through some of the documentation, I’m a little surprised to hear you all are interested in moving away from LLVM as the compiler backend. What are you all hoping to do that LLVM doesn’t do for Zig now?”

I am just someone interested in learning Zig, and Andy’s first question is already beyond my ability to respond.
If someone with a better understanding of the need for a stand alone compiler can provide in depth discussions with him, may well be a useful contribution towards Zig maturity.
Maybe you can forward to Andrew Kelly.

I apologize in advance if I have posted in the wrong location.

Dan

1 Like

As far as I know the reason to move away from LLVM is compilation speed, but I not 100% sure on this.

Yes, I recall hearing or reading somewhere that compilation speed was one important factor and also that there were instances where bugs in LLVM were negatively affecting Zig, and even after being reported, the LLVM folks were taking too long in fixing them.

Zig isn’t trying to replace LLVM, it’s adding additional backends that will focus on compilation speed instead of optimizing runtime speed. LLVM has a lot of smart people who have been developing it’s optimizer for many years. Zig has no plans to replace that work.

4 Likes

Update since this was written:

  • we are self-hosted now
  • the individual backends are still work in progress
  • a lot of things in the compiler are already setup for incremental compilation
2 Likes