Improving Swift Debug Build Times
It’s well known that enabling Whole Module Optimization greatly reduces Swift build times, but did you know it’s possible to do this for debug builds without breaking the debugger? I didn’t.
Normally, one sets
-Onone for development builds. Otherwise, the debugger will behave in ways that are expected but not helpful.
I wanted the build-time gains that come from enabling Whole Module Optimization without breaking the debugger. After some trial/error, I tried setting
YES and, to my surprise, it worked. And the debugger still worked in my testing.
This reduced debug build times by approximately 30% on a project I contribute to.
You might be run into an interesting compiler segmentation fault after enabling
SWIFT_WHOLE_MODULE_OPTIMIZATION. If you do, check the build log for a stack trace that mentions SIL optimization
Continue reading →