r/ProgrammingLanguages • u/Key_River7180 Nain. • 20d ago
Help transpilation - Bootstrap compiler
So, I am making a compiler for my language, Nain, in CHICKEN Scheme. Should I output QBE IR or code for C or another language? This is a bootstrap compiler, I will use it only to test new language features and to compile the self hosting compiler so yeah.
1
Upvotes
View all comments
Show parent comment
2
u/AustinVelonaut Admiran 20d ago
Most self-hosting compilers are "continuously bootstrapped", meaning you add new features / capabilities to the existing compiler sources, compile with the existing compiler, and get a new compiler that understands the new features/capabilities. So you don't have to do everything in one step from original bootstrap compiler to final self-hosted compiler -- you can do the process in stages.
So it doesn't matter what the original bootstrap Nain compiler (written in Scheme) generates, as long as you have a path from that to an executable binary. Then rewrite the compiler in Nain that produces LLVM, run that through your bootstrap compiler, and get the Nain->LLVM compiler. Or you can do an intermediate stage, where you write a Nain -> C compiler written in Nain, then change the backend out to LLVM, run that through, and get a Nain -> LLVM compiler.