Skip to content

Commit

Permalink
JVM: remove -Xuse-old-backend
Browse files Browse the repository at this point in the history
 #KT-71197
  • Loading branch information
udalov authored and Space Team committed Feb 12, 2025
1 parent cac08d3 commit 8d62066
Show file tree
Hide file tree
Showing 14 changed files with 3 additions and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ fun copyK2JVMCompilerArguments(from: K2JVMCompilerArguments, to: K2JVMCompilerAr
to.useInlineScopesNumbers = from.useInlineScopesNumbers
to.useJavac = from.useJavac
to.useK2Kapt = from.useK2Kapt
to.useOldBackend = from.useOldBackend
to.useOldClassFilesReading = from.useOldClassFilesReading
to.useOldInlineClassesManglingScheme = from.useOldInlineClassesManglingScheme
to.useTypeTable = from.useTypeTable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1096,9 +1096,6 @@ default: 'first-only-warn' in language version 2.2+, 'first-only' in version 2.1
}
}

protected open fun defaultLanguageVersion(collector: MessageCollector): LanguageVersion =
LanguageVersion.LATEST_STABLE

protected open fun checkPlatformSpecificSettings(languageVersionSettings: LanguageVersionSettings, collector: MessageCollector) {
}

Expand Down Expand Up @@ -1136,7 +1133,7 @@ default: 'first-only-warn' in language version 2.2+, 'first-only' in version 2.1
}

// If only "-api-version" is specified, language version is assumed to be the latest stable
return parseVersion(collector, languageVersion, "language") ?: defaultLanguageVersion(collector)
return parseVersion(collector, languageVersion, "language") ?: LanguageVersion.LATEST_STABLE
}

private fun parseVersion(collector: MessageCollector, value: String?, versionOf: String): LanguageVersion? =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,6 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {

// Advanced options

@Argument(value = "-Xuse-old-backend", description = "Use the old JVM backend.")
var useOldBackend = false
set(value) {
checkFrozen()
field = value
}

@Argument(
value = "-Xallow-unstable-dependencies",
description = "Do not report errors on classes in dependencies that were compiled by an unstable version of the Kotlin compiler."
Expand Down Expand Up @@ -854,7 +847,6 @@ This option is deprecated and will be deleted in future versions."""
result[JvmAnalysisFlags.suppressMissingBuiltinsError] = suppressMissingBuiltinsError
result[JvmAnalysisFlags.enableJvmPreview] = enableJvmPreview
result[AnalysisFlags.allowUnstableDependencies] = allowUnstableDependencies
result[JvmAnalysisFlags.useIR] = !useOldBackend
result[JvmAnalysisFlags.outputBuiltinsMetadata] = outputBuiltinsMetadata
if (expectBuiltinsAsPartOfStdlib && !stdlibCompilation) {
collector.report(
Expand Down Expand Up @@ -909,26 +901,7 @@ This option is deprecated and will be deleted in future versions."""
return result
}

override fun defaultLanguageVersion(collector: MessageCollector): LanguageVersion =
if (useOldBackend) {
if (!suppressVersionWarnings) {
collector.report(
CompilerMessageSeverity.STRONG_WARNING,
"Language version is automatically inferred to ${LanguageVersion.KOTLIN_1_5.versionString} when using " +
"the old JVM backend. Consider specifying -language-version explicitly, or remove -Xuse-old-backend"
)
}
LanguageVersion.KOTLIN_1_5
} else super.defaultLanguageVersion(collector)

override fun checkPlatformSpecificSettings(languageVersionSettings: LanguageVersionSettings, collector: MessageCollector) {
if (useOldBackend && languageVersionSettings.languageVersion >= LanguageVersion.KOTLIN_1_6) {
collector.report(
CompilerMessageSeverity.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"
)
}
if (oldInnerClassesLogic) {
collector.report(
CompilerMessageSeverity.WARNING,
Expand Down
13 changes: 0 additions & 13 deletions compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,6 @@ 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) {
Expand All @@ -142,12 +138,6 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
}
}

if (arguments.useOldBackend) {
val severity = if (isUseOldBackendAllowed()) WARNING else ERROR
messageCollector.report(severity, "-Xuse-old-backend is no longer supported. Please migrate to the new JVM IR backend")
if (severity == ERROR) return COMPILATION_ERROR
}

messageCollector.report(LOGGING, "Configuring the compilation environment")
try {
val buildFile = arguments.buildFile?.let { File(it) }
Expand Down Expand Up @@ -285,9 +275,6 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
override fun createPerformanceManager(arguments: K2JVMCompilerArguments, services: Services): PerformanceManager {
return createCustomPerformanceManagerOrNull(arguments, services) ?: defaultPerformanceManager
}

private fun isUseOldBackendAllowed(): Boolean =
K2JVMCompiler::class.java.classLoader.getResource("META-INF/unsafe-allow-use-old-backend") != null
}

fun CompilerConfiguration.configureModuleChunk(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ object JvmAnalysisFlags {
@JvmStatic
val enableJvmPreview by AnalysisFlag.Delegates.Boolean

@JvmStatic
val useIR by AnalysisFlag.Delegates.Boolean

@JvmStatic
val outputBuiltinsMetadata by AnalysisFlag.Delegates.Boolean

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

package org.jetbrains.kotlin.resolve.jvm.checkers

import org.jetbrains.kotlin.config.JvmAnalysisFlags
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
Expand All @@ -29,12 +28,10 @@ class SuspendInFunInterfaceChecker : DeclarationChecker {
val abstractMember = getSingleAbstractMethodOrNull(descriptor) ?: return
if (!abstractMember.isSuspend) return

if (context.languageVersionSettings.supportsFeature(LanguageFeature.SuspendFunctionsInFunInterfaces) &&
context.languageVersionSettings.getFlag(JvmAnalysisFlags.useIR)
) return
if (context.languageVersionSettings.supportsFeature(LanguageFeature.SuspendFunctionsInFunInterfaces)) return

val ktFunction = abstractMember.source.getPsi() as? KtNamedFunction
val reportOn = ktFunction?.modifierList?.getModifier(KtTokens.SUSPEND_KEYWORD) ?: funKeyword
context.trace.report(Errors.FUN_INTERFACE_WITH_SUSPEND_FUNCTION.on(reportOn))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ class LanguageVersionSettingsBuilder {
analysisFlag(JvmAnalysisFlags.sanitizeParentheses, trueOrNull(LanguageSettingsDirectives.SANITIZE_PARENTHESES in directives)),
analysisFlag(JvmAnalysisFlags.enableJvmPreview, trueOrNull(LanguageSettingsDirectives.ENABLE_JVM_PREVIEW in directives)),
analysisFlag(JvmAnalysisFlags.expectBuiltinsAsPartOfStdlib, trueOrNull(LanguageSettingsDirectives.EXPECT_BUILTINS_AS_PART_OF_STDLIB in directives)),
analysisFlag(JvmAnalysisFlags.useIR, targetBackend?.isIR != false),

analysisFlag(AnalysisFlags.explicitApiVersion, trueOrNull(apiVersion != null)),
)
Expand Down
1 change: 0 additions & 1 deletion compiler/testData/cli/jvm/extraHelp.out
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ where advanced options include:
-Xuse-inline-scopes-numbers Use inline scopes numbers for inline marker variables.
-Xuse-javac Use javac for Java source and class file analysis.
-Xuse-k2-kapt Enable the experimental support for K2 KAPT.
-Xuse-old-backend Use the old JVM backend.
-Xuse-old-class-files-reading Use the old implementation for reading class files. This may slow down the compilation and cause problems with Groovy interop.
This can be used in the event of problems with the new implementation.
-Xuse-14-inline-classes-mangling-scheme
Expand Down
4 changes: 0 additions & 4 deletions compiler/testData/cli/jvm/oldBackend.args

This file was deleted.

3 changes: 0 additions & 3 deletions compiler/testData/cli/jvm/oldBackend.out

This file was deleted.

5 changes: 0 additions & 5 deletions compiler/testData/cli/jvm/oldBackendWithScript.args

This file was deleted.

3 changes: 0 additions & 3 deletions compiler/testData/cli/jvm/oldBackendWithScript.out

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@

package org.jetbrains.kotlin.codegen

import org.jetbrains.kotlin.checkers.CompilerTestLanguageVersionSettings
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.config.*
import org.jetbrains.kotlin.container.StorageComponentContainer
import org.jetbrains.kotlin.container.useInstance
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
Expand Down Expand Up @@ -103,26 +101,6 @@ abstract class AbstractLightAnalysisModeTest : CodegenTestCase() {
return BytecodeListingTextCollectingVisitor.getText(classFileFactory, ListAnalysisFilter())
}

override fun updateConfiguration(configuration: CompilerConfiguration) {
super.updateConfiguration(configuration)
configureIrAnalysisFlag(configuration)
}

// TODO: rewrite the test on the new infrastructure, so that this won't be needed.
private fun configureIrAnalysisFlag(configuration: CompilerConfiguration) {
val irFlag: Map<AnalysisFlag<*>, Boolean> = mapOf(JvmAnalysisFlags.useIR to backend.isIR)
val lvs = configuration.languageVersionSettings
if (lvs is CompilerTestLanguageVersionSettings) {
configuration.languageVersionSettings = LanguageVersionSettingsImpl(
lvs.languageVersion, lvs.apiVersion, lvs.analysisFlags + irFlag, lvs.extraLanguageFeatures,
)
} else {
configuration.languageVersionSettings = LanguageVersionSettingsImpl(
LanguageVersion.LATEST_STABLE, ApiVersion.LATEST_STABLE, irFlag,
)
}
}

private class ListAnalysisFilter : BytecodeListingTextCollectingVisitor.Filter {
@Suppress("UNCHECKED_CAST")
override fun shouldWriteClass(node: ClassNode): Boolean {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8d62066

Please # to comment.