:wave: I've been testing some of the new incremen...
# compiler
z
👋 I've been testing some of the new incremental common compilation props and found a bug in 2.4.20 that's fixed (I think incidentally) in 2.5.0-Beta1 I think that's from one or both of these - github.com/JetBrains/kotlin/commit/… (hash source file paths for JVM metadata fragment names) - github.com/JetBrains/kotlin/commit/… (drop the disk-based common metadata KLIB writing) Would it be worth filing a FR to backport those to 2.4.21? Creating the parent directory in writeTo might be enough there, but y'all would know better
Context: Metro's contribution hints are FIR-generated top-level declarations, so under KT-75864 every contributing file is always dirty. In KMP projects with contributions in commonMain, that makes every JVM incremental build a full rebuild (KT-62686), even for jvmMain-only edits. On 2.5.0-Beta1 the common-sources flag fixes that for us, and a backport would let 2.4.x users opt in a bit earlier
The crash I ran into trying it
Copy code
e: java.nio.file.NoSuchFileException: .../build/kotlin/compileKotlinJvm/cacheable/metadata-jvm/commonMain/default/linkdata/package_metro.hints/metro/hints/testCommonValueDev_zacsweers_metro_AppScope.kt.knm
      at org.jetbrains.kotlin.cli.pipeline.jvm.metadata.JvmMetadataComponentWriter.writeTo(JvmMetadataComponentWriter.kt:38)
The synthetic file's name includes its package path (metro/hints/...kt) and
JvmMetadataComponentWriter
only creates the package fragment directory, so the nested parent directory doesn't exist
p
What's your exact setup? As far I remember IC shouldn't be enabled in multiplatform projects at all in 2.4.20, unless you opt-in with some very scary flag.
true 1
Or, that's exactly the problem, as it not enabled, but tries to do something and it crashes?
z
I am trying the scary flags yes 🙂
i
Hi, thank you for the report! Could you please share the flags you used for 2.4.20 and 2.5.0-Beta1?
z
will circle back with them!
👌 1
the flags in 2.4.20
Copy code
kotlin.internal.incremental.enableUnsafeOptimizationsForMultiplatform=true
kotlin.internal.jvm.enableKmpClasspathMetadataForIncrementalCompilation=true
For 2.5.0-Beta1 I used
Copy code
kotlin.jvm.enableIncrementalCompilationOfCommonSources=true
The 2.4.20 configuration triggers the metadata-writing crash with Metro contributions in
commonMain
. With 2.5.0-Beta1, JVM builds stay incremental when editing only
jvmMain
I subsequently also tested
kotlin.kmp.separateCompilation=true
, including alongside the common-sources IC flag. That testing is captured in here, where I reported a separate single-target producer metadata issue. The JS/Wasm deletion crash also reproduces with separate compilation disabled
i
Thanks for providing the flags, that gives me the full picture. To answer your question, we don’t plan to backport this functionality to 2.4.21. The 2.4.20 implementation was a prototype that used a different mechanism from 2.5.0: in 2.4.20, we generated knm output per file, while 2.5.0 uses only the IC cache. Given that difference, I don’t think it’s worth spending time testing the metadata behavior in versions before 2.5.0. The change is intended to enable incremental compilation within a module when you edit a file in that module’s
commonMain
source set. Could you clarify what you meant by “With 2.5.0-Beta1, JVM builds stay incremental when editing only `jvmMain`”? Builds should already be incremental when you edit
jvmMain
, by default. Separate compilation should help in multi-module scenarios.
👍 1