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:
Alexander Udalov
2022-09-05 18:56:52 +02:00
parent d50cf81e42
commit 0569f429dd
30 changed files with 33 additions and 129 deletions
@@ -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))
}