Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -350,27 +350,27 @@ class FusStatisticsIT : KGPBaseTest() {
"compileKotlinJvm", "-Pkotlin.session.logger.root.path=$projectPath",
buildOptions = defaultBuildOptions.copy(
jvmClasspathMetadata = true,
enableJvmUnsafeIncrementalCompilationForMultiplatform = true,
enableJvmIncrementalCompilationOfCommonSources = true,
),
) {
assertOutputDoesNotContainFusErrors()
fusStatisticsDirectory.assertFusReportContains(
"KMP_JVM_CLASSPATH_METADATA_ENABLED=true",
"KMP_JVM_UNSAFE_OPTIMIZATIONS_ENABLED=true",
"KMP_JVM_INCREMENTAL_COMPILATION_OF_COMMON_SOURCES_ENABLED=true",
)
}

build(
"clean", "compileKotlinJvm", "-Pkotlin.session.logger.root.path=$projectPath",
buildOptions = defaultBuildOptions.copy(
jvmClasspathMetadata = false,
enableJvmUnsafeIncrementalCompilationForMultiplatform = false,
enableJvmIncrementalCompilationOfCommonSources = false,
),
) {
assertOutputDoesNotContainFusErrors()
fusStatisticsDirectory.assertFusReportContains(
"KMP_JVM_CLASSPATH_METADATA_ENABLED=false",
"KMP_JVM_UNSAFE_OPTIMIZATIONS_ENABLED=false",
"KMP_JVM_INCREMENTAL_COMPILATION_OF_COMMON_SOURCES_ENABLED=false",
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ abstract class CommonCodeWithPlatformSymbolsITBase(
private fun BuildOptions.withUnsafeOptimizationsForMultiplatform(enabled: Boolean): BuildOptions = when (platformType) {
KotlinPlatformType.js -> copy(enableJsUnsafeIncrementalCompilationForMultiplatform = enabled)
KotlinPlatformType.wasm -> copy(enableWasmUnsafeIncrementalCompilationForMultiplatform = enabled)
else -> copy(enableJvmUnsafeIncrementalCompilationForMultiplatform = enabled)
else -> copy(enableJvmIncrementalCompilationOfCommonSources = enabled)
}

private val platformSourceSet = "${platformType.name}Main"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class JvmClasspathMetadataIncrementalIT : KGPBaseTest() {
get() = super.defaultBuildOptions.copy(
logLevel = LogLevel.DEBUG,
languageVersion = "2.0",
enableJvmUnsafeIncrementalCompilationForMultiplatform = true,
enableJvmIncrementalCompilationOfCommonSources = true,
)

@GradleTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class KmpIncrementalCompilationWithLocalClassesIT : KGPBaseTest() {

override val defaultBuildOptions: BuildOptions
get() = super.defaultBuildOptions.copy(
enableJvmUnsafeIncrementalCompilationForMultiplatform = true,
enableJvmIncrementalCompilationOfCommonSources = true,
enableJsUnsafeIncrementalCompilationForMultiplatform = true,
enableWasmUnsafeIncrementalCompilationForMultiplatform = true,
).disableIsolatedProjectsBecauseOfJsAndWasmKT75899()
Expand Down Expand Up @@ -168,7 +168,7 @@ class KmpIncrementalCompilationSetExpansionIT : KGPBaseTest() {
override val defaultBuildOptions: BuildOptions
get() = super.defaultBuildOptions.copy(
// it's more convenient to set up the test project using common sourceset
enableJvmUnsafeIncrementalCompilationForMultiplatform = true,
enableJvmIncrementalCompilationOfCommonSources = true,
enableJsUnsafeIncrementalCompilationForMultiplatform = true,
enableWasmUnsafeIncrementalCompilationForMultiplatform = true,
).disableIsolatedProjectsBecauseOfJsAndWasmKT75899()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ abstract class KmpIncrementalITBase : KGPBaseTest() {
/**
* disable IC-breaking feature; it's tested separately in [org.jetbrains.kotlin.gradle.mpp.CommonCodeWithPlatformSymbolsITBase]
*/
enableJvmUnsafeIncrementalCompilationForMultiplatform = true,
enableJvmIncrementalCompilationOfCommonSources = true,
enableJsUnsafeIncrementalCompilationForMultiplatform = true,
enableWasmUnsafeIncrementalCompilationForMultiplatform = true,
).disableIsolatedProjectsBecauseOfJsAndWasmKT75899()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class PerTargetUnsafeOptimizationsIT : KGPBaseTest() {
"kt-62686-mpp-source-set-boundary",
gradleVersion,
buildOptions = defaultBuildOptions.copy(
enableJvmUnsafeIncrementalCompilationForMultiplatform = true,
enableJvmIncrementalCompilationOfCommonSources = true,
enableJsUnsafeIncrementalCompilationForMultiplatform = false,
)
) {
Expand All @@ -68,7 +68,7 @@ class PerTargetUnsafeOptimizationsIT : KGPBaseTest() {
"kt-62686-mpp-source-set-boundary",
gradleVersion,
buildOptions = defaultBuildOptions.copy(
enableJvmUnsafeIncrementalCompilationForMultiplatform = false,
enableJvmIncrementalCompilationOfCommonSources = false,
enableJsUnsafeIncrementalCompilationForMultiplatform = true,
)
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ abstract class AbstractExpectActualIncrementalCompilationIT : KGPBaseTest() {
override val defaultBuildOptions: BuildOptions
get() = super.defaultBuildOptions.copyEnsuringK2().copy(
// disable IC-breaking feature; it's tested separately in [org.jetbrains.kotlin.gradle.mpp.CommonCodeWithPlatformSymbolsITBase]
enableJvmUnsafeIncrementalCompilationForMultiplatform = true,
enableJvmIncrementalCompilationOfCommonSources = true,
enableJsUnsafeIncrementalCompilationForMultiplatform = true,
enableWasmUnsafeIncrementalCompilationForMultiplatform = true,
logLevel = LogLevel.DEBUG,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ data class BuildOptions(
val languageApiVersion: String? = null,
val freeArgs: List<String> = emptyList(),
val statisticsForceValidation: Boolean = true,
val enableJvmUnsafeIncrementalCompilationForMultiplatform: Boolean? = null,
val enableJvmIncrementalCompilationOfCommonSources: Boolean? = null,
val enableJsUnsafeIncrementalCompilationForMultiplatform: Boolean? = null,
val enableWasmUnsafeIncrementalCompilationForMultiplatform: Boolean? = null,
val enableMonotonousIncrementalCompileSetExpansion: Boolean? = null,
Expand Down Expand Up @@ -311,8 +311,8 @@ data class BuildOptions(
arguments.add("-Pkotlin.test.languageVersion=$languageVersion")
}

if (enableJvmUnsafeIncrementalCompilationForMultiplatform != null) {
arguments.add("-Pkotlin.internal.jvm.enableUnsafeOptimizationsForMultiplatform=$enableJvmUnsafeIncrementalCompilationForMultiplatform")
if (enableJvmIncrementalCompilationOfCommonSources != null) {
arguments.add("-Pkotlin.jvm.enableIncrementalCompilationOfCommonSources=$enableJvmIncrementalCompilationOfCommonSources")
}

if (enableJsUnsafeIncrementalCompilationForMultiplatform != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -616,17 +616,22 @@ internal class PropertiesProvider private constructor(private val project: Proje
.orElse(KotlinCompilerArgumentsLogLevel.DEFAULT)

/**
* Without unsafe optimization: in k2, if common source is dirty, module will be rebuilt.
* With unsafe optimization: regular IC logic is used. Common sources might see declarations from platform sources. See KT-62686
* When disabled: in k2, if a common source is dirty, the whole module is rebuilt.
* When enabled: common sources are compiled incrementally, and [enableJvmClasspathMetadata] keeps them from seeing
* platform declarations. See KT-86703.
*/
val enableJvmUnsafeOptimizationsForMultiplatform: Provider<Boolean>
get() = booleanProvider(PropertyNames.KOTLIN_JVM_UNSAFE_MULTIPLATFORM_INCREMENTAL_COMPILATION).orElse(false)
val enableJvmIncrementalCompilationOfCommonSources: Provider<Boolean>
get() = booleanProvider(PropertyNames.KOTLIN_JVM_INCREMENTAL_COMPILATION_OF_COMMON_SOURCES).orElse(false)

/** See [enableJvmUnsafeOptimizationsForMultiplatform] */
/**
* When disabled: in k2, if a common source is dirty, the whole module is rebuilt.
* When enabled: regular IC logic is used, and common sources might see platform declarations. There is no
* counterpart of [enableJvmClasspathMetadata] to prevent this. See KT-62686.
*/
val enableJsUnsafeOptimizationsForMultiplatform: Provider<Boolean>
get() = booleanProvider(PropertyNames.KOTLIN_JS_UNSAFE_MULTIPLATFORM_INCREMENTAL_COMPILATION).orElse(false)

/** See [enableJvmUnsafeOptimizationsForMultiplatform] */
/** See [enableJsUnsafeOptimizationsForMultiplatform] */
val enableWasmUnsafeOptimizationsForMultiplatform: Provider<Boolean>
get() = booleanProvider(PropertyNames.KOTLIN_WASM_UNSAFE_MULTIPLATFORM_INCREMENTAL_COMPILATION).orElse(false)

Expand Down Expand Up @@ -880,6 +885,8 @@ internal class PropertiesProvider private constructor(private val project: Proje
val KOTLIN_KMP_ALLOW_MATCHING_BY_REQUESTED_COORDINATES_IN_GMDT =
property("${KOTLIN_INTERNAL_NAMESPACE}.kmp.allowMatchingByRequestedCoordinatesInMetadataTransformations")
val KOTLIN_INCREMENTAL_FIR = property("kotlin.incremental.jvm.fir")
val KOTLIN_JVM_INCREMENTAL_COMPILATION_OF_COMMON_SOURCES =
property("kotlin.jvm.enableIncrementalCompilationOfCommonSources")
val KOTLIN_KMP_UNRESOLVED_DEPENDENCIES_DIAGNOSTIC = property("kotlin.kmp.unresolvedDependenciesDiagnostic")
val KOTLIN_KMP_EAGER_UNRESOLVED_DEPENDENCIES_DIAGNOSTIC = property("kotlin.kmp.eagerUnresolvedDependenciesDiagnostic")
val KOTLIN_DISPLAY_DIAGNOSTICS_IN_IDE_BUILD_LOG = property("kotlin.displayDiagnosticsInIdeBuildLog")
Expand Down Expand Up @@ -907,13 +914,11 @@ internal class PropertiesProvider private constructor(private val project: Proje
val KOTLIN_COMPILER_ARGUMENTS_LOG_LEVEL = property("$KOTLIN_INTERNAL_NAMESPACE.compiler.arguments.log.level")

/**
* Replaced by the per-target properties below, kept only to report
* Replaced by the per-target properties, kept only to report
* [org.jetbrains.kotlin.gradle.plugin.diagnostics.KotlinToolingDiagnostics.DeprecatedErrorGradleProperties] on its usage.
*/
val KOTLIN_UNSAFE_MULTIPLATFORM_INCREMENTAL_COMPILATION =
property("$KOTLIN_INTERNAL_NAMESPACE.incremental.enableUnsafeOptimizationsForMultiplatform")
val KOTLIN_JVM_UNSAFE_MULTIPLATFORM_INCREMENTAL_COMPILATION =
property("$KOTLIN_INTERNAL_NAMESPACE.jvm.enableUnsafeOptimizationsForMultiplatform")
val KOTLIN_JS_UNSAFE_MULTIPLATFORM_INCREMENTAL_COMPILATION =
property("$KOTLIN_INTERNAL_NAMESPACE.js.enableUnsafeOptimizationsForMultiplatform")
val KOTLIN_WASM_UNSAFE_MULTIPLATFORM_INCREMENTAL_COMPILATION =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import org.jetbrains.kotlin.gradle.internal.properties.PropertiesBuildService
import org.jetbrains.kotlin.gradle.plugin.KotlinPluginLifecycle
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_DEPRECATED_TEST_PROPERTY
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_JS_UNSAFE_MULTIPLATFORM_INCREMENTAL_COMPILATION
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_JVM_UNSAFE_MULTIPLATFORM_INCREMENTAL_COMPILATION
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_JVM_INCREMENTAL_COMPILATION_OF_COMMON_SOURCES
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_MPP_ENABLE_PLATFORM_INTEGER_COMMONIZATION
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_MPP_ENABLE_OPTIMISTIC_NUMBER_COMMONIZATION
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_PUBLISH_JVM_ENVIRONMENT_ATTRIBUTE
Expand Down Expand Up @@ -138,7 +138,7 @@ internal object GradleDeprecatedPropertyChecker : KotlinGradleProjectChecker {
DeprecatedProperty(
propertyName = KOTLIN_UNSAFE_MULTIPLATFORM_INCREMENTAL_COMPILATION,
details = "This property has no effect. Unsafe incremental compilation optimizations are now enabled per target: use " +
"$KOTLIN_JVM_UNSAFE_MULTIPLATFORM_INCREMENTAL_COMPILATION, " +
"$KOTLIN_JVM_INCREMENTAL_COMPILATION_OF_COMMON_SOURCES, " +
"$KOTLIN_JS_UNSAFE_MULTIPLATFORM_INCREMENTAL_COMPILATION or " +
"$KOTLIN_WASM_UNSAFE_MULTIPLATFORM_INCREMENTAL_COMPILATION instead. " +
"See https://kotl.in/KT-87522 for details.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ internal object CompileKotlinTaskMetrics : FusMetrics {
executionPolicy: KotlinCompilerExecutionStrategy,
// both are null for anything that is not a multiplatform Kotlin/JVM compilation
kmpJvmClasspathMetadataEnabled: Boolean?,
kmpJvmUnsafeOptimizationsEnabled: Boolean?,
kmpJvmIncrementalCompilationOfCommonSourcesEnabled: Boolean?,
metricsContainer: StatisticsValuesConsumer,
) {
metricsContainer.report(BooleanMetrics.KOTLIN_PROGRESSIVE_MODE, compilerOptions.progressiveMode.get())
Expand All @@ -303,8 +303,8 @@ internal object CompileKotlinTaskMetrics : FusMetrics {
kmpJvmClasspathMetadataEnabled?.also {
metricsContainer.report(BooleanMetrics.KMP_JVM_CLASSPATH_METADATA_ENABLED, it)
}
kmpJvmUnsafeOptimizationsEnabled?.also {
metricsContainer.report(BooleanMetrics.KMP_JVM_UNSAFE_OPTIMIZATIONS_ENABLED, it)
kmpJvmIncrementalCompilationOfCommonSourcesEnabled?.also {
metricsContainer.report(BooleanMetrics.KMP_JVM_INCREMENTAL_COMPILATION_OF_COMMON_SOURCES_ENABLED, it)
}
metricsContainer.report(StringListMetrics.KOTLIN_COMPILER_EXECUTION_POLICY, executionPolicy.propertyValue)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments> @Inject constr
firRunnerEnabled = (this as? KotlinCompile)?.useFirRunner?.get() == true,
executionPolicy = compilerExecutionStrategy.get(),
kmpJvmClasspathMetadataEnabled = kmpJvmCompile?.enableJvmClasspathMetadata?.get(),
kmpJvmUnsafeOptimizationsEnabled = kmpJvmCompile?.enableUnsafeIncrementalCompilationForMultiplatform?.get(),
kmpJvmIncrementalCompilationOfCommonSourcesEnabled = kmpJvmCompile?.enableUnsafeIncrementalCompilationForMultiplatform?.get(),
it
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ internal open class BaseKotlinCompileConfig<TASK : KotlinCompile> : AbstractKotl
task.useFirRunner.convention(propertiesProvider.incrementalJvmFir)
task.enableJvmClasspathMetadata.convention(propertiesProvider.enableJvmClasspathMetadata)
task.enableUnsafeIncrementalCompilationForMultiplatform
.convention(propertiesProvider.enableJvmUnsafeOptimizationsForMultiplatform)
.convention(propertiesProvider.enableJvmIncrementalCompilationOfCommonSources)
.finalizeValueOnRead()
task.usePreciseJavaTracking = propertiesProvider.usePreciseJavaTracking ?: true
task.jvmTargetValidationMode.convention(propertiesProvider.jvmTargetValidationMode).finalizeValueOnRead()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class UnsafeOptimizationsForMultiplatformTest {
@Test
fun jvmPropertyAffectsOnlyJvmTasks() {
assertEnabledTargets(
enabledProperty = "kotlin.internal.jvm.enableUnsafeOptimizationsForMultiplatform",
enabledProperty = "kotlin.jvm.enableIncrementalCompilationOfCommonSources",
expectedJvm = true, expectedJs = false, expectedWasm = false,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ enum class BooleanMetrics(val type: BooleanOverridePolicy, val anonymization: Bo
KOTLIN_SEPARATE_KMP_COMPILATION_ENABLED(OR, SAFE),
// kotlin.internal.jvm.enableKmpClasspathMetadataForIncrementalCompilation, reported per KMP JVM compilation
KMP_JVM_CLASSPATH_METADATA_ENABLED(OR, SAFE),
// kotlin.internal.jvm.enableUnsafeOptimizationsForMultiplatform, reported per KMP JVM compilation
KMP_JVM_UNSAFE_OPTIMIZATIONS_ENABLED(OR, SAFE),
// kotlin.jvm.enableIncrementalCompilationOfCommonSources, reported per KMP JVM compilation
KMP_JVM_INCREMENTAL_COMPILATION_OF_COMMON_SOURCES_ENABLED(OR, SAFE),
KMP_TOP_LEVEL_DEPENDENCIES_BLOCK(OR, SAFE),
KOTLIN_NATIVE_CACHE_DISABLED(OR, SAFE),
KMP_SWIFT_PM_IMPORT_HAS_DIRECT_DEPENDENCIES(OR, SAFE),
Expand Down Expand Up @@ -146,6 +146,6 @@ enum class BooleanMetrics(val type: BooleanOverridePolicy, val anonymization: Bo
;

companion object {
const val VERSION = 30
const val VERSION = 31
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private const val NUMERICAL_METRICS_RELATIVE_PATH = "$SOURCE_CODE_RELATIVE_PATH/
private const val STRING_LIST_METRICS_RELATIVE_PATH = "$SOURCE_CODE_RELATIVE_PATH/StringListMetrics.kt"

private val STRING_METRICS_EXPECTED_VERSION_AND_HASH = Pair(13, "f6d1d30105cafe24bdc33325c8465095")
private val BOOLEAN_METRICS_EXPECTED_VERSION_AND_HASH = Pair(30, "622ddbc4b5c073ea379e7430d1ee3419")
private val BOOLEAN_METRICS_EXPECTED_VERSION_AND_HASH = Pair(31, "c21c6206e1ae0d7217abf0925043d010")
private val NUMERICAL_METRICS_EXPECTED_VERSION_AND_HASH = Pair(3, "bcc6f0dba7d9db8e58408f8c0ff57965")
private val STRING_LIST_METRICS_EXPECTED_VERSION_AND_HASH = Pair(4, "bab8ebe7d6a6b21b210468ab1193cb1c")
private val SOURCE_FOLDER_EXPECTED_VERSION_AND_HASH =
Expand Down