Right now when you pass
--release to the compiler, it will produce a single LLVM file that is then optimized and compiled. The reason we do this is that, if LLVM has all the code right there, it will be able to inline and really optimize the final executable. And that’s indeed what happens! However, it takes a lot of time to do this.
Instead, we could still produce a lot of LLVM files (more or less one per each class/struct/file), tell LLVM to optimize those independently, and then produce an executable.
In my experiments, this leads to much faster compile times. For example compiling the compiler in release mode usually takes a bit more than 5 minutes, but with this new approach it takes a bit more than 1 minute. Compiling a “Hello world” program takes around 8 seconds (in release mode), and with the new approach it takes 3 seconds.
Do you think it would be worth to either:
- change the current
--releasemode so that it compiles faster, despite producing slower executables
- add a way to use this new
--releasemode that’s faster to compile but slower to run?
My thinking is that if you are going to distribute or deploy a program you want it to be as fast as possible, even if you have to wait a few minutes to get there. What do you think?