From 1b4ee63f305f82e8ae8c800ae618154accd16a53 Mon Sep 17 00:00:00 2001 From: Elena Lepilkina Date: Thu, 28 Oct 2021 15:39:23 +0300 Subject: [PATCH] [K/N] Deprecate and remove from supported list relaxed memory model --- .../cli.bc/src/org/jetbrains/kotlin/cli/bc/K2Native.kt | 5 +---- .../jetbrains/kotlin/cli/bc/K2NativeCompilerArguments.kt | 2 +- .../src/org/jetbrains/kotlin/backend/konan/KonanConfig.kt | 7 ++++++- .../main/kotlin/org/jetbrains/kotlin/KotlinNativeTest.kt | 6 +----- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/kotlin-native/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2Native.kt b/kotlin-native/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2Native.kt index 1702a5c5355..a99259a0057 100644 --- a/kotlin-native/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2Native.kt +++ b/kotlin-native/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2Native.kt @@ -233,10 +233,7 @@ class K2Native : CLICompiler() { put(ENABLE_ASSERTIONS, arguments.enableAssertions) val memoryModelFromArgument = when (arguments.memoryModel) { - "relaxed" -> { - configuration.report(STRONG_WARNING, "Relaxed memory model is not yet fully functional") - MemoryModel.RELAXED - } + "relaxed" -> MemoryModel.RELAXED "strict" -> MemoryModel.STRICT "experimental" -> MemoryModel.EXPERIMENTAL else -> { diff --git a/kotlin-native/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2NativeCompilerArguments.kt b/kotlin-native/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2NativeCompilerArguments.kt index d5e865de967..b5bb59fa685 100644 --- a/kotlin-native/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2NativeCompilerArguments.kt +++ b/kotlin-native/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2NativeCompilerArguments.kt @@ -47,7 +47,7 @@ class K2NativeCompilerArguments : CommonCompilerArguments() { @Argument(value = "-manifest", valueDescription = "", description = "Provide a maniferst addend file") var manifestFile: String? = null - @Argument(value="-memory-model", valueDescription = "", description = "Memory model to use, 'strict', 'relaxed' and 'experimental' are currently supported") + @Argument(value="-memory-model", valueDescription = "", description = "Memory model to use, 'strict' and 'experimental' are currently supported") var memoryModel: String? = "strict" @Argument(value="-module-name", deprecatedName = "-module_name", valueDescription = "", description = "Specify a name for the compilation module") diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanConfig.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanConfig.kt index 5b5dbf17be7..3b5edd0ee18 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanConfig.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanConfig.kt @@ -59,7 +59,12 @@ class KonanConfig(val project: Project, val configuration: CompilerConfiguration val memoryModel: MemoryModel by lazy { when (configuration.get(BinaryOptions.memoryModel)!!) { MemoryModel.STRICT -> MemoryModel.STRICT - MemoryModel.RELAXED -> MemoryModel.RELAXED + MemoryModel.RELAXED -> { + configuration.report(CompilerMessageSeverity.ERROR, + "Relaxed memory model is deprecated and isn't expected to work right way with current Kotlin version." + + " Use strict as default. ") + MemoryModel.STRICT + } MemoryModel.EXPERIMENTAL -> { if (!target.supportsThreads()) { configuration.report(CompilerMessageSeverity.STRONG_WARNING, diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/KotlinNativeTest.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/KotlinNativeTest.kt index b76571c2f59..e51f1c63a85 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/KotlinNativeTest.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/KotlinNativeTest.kt @@ -314,11 +314,7 @@ open class KonanLocalTest : KonanTest() { // TODO: as for now it captures output only in the driver task. // It should capture output from the build task using Gradle's LoggerManager and LoggerOutput val compilationLog = project.file("$executable.compilation.log").readText() - // TODO: ugly hack to fix irrelevant warnings. - val filteredCompilationLog = compilationLog.split('\n').filter { - it != "warning: relaxed memory model is not yet fully functional" - }.joinToString(separator = "\n") - output.stdOut = filteredCompilationLog + output.stdOut + output.stdOut = compilationLog + output.stdOut } output.check() output.print()