diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/GeneralNativeIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/GeneralNativeIT.kt index 2712378620e..aada8761db4 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/GeneralNativeIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/GeneralNativeIT.kt @@ -14,45 +14,10 @@ class GeneralNativeIT : BaseGradleIT() { get() = GradleVersionRequired.FOR_MPP_SUPPORT @Test - fun testParallelExecutionDetection(): Unit = with(transformProjectWithPluginsDsl("native-parallel")) { - val compileTasks = arrayOf(":one:compileKotlinLinux", ":two:compileKotlinLinux") - // Check that parallel in-process execution fails with the corresponding message. - build(*compileTasks) { - assertFailed() - assertContains("Parallel in-process execution of the Kotlin/Native compiler detected.") - } - - // Parallel execution without daemon => ok. - build("clean", *compileTasks, "-Pkotlin.native.disableCompilerDaemon=true") { + fun testParallelExecutionSmoke(): Unit = with(transformProjectWithPluginsDsl("native-parallel")) { + // Check that the K/N compiler can be started in-process in parallel. + build(":one:compileKotlinLinux", ":two:compileKotlinLinux") { assertSuccessful() - assertTasksExecuted(*compileTasks) - } - - // org.gradle.parallel must be set in the properties file (not in command line). - projectDir.resolve("gradle.properties").modify { - it.replace("org.gradle.parallel=true", "org.gradle.parallel=false") - } - - // Sequential execution => ok. - build("clean", *compileTasks) { - assertSuccessful() - assertTasksExecuted(*compileTasks) - } - - // Check for KT-37696. - // Add an incorrect code to trigger compilation failure. - projectDir.resolve("one/src/linuxMain/kotlin/main.kt").appendText("\nfun incorrect") - gradleBuildScript("two").appendText(""" - - val compileKotlinLinux by tasks.getting - compileKotlinLinux.mustRunAfter(":one:compileKotlinLinux") - """.trimIndent()) - - build("clean", *compileTasks, "--continue") { - assertFailed() - assertTasksFailed(":one:compileKotlinLinux") - assertTasksExecuted(":two:compileKotlinLinux") - assertNotContains("Parallel in-process execution of the Kotlin/Native compiler detected.") } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/KotlinToolRunner.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/KotlinToolRunner.kt index e1c16e971cb..2458048535e 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/KotlinToolRunner.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/KotlinToolRunner.kt @@ -90,8 +90,7 @@ internal abstract class KotlinToolRunner( } } - // TODO: Make it private again once KT-37550 is fixed. - protected open fun runInProcess(args: List) { + private fun runInProcess(args: List) { try { val mainClass = getIsolatedClassLoader().loadClass(mainClass) val entryPoint = mainClass.methods.single { it.name == daemonEntryPoint } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/nativeToolRunners.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/nativeToolRunners.kt index 613a8bf70ce..c6f56b999bf 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/nativeToolRunners.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/nativeToolRunners.kt @@ -83,50 +83,6 @@ internal abstract class KotlinNativeToolRunner( override fun transformArgs(args: List) = listOf(toolName) + args final override fun getCustomJvmArgs() = project.jvmArgs - - final override fun runInProcess(args: List) { - withParallelExecutionGuard { - super.runInProcess(args) - } - } - - // TODO: Remove once KT-37550 is fixed - private inline fun withParallelExecutionGuard(action: () -> Unit) { - try { - if (PropertiesProvider(project).nativeEnableParallelExecutionCheck) { - System.getProperties().compute(PARALLEL_EXECUTION_GUARD_PROPERTY) { _, value -> - check(value == null) { PARALLEL_EXECUTION_ERROR_MESSAGE } - "true" - } - } - - action() - - } finally { - if (PropertiesProvider(project).nativeEnableParallelExecutionCheck) { - System.clearProperty(PARALLEL_EXECUTION_GUARD_PROPERTY) - } - } - } - - companion object { - private const val PARALLEL_EXECUTION_GUARD_PROPERTY = "org.jetbrains.kotlin.native.compiler.running" - - private val PARALLEL_EXECUTION_ERROR_MESSAGE = """ - Parallel in-process execution of the Kotlin/Native compiler detected. - - At this moment the parallel execution of several compiler instances in the same process is not supported. - To fix this, you can do one of the following things: - - - Disable in-process execution. To do this, set '${PropertiesProvider.KOTLIN_NATIVE_DISABLE_COMPILER_DAEMON}=true' project property. - - - Disable parallel task execution. To do this, set 'org.gradle.parallel=false' project property. - - If you still want to run the compiler in-process in parallel, you may disable this check by setting project - property '${PropertiesProvider.KOTLIN_NATIVE_ENABLE_PARALLEL_EXECUTION_CHECK}=false'. Note that in this case the compiler may fail. - - """.trimIndent() - } } /** A common ancestor for all runners that run the cinterop tool. */ diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinProperties.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinProperties.kt index 144174f41f3..918057a0512 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinProperties.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinProperties.kt @@ -170,11 +170,7 @@ internal class PropertiesProvider private constructor(private val project: Proje * Forces to run a compilation in a separate JVM. */ val nativeDisableCompilerDaemon: Boolean? - get() = booleanProperty(KOTLIN_NATIVE_DISABLE_COMPILER_DAEMON) - - // TODO: Remove once KT-37550 is fixed - val nativeEnableParallelExecutionCheck: Boolean - get() = booleanProperty(KOTLIN_NATIVE_ENABLE_PARALLEL_EXECUTION_CHECK) ?: true + get() = booleanProperty("kotlin.native.disableCompilerDaemon") /** * Allows a user to specify additional arguments of a JVM executing KLIB commonizer. @@ -229,12 +225,8 @@ internal class PropertiesProvider private constructor(private val project: Proje private const val CACHED_PROVIDER_EXT_NAME = "kotlin.properties.provider" - internal const val KOTLIN_NATIVE_DISABLE_COMPILER_DAEMON = "kotlin.native.disableCompilerDaemon" internal const val KOTLIN_NATIVE_IGNORE_INCORRECT_DEPENDENCIES = "kotlin.native.ignoreIncorrectDependencies" - // TODO: Remove once KT-37550 is fixed - internal const val KOTLIN_NATIVE_ENABLE_PARALLEL_EXECUTION_CHECK = "kotlin.native.enableParallelExecutionCheck" - operator fun invoke(project: Project): PropertiesProvider = with(project.extensions.extraProperties) { if (!has(CACHED_PROVIDER_EXT_NAME)) {