Upgrading Meta's Kotlin Infrastructure to K2
summary
Meta upgrades Kotlin front end to K2 across a heavy Buck-based Android toolchain, migrating 95% of models and achieving 20% faster builds on average. Migration requires rewriting compiler plugins to use FIR extensions, adding FIR transformers and declaration generators to modify in-memory IR, and switching KSP to a standalone KSP2 invocation. Challenges include a 20 million line Kotlin codebase, stricter type checks that expose latent bugs, and custom casabi source-only symbol generation.
AI-written summary · about
chapters (8)
- 0:00Kotlin K2 migration intro
- 1:51Why Meta started K2
- 6:06K2 migration challenges
- 9:47K2 compiler front end
- 12:21K2 compiler plugins
- 17:26Build speed with K2
- 23:38KSP and K2 at Meta
- 25:08K2 adoption results
related talks
35mK2 compiler in production
42mKotlin Adoption in the Giant Java Application
35mAt long last we have Kotlin first at Meta!
33mMeta-programming with KSP and Kotlin compiler plugins
38mHow Kotlin 2.0 Will Evolve Android Development
43mCompile Kotlin faster with ABI
23mKotlin
44mMeta-programming with KSP and Kotlin compiler plugins
