I notice there are two settings of optimization in the project settings :
- Single-File Optimization
- Whole Module Optimization
What's the difference? And which one should we choose under what circumstances?
I notice there are two settings of optimization in the project settings :
What's the difference? And which one should we choose under what circumstances?
This optimization mode has the compiler run one frontend instance per file in your program. It runs optimizations on each file separately, loading as little information as it can from other files in the project.
Pros
Cons
This optimization mode will run one frontend instance for your whole module. It runs optimizations on all the files at once.
Pros
Cons
For debug builds, I highly recommend completely disabling optimizations. This will make stepping through your code in the debugger more predictable and will make build times shorter. If you really need optimizations, you should probably go with single-file for the better incremental compilation times.
For release builds, I recommend using whole-module optimization, as it can perform more optimizations than single-file optimization.