Meta's engineering team successfully integrated Kotlin incremental compilation into Buck2, their build system, achieving up to 3x faster build times for critical modules. The implementation involved using Kotlin's Build Tools API, configuring incremental actions to preserve previous outputs, making compiler caches relocatable for distributed builds, and adapting custom compiler plugins to work with incremental compilation. The team overcame challenges with shaded vs unshaded compiler dependencies, handled multiple compilation rounds, and maintained compatibility with annotation processors. A/B testing showed 30% improvement in average build times, with nearly doubled speed for modules without annotation processing.
Table of contents
Step 1: Integrating Kotlin’s Build Tools APIStep 2: Keeping previous output around for the incremental compilerStep 3: Making the incremental compiler cache relocatableStep 4: Configuring the incremental compilerStep 5: Making compiler plugins work with the incremental compilerStep 6: Verifying the functionality of annotation processorsStep 7: Enabling compilation against ABIStep 8: TestingThe impact of incremental compilationWhat’s nextSort: