Kotlin 2.4.0 support#191
Closed
LionZXY wants to merge 8 commits into
Closed
Conversation
Register 2.4.0 (release) in versionSupport.kotlin and switch dev-support to it. SKIE keeps compiling with the 2.2.20 Kotlin compiler (which still supports experimental context receivers). That compiler reads klib metadata only one minor version ahead, so building against the 2.4.0 Kotlin/Native distribution needs -Xskip-metadata-version-check; it is added in BaseKotlinPlugin for every JVM module (main and test) when the primary Kotlin version is >= 2.4.0.
Kotlin 2.4.0 renamed several Kotlin/Native compiler types:
- KonanConfig -> NativeSecondStageCompilationConfig
- KonanConfigKeys -> NativeConfigurationKeys
- PhaseContext -> NativePhaseContext
The shared `main` source set now references SKIE-internal typealiases
(co.touchlab.skie.compat.{KonanConfig,KonanConfigKeys,PhaseContext}) defined
per version range (`..2.3.20` -> old names, `2.4.0..` -> new names). The
debugPrefixMapKey/phaseContextKonanConfig version helpers are bounded to
exactly 2.3.20 and reimplemented for 2.4.0+ against the new types.
Kotlin 2.4.0 removed the dedicated IR value-parameter/receiver/argument accessors (valueParameters, putValueArgument, putTypeArgument, extensionReceiver, extensionReceiverParameter) in favor of unified positional parameters/arguments lists, changed IrMutableAnnotationContainer.annotations to List<IrAnnotation>, and made the GeneratorContext primary constructor private (the public one gained a CompilerConfiguration parameter). The shared `main` source set now uses skie* shims and a skieCreateGeneratorContext helper, implemented per version range, plus a SkieIrAnnotation alias for the annotation element type.
…dulesSupport removal - CompilerConfiguration.report(severity, message, location) was removed; SKIE now reports through the MessageCollector (reportCompilerMessage shim). - The framework OUTPUT key was renamed to KONAN_OUTPUT_PATH (frameworkOutputPathConfigurationKey shim). - CompilerConfigurationKey is final; SkieConfigurationKeys holds key instances instead of subclassing it. - UserVisibleIrModulesSupport was removed with no replacement that maps resolved libraries to dependency coordinates. getExternalDependencies returns an empty set on 2.4.0, so all non-distribution libraries are treated as local and per-module analytics no longer distinguish external libraries. Default libraries are now detected via KotlinLibrary.isFromKotlinNativeDistribution.
# Conflicts: # common-gradle/gradle.properties # dev-support/build.gradle.kts
`generateCIActions` regenerates every versioned smoke-test workflow, which incidentally re-synced the stale smoke-tests-2_3_20-*.yml (its lockfile was shrunk in b88ae64 without regenerating the workflow). That change is unrelated to Kotlin 2.4.0 support, so restore those two files to match main and keep this PR scoped to 2.4.0.
LionZXY
commented
Jun 3, 2026
Comment on lines
+83
to
+95
| private fun Project.extraJvmCompilerArgs(): List<String> = buildList { | ||
| add("-Xjdk-release=${libs.versions.jvmTarget}") | ||
|
|
||
| // The project is compiled with the Kotlin compiler pinned in the version catalog (see `kotlin`), which can only | ||
| // read klib metadata up to one minor version ahead. Compiling against a newer Kotlin distribution (2.4.0+, used | ||
| // by the kotlin-native-compiler-embeddable on the main/test classpath) therefore needs the metadata version | ||
| // check relaxed. | ||
| val primaryCompilerVersion = SupportedKotlinVersionProvider.getPrimaryKotlinVersion(this@extraJvmCompilerArgs).compilerVersion | ||
| if (primaryCompilerVersion >= KotlinToolingVersion("2.4.0")) { | ||
| add("-Xskip-metadata-version-check") | ||
| } | ||
| } | ||
|
|
Author
There was a problem hiding this comment.
Unfortunately, this is necessary to avoid upgrading Kotlin to 2.3.* as part of this PR.
The main obstacle to this is: #190
Author
|
What about this:
Fortunately, SKIE uses a Gradle plugin, so it can pass this information. I don’t really like this approach, so I didn’t include it in the main PR. There’s a separate PR for this here: LionZXY#4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds Kotlin 2.4.0 (release) to the supported versions
Compiler-internal API changes
Isolated in the
..2.3.20/2.4.0..version source sets; the sharedmainsource set stays version-agnostic
KonanConfig→NativeSecondStageCompilationConfig,KonanConfigKeys→NativeConfigurationKeys,PhaseContext→NativePhaseContext.valueParameters/putValueArgument/putTypeArgument/extensionReceiver(Parameter)→skie*shims over the new positionalparameters/argumentslists;IrMutableAnnotationContainer.annotationselement type →
IrAnnotation;GeneratorContextconstructor change.CompilerConfiguration.report→MessageCollector,OUTPUTkey →KONAN_OUTPUT_PATH, non-subclassableCompilerConfigurationKey.UserVisibleIrModulesSupportwas removed in 2.4.0 with no replacement that mapsresolved libraries back to dependency coordinates. On 2.4.0, external
dependencies are no longer reported — all non-distribution libraries are treated
as local, and per-module analytics no longer distinguish external libraries.
Validation
macos_arm64).expected-failuresfor 2.4.0 are seeded from 2.3.20 — to be finalized from theCI external-library runs.
cc: #187