Report error on -Xuse-old-backend, remove Gradle option useOldBackend
Allow using old JVM backend only to compile kts. #KT-48532 Fixed
This commit is contained in:
-1
@@ -91,7 +91,6 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
||||
)
|
||||
var useIR: Boolean by FreezableVar(false)
|
||||
|
||||
@GradleOption(DefaultValues.BooleanFalseDefault::class)
|
||||
@Argument(value = "-Xuse-old-backend", description = "Use the old JVM backend")
|
||||
var useOldBackend: Boolean by FreezableVar(false)
|
||||
|
||||
|
||||
@@ -101,6 +101,10 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
|
||||
)
|
||||
projectEnvironment.registerExtensionsFromPlugins(configuration)
|
||||
|
||||
if (arguments.useOldBackend) {
|
||||
messageCollector.report(WARNING, "-Xuse-old-backend is no longer supported. Please migrate to the new JVM IR backend")
|
||||
}
|
||||
|
||||
if (arguments.script || arguments.expression != null) {
|
||||
val scriptingEvaluator = ScriptEvaluationExtension.getInstances(projectEnvironment.project).find { it.isAccepted(arguments) }
|
||||
if (scriptingEvaluator == null) {
|
||||
@@ -118,6 +122,11 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
|
||||
}
|
||||
}
|
||||
|
||||
if (arguments.useOldBackend) {
|
||||
messageCollector.report(ERROR, "-Xuse-old-backend is no longer supported. Please migrate to the new JVM IR backend")
|
||||
return COMPILATION_ERROR
|
||||
}
|
||||
|
||||
messageCollector.report(LOGGING, "Configuring the compilation environment")
|
||||
try {
|
||||
val buildFile = arguments.buildFile?.let { File(it) }
|
||||
|
||||
@@ -265,20 +265,6 @@ fun CompilerConfiguration.configureAdvancedJvmOptions(arguments: K2JVMCompilerAr
|
||||
arguments.useIR && !useOldBackend
|
||||
}
|
||||
|
||||
if (arguments.useOldBackend) {
|
||||
messageCollector.report(
|
||||
STRONG_WARNING,
|
||||
"-Xuse-old-backend is deprecated and will be removed in a future release"
|
||||
)
|
||||
if (arguments.useIR) {
|
||||
messageCollector.report(
|
||||
STRONG_WARNING,
|
||||
"Both -Xuse-ir and -Xuse-old-backend are passed. This is an inconsistent configuration. " +
|
||||
"The compiler will use the ${if (useIR) "JVM IR" else "old JVM"} backend"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
messageCollector.report(LOGGING, "Using ${if (useIR) "JVM IR" else "old JVM"} backend")
|
||||
|
||||
put(JVMConfigurationKeys.IR, useIR)
|
||||
@@ -377,7 +363,6 @@ private fun parseBackendThreads(stringValue: String, messageCollector: MessageCo
|
||||
|
||||
fun CompilerConfiguration.configureKlibPaths(arguments: K2JVMCompilerArguments) {
|
||||
val libraries = arguments.klibLibraries ?: return
|
||||
assert(arguments.useIR && !arguments.useOldBackend) { "Klib libraries can only be used with IR backend" }
|
||||
put(JVMConfigurationKeys.KLIB_PATHS, libraries.split(File.pathSeparator.toRegex()).filterNot(String::isEmpty))
|
||||
}
|
||||
|
||||
|
||||
+1
-7
@@ -6,15 +6,9 @@
|
||||
package org.jetbrains.kotlin.fir
|
||||
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
||||
import org.jetbrains.kotlin.cli.common.toBooleanLenient
|
||||
|
||||
|
||||
private val USE_BE_IR = System.getProperty("fir.bench.fe1.useIR", "false").toBooleanLenient()!!
|
||||
|
||||
class FE1FullPipelineModularizedTest : AbstractFullPipelineModularizedTest() {
|
||||
override fun configureArguments(args: K2JVMCompilerArguments, moduleData: ModuleData) {
|
||||
args.useIR = USE_BE_IR
|
||||
args.useOldBackend = !USE_BE_IR
|
||||
args.useK2 = false
|
||||
args.jvmDefault = "compatibility"
|
||||
args.apiVersion = "1.4"
|
||||
@@ -34,4 +28,4 @@ class FE1FullPipelineModularizedTest : AbstractFullPipelineModularizedTest() {
|
||||
runTestOnce(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
$TESTDATA_DIR$/simple.kt
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
-Xabi-stability=unstable
|
||||
-Xuse-old-backend
|
||||
@@ -1,7 +0,0 @@
|
||||
$TESTDATA_DIR$/simple.kt
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
-Xuse-ir
|
||||
-Xuse-old-backend
|
||||
-language-version
|
||||
1.5
|
||||
@@ -1,3 +0,0 @@
|
||||
warning: -Xuse-old-backend is deprecated and will be removed in a future release
|
||||
warning: both -Xuse-ir and -Xuse-old-backend are passed. This is an inconsistent configuration. The compiler will use the old JVM backend
|
||||
OK
|
||||
@@ -1,6 +1,3 @@
|
||||
$TESTDATA_DIR$/classAndTraitClash.kt
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
-Xuse-old-backend
|
||||
-language-version
|
||||
1.5
|
||||
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
package test
|
||||
|
||||
interface T1 {
|
||||
|
||||
interface T1 {
|
||||
fun f() {}
|
||||
}
|
||||
|
||||
class `T1$DefaultImpls` {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+3
-4
@@ -1,8 +1,7 @@
|
||||
warning: -Xuse-old-backend is deprecated and will be removed in a future release
|
||||
compiler/testData/cli/jvm/classAndTraitClash.kt:3:1: error: duplicate JVM class name 'test/T1$DefaultImpls' generated from: `T1$DefaultImpls`, T1
|
||||
interface T1 {
|
||||
compiler/testData/cli/jvm/classAndTraitClash.kt:3:1: error: duplicate JVM class name 'test/T1$DefaultImpls' generated from: `T1$DefaultImpls`, DefaultImpls
|
||||
interface T1 {
|
||||
^
|
||||
compiler/testData/cli/jvm/classAndTraitClash.kt:7:1: error: duplicate JVM class name 'test/T1$DefaultImpls' generated from: `T1$DefaultImpls`, T1
|
||||
compiler/testData/cli/jvm/classAndTraitClash.kt:7:1: error: duplicate JVM class name 'test/T1$DefaultImpls' generated from: `T1$DefaultImpls`, DefaultImpls
|
||||
class `T1$DefaultImpls` {
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
-2
@@ -2,5 +2,3 @@ $TESTDATA_DIR$/simple.kt
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
-Xuse-old-backend
|
||||
-language-version
|
||||
1.6
|
||||
+1
-2
@@ -1,4 +1,3 @@
|
||||
warning: language version is automatically inferred to 1.5 when using the old JVM backend. Consider specifying -language-version explicitly, or remove -Xuse-old-backend
|
||||
warning: -Xuse-old-backend is deprecated and will be removed in a future release
|
||||
error: -Xabi-stability=unstable is not supported in the old JVM backend
|
||||
error: -Xuse-old-backend is no longer supported. Please migrate to the new JVM IR backend
|
||||
COMPILATION_ERROR
|
||||
@@ -1,2 +0,0 @@
|
||||
error: old JVM backend does not support language version 1.6 or above. Please use language version 1.5 or below, or remove -Xuse-old-backend
|
||||
COMPILATION_ERROR
|
||||
@@ -0,0 +1,5 @@
|
||||
$TESTDATA_DIR$/hello.kts
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
-Xuse-old-backend
|
||||
-script
|
||||
@@ -0,0 +1,3 @@
|
||||
warning: language version is automatically inferred to 1.5 when using the old JVM backend. Consider specifying -language-version explicitly, or remove -Xuse-old-backend
|
||||
warning: -Xuse-old-backend is no longer supported. Please migrate to the new JVM IR backend
|
||||
OK
|
||||
@@ -1,3 +0,0 @@
|
||||
$TESTDATA_DIR$/suspendInFunInterfaceDefault.kt
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
@@ -1,3 +0,0 @@
|
||||
fun interface FIC {
|
||||
suspend fun foo()
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
OK
|
||||
@@ -1,6 +0,0 @@
|
||||
$TESTDATA_DIR$/suspendInFunInterfaceIrDisabled.kt
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
-Xuse-old-backend
|
||||
-language-version
|
||||
1.5
|
||||
@@ -1,3 +0,0 @@
|
||||
fun interface FIC {
|
||||
suspend fun foo()
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
warning: -Xuse-old-backend is deprecated and will be removed in a future release
|
||||
compiler/testData/cli/jvm/suspendInFunInterfaceIrDisabled.kt:2:5: error: 'suspend' modifier is not allowed on a single abstract member
|
||||
suspend fun foo()
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
@@ -1,4 +0,0 @@
|
||||
$TESTDATA_DIR$/suspendInFunInterfaceIrEnabled.kt
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
-Xuse-ir
|
||||
@@ -1,3 +0,0 @@
|
||||
fun interface FIC {
|
||||
suspend fun foo()
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
OK
|
||||
@@ -138,11 +138,6 @@ public class CliTestGenerated extends AbstractCliTest {
|
||||
runTest("compiler/testData/cli/jvm/abiStabilityIncorrectValue.args");
|
||||
}
|
||||
|
||||
@TestMetadata("abiStabilityUnstableWithOldBackend.args")
|
||||
public void testAbiStabilityUnstableWithOldBackend() throws Exception {
|
||||
runTest("compiler/testData/cli/jvm/abiStabilityUnstableWithOldBackend.args");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInJvm() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/cli/jvm"), Pattern.compile("^(.+)\\.args$"), null, false);
|
||||
}
|
||||
@@ -207,11 +202,6 @@ public class CliTestGenerated extends AbstractCliTest {
|
||||
runTest("compiler/testData/cli/jvm/argumentPassedMultipleTimes.args");
|
||||
}
|
||||
|
||||
@TestMetadata("bothJvmIrAndOldBackend.args")
|
||||
public void testBothJvmIrAndOldBackend() throws Exception {
|
||||
runTest("compiler/testData/cli/jvm/bothJvmIrAndOldBackend.args");
|
||||
}
|
||||
|
||||
@TestMetadata("builderInferenceByDefault.args")
|
||||
public void testBuilderInferenceByDefault() throws Exception {
|
||||
runTest("compiler/testData/cli/jvm/builderInferenceByDefault.args");
|
||||
@@ -927,9 +917,14 @@ public class CliTestGenerated extends AbstractCliTest {
|
||||
runTest("compiler/testData/cli/jvm/nullabilityAnnotations.args");
|
||||
}
|
||||
|
||||
@TestMetadata("oldBackendLv16.args")
|
||||
public void testOldBackendLv16() throws Exception {
|
||||
runTest("compiler/testData/cli/jvm/oldBackendLv16.args");
|
||||
@TestMetadata("oldBackend.args")
|
||||
public void testOldBackend() throws Exception {
|
||||
runTest("compiler/testData/cli/jvm/oldBackend.args");
|
||||
}
|
||||
|
||||
@TestMetadata("oldBackendWithScript.args")
|
||||
public void testOldBackendWithScript() throws Exception {
|
||||
runTest("compiler/testData/cli/jvm/oldBackendWithScript.args");
|
||||
}
|
||||
|
||||
@TestMetadata("optInEmptyMessage.args")
|
||||
@@ -1042,21 +1037,6 @@ public class CliTestGenerated extends AbstractCliTest {
|
||||
runTest("compiler/testData/cli/jvm/suppressAllWarningsJvm.args");
|
||||
}
|
||||
|
||||
@TestMetadata("suspendInFunInterfaceDefault.args")
|
||||
public void testSuspendInFunInterfaceDefault() throws Exception {
|
||||
runTest("compiler/testData/cli/jvm/suspendInFunInterfaceDefault.args");
|
||||
}
|
||||
|
||||
@TestMetadata("suspendInFunInterfaceIrDisabled.args")
|
||||
public void testSuspendInFunInterfaceIrDisabled() throws Exception {
|
||||
runTest("compiler/testData/cli/jvm/suspendInFunInterfaceIrDisabled.args");
|
||||
}
|
||||
|
||||
@TestMetadata("suspendInFunInterfaceIrEnabled.args")
|
||||
public void testSuspendInFunInterfaceIrEnabled() throws Exception {
|
||||
runTest("compiler/testData/cli/jvm/suspendInFunInterfaceIrEnabled.args");
|
||||
}
|
||||
|
||||
@TestMetadata("suspensionPointInMonitor.args")
|
||||
public void testSuspensionPointInMonitor() throws Exception {
|
||||
runTest("compiler/testData/cli/jvm/suspensionPointInMonitor.args");
|
||||
|
||||
@@ -140,7 +140,6 @@ class CompilerArgumentsContentProspectorTest {
|
||||
K2JVMCompilerArguments::noReflect,
|
||||
K2JVMCompilerArguments::javaParameters,
|
||||
K2JVMCompilerArguments::useIR,
|
||||
K2JVMCompilerArguments::useOldBackend,
|
||||
K2JVMCompilerArguments::allowUnstableDependencies,
|
||||
K2JVMCompilerArguments::doNotClearBindingContext,
|
||||
K2JVMCompilerArguments::noCallAssertions,
|
||||
|
||||
-6
@@ -29,10 +29,4 @@ interface KotlinJvmOptions : org.jetbrains.kotlin.gradle.dsl.KotlinCommonOption
|
||||
* Default value: false
|
||||
*/
|
||||
var noJdk: kotlin.Boolean
|
||||
|
||||
/**
|
||||
* Use the old JVM backend
|
||||
* Default value: false
|
||||
*/
|
||||
var useOldBackend: kotlin.Boolean
|
||||
}
|
||||
|
||||
-1
@@ -151,7 +151,6 @@ internal open class GradleCompilerRunner(
|
||||
parseCommandLineArguments(argsArray.toList(), args)
|
||||
report(BooleanMetrics.JVM_COMPILER_IR_MODE, args.useIR)
|
||||
report(StringMetrics.JVM_DEFAULTS, args.jvmDefault)
|
||||
report(StringMetrics.USE_OLD_BACKEND, args.useOldBackend.toString())
|
||||
report(StringMetrics.USE_FIR, args.useK2.toString())
|
||||
|
||||
val pluginPatterns = listOf(Pair(BooleanMetrics.ENABLED_COMPILER_PLUGIN_ALL_OPEN, "kotlin-allopen-.*jar"),
|
||||
|
||||
-9
@@ -55,13 +55,6 @@ internal abstract class KotlinJvmOptionsBase : org.jetbrains.kotlin.gradle.dsl.K
|
||||
noJdkField = value
|
||||
}
|
||||
|
||||
private var useOldBackendField: kotlin.Boolean? = null
|
||||
override var useOldBackend: kotlin.Boolean
|
||||
get() = useOldBackendField ?: false
|
||||
set(value) {
|
||||
useOldBackendField = value
|
||||
}
|
||||
|
||||
internal open fun updateArguments(args: org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments) {
|
||||
allWarningsAsErrorsField?.let { args.allWarningsAsErrors = it }
|
||||
suppressWarningsField?.let { args.suppressWarnings = it }
|
||||
@@ -73,7 +66,6 @@ internal abstract class KotlinJvmOptionsBase : org.jetbrains.kotlin.gradle.dsl.K
|
||||
jvmTarget?.let { args.jvmTarget = it }
|
||||
moduleName?.let { args.moduleName = it }
|
||||
noJdkField?.let { args.noJdk = it }
|
||||
useOldBackendField?.let { args.useOldBackend = it }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +80,6 @@ internal fun org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments.fi
|
||||
jvmTarget = null
|
||||
moduleName = null
|
||||
noJdk = false
|
||||
useOldBackend = false
|
||||
noStdlib = true
|
||||
noReflect = true
|
||||
}
|
||||
|
||||
-1
@@ -134,7 +134,6 @@ internal fun reportArgumentsNotAllowed(
|
||||
reportingState,
|
||||
K2JVMCompilerArguments::useJavac,
|
||||
K2JVMCompilerArguments::useIR,
|
||||
K2JVMCompilerArguments::useOldBackend,
|
||||
K2JVMCompilerArguments::useK2
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user