[K/N] Issue deprecation warning when using legacy MM
Merge-request: KT-MR-9091 Merged-by: Alexander Shabalin <Alexander.Shabalin@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
5bd0a1a0ba
commit
e6297f92fa
+8
-5
@@ -82,22 +82,25 @@ class KonanConfig(val project: Project, val configuration: CompilerConfiguration
|
||||
|
||||
val memoryModel: MemoryModel by lazy {
|
||||
when (configuration.get(BinaryOptions.memoryModel)) {
|
||||
MemoryModel.STRICT -> MemoryModel.STRICT
|
||||
MemoryModel.STRICT -> {
|
||||
configuration.report(CompilerMessageSeverity.STRONG_WARNING, "Legacy MM is deprecated and will be removed in version 1.9.20")
|
||||
MemoryModel.STRICT
|
||||
}
|
||||
MemoryModel.RELAXED -> {
|
||||
configuration.report(CompilerMessageSeverity.ERROR,
|
||||
"Relaxed MM is deprecated and isn't expected to work right way with current Kotlin version. Using legacy MM.")
|
||||
"Relaxed MM is deprecated and isn't expected to work right way with current Kotlin version.")
|
||||
MemoryModel.STRICT
|
||||
}
|
||||
MemoryModel.EXPERIMENTAL -> {
|
||||
if (!target.supportsThreads()) {
|
||||
configuration.report(CompilerMessageSeverity.STRONG_WARNING,
|
||||
"New MM requires threads, which are not supported on target ${target.name}. Using legacy MM.")
|
||||
"New MM requires threads, which are not supported on a deprecated target ${target.name}. Using deprecated legacy MM.")
|
||||
MemoryModel.STRICT
|
||||
} else {
|
||||
MemoryModel.EXPERIMENTAL
|
||||
}
|
||||
}
|
||||
null -> defaultMemoryModel
|
||||
null -> defaultMemoryModel // If target does not support threads, it's deprecated, no need to spam with our own deprecation message.
|
||||
}.also {
|
||||
if (it == MemoryModel.EXPERIMENTAL && destroyRuntimeMode == DestroyRuntimeMode.LEGACY) {
|
||||
configuration.report(CompilerMessageSeverity.ERROR,
|
||||
@@ -544,4 +547,4 @@ private fun String.isRelease(): Boolean {
|
||||
?: throw IllegalStateException("Cannot parse Kotlin/Native version: $this")
|
||||
|
||||
return metaString.isEmpty() && build.isEmpty()
|
||||
}
|
||||
}
|
||||
|
||||
+7
-2
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.LibraryCompil
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationArtifact
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationResult
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.compilation.TestCompilationResult.Companion.assertSuccess
|
||||
import org.jetbrains.kotlin.konan.blackboxtest.support.settings.MemoryModel
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.io.File
|
||||
@@ -88,10 +89,14 @@ class CompilerOutputTest : AbstractNativeSimpleTest() {
|
||||
}
|
||||
|
||||
private fun normalizeOutput(output: String, exitCode: ExitCode): String {
|
||||
return AbstractCliTest.getNormalizedCompilerOutput(
|
||||
var normalizedOutput = AbstractCliTest.getNormalizedCompilerOutput(
|
||||
output,
|
||||
exitCode,
|
||||
"compiler/testData/compileKotlinAgainstCustomBinaries/"
|
||||
)
|
||||
if (testRunSettings.get<MemoryModel>() != MemoryModel.EXPERIMENTAL) {
|
||||
normalizedOutput = normalizedOutput.replace("warning: legacy MM is deprecated and will be removed in version 1.9.20\n", "")
|
||||
}
|
||||
return normalizedOutput
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-1
@@ -72,7 +72,8 @@ internal class NativeTestGroupingMessageCollector(
|
||||
|| isUnsafeCompilerArgumentsWarning(message)
|
||||
|| isLibraryIncludedMoreThanOnceWarning(message)
|
||||
|| isK2Experimental(message)
|
||||
|| isPartialLinkageWarning(message) -> {
|
||||
|| isPartialLinkageWarning(message)
|
||||
|| isLegacyMMWarning(message) -> {
|
||||
// These warnings are known and should not be reported as errors.
|
||||
severity
|
||||
}
|
||||
@@ -117,6 +118,9 @@ internal class NativeTestGroupingMessageCollector(
|
||||
|
||||
private fun isK2Experimental(message: String): Boolean = message.startsWith(K2_NATIVE_EXPERIMENTAL_WARNING_PREFIX)
|
||||
|
||||
// Legacy MM is deprecated and will be removed in 1.9.20. Until that moment we still need to run tests with it.
|
||||
private fun isLegacyMMWarning(message: String): Boolean = message.startsWith(LEGACY_MM_WARNING_PREFIX)
|
||||
|
||||
override fun hasErrors() = hasWarningsWithRaisedSeverity || super.hasErrors()
|
||||
|
||||
companion object {
|
||||
@@ -125,6 +129,7 @@ internal class NativeTestGroupingMessageCollector(
|
||||
private const val LIBRARY_INCLUDED_MORE_THAN_ONCE_WARNING_PREFIX = "library included more than once: "
|
||||
private const val K2_NATIVE_EXPERIMENTAL_WARNING_PREFIX = "Language version 2.0 is experimental"
|
||||
private val PARTIAL_LINKAGE_WARNING_REGEX = Regex(".+ uses unlinked symbols(:.*)?")
|
||||
private const val LEGACY_MM_WARNING_PREFIX = "Legacy MM is deprecated and will be removed"
|
||||
|
||||
private fun parseLanguageFeatureArg(arg: String): String? =
|
||||
substringAfter(arg, "-XXLanguage:-") ?: substringAfter(arg, "-XXLanguage:+")
|
||||
|
||||
Reference in New Issue
Block a user