Rename -Xno-use-ir -> -Xuse-old-backend, add Gradle option
As soon as JVM IR is enabled by default (in language version 1.5), use the CLI argument `-Xuse-old-backend` or Gradle option `useOldBackend` to switch to the old JVM backend.
This commit is contained in:
+4
-3
@@ -85,8 +85,9 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
||||
@Argument(value = "-Xuse-ir", description = "Use the IR backend")
|
||||
var useIR: Boolean by FreezableVar(false)
|
||||
|
||||
@Argument(value = "-Xno-use-ir", description = "Do not use the IR backend. Useful for a custom-built compiler where IR backend is enabled by default")
|
||||
var noUseIR: 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)
|
||||
|
||||
@Argument(
|
||||
value = "-Xallow-unstable-dependencies",
|
||||
@@ -462,7 +463,7 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
||||
}
|
||||
|
||||
override fun checkIrSupport(languageVersionSettings: LanguageVersionSettings, collector: MessageCollector) {
|
||||
if (!useIR) return
|
||||
if (!useIR || useOldBackend) return
|
||||
|
||||
if (languageVersionSettings.languageVersion < LanguageVersion.KOTLIN_1_3
|
||||
|| languageVersionSettings.apiVersion < ApiVersion.KOTLIN_1_3
|
||||
|
||||
@@ -165,7 +165,7 @@ fun CompilerConfiguration.configureAdvancedJvmOptions(arguments: K2JVMCompilerAr
|
||||
|
||||
put(JVMConfigurationKeys.PARAMETERS_METADATA, arguments.javaParameters)
|
||||
|
||||
val useIR = (arguments.useIR && !arguments.noUseIR) || arguments.useFir
|
||||
val useIR = (arguments.useIR && !arguments.useOldBackend) || arguments.useFir
|
||||
put(JVMConfigurationKeys.IR, useIR)
|
||||
|
||||
val abiStability = JvmAbiStability.fromStringOrNull(arguments.abiStability)
|
||||
@@ -242,11 +242,9 @@ fun CompilerConfiguration.configureAdvancedJvmOptions(arguments: K2JVMCompilerAr
|
||||
}
|
||||
|
||||
fun CompilerConfiguration.configureKlibPaths(arguments: K2JVMCompilerArguments) {
|
||||
assert(arguments.useIR || arguments.klibLibraries == null) { "Klib libraries can only be used with IR backend" }
|
||||
arguments.klibLibraries?.split(File.pathSeparator.toRegex())
|
||||
?.toTypedArray()
|
||||
?.filterNot { it.isEmpty() }
|
||||
?.let { put(JVMConfigurationKeys.KLIB_PATHS, it) }
|
||||
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))
|
||||
}
|
||||
|
||||
private val CompilerConfiguration.messageCollector: MessageCollector
|
||||
|
||||
+1
-1
@@ -86,7 +86,6 @@ where advanced options include:
|
||||
-Xno-receiver-assertions Don't generate not-null assertion for extension receiver arguments of platform types
|
||||
-Xno-reset-jar-timestamps Do not reset jar entry timestamps to a fixed date
|
||||
-Xno-unified-null-checks Use pre-1.4 exception types in null checks instead of java.lang.NPE. See KT-22275 for more details
|
||||
-Xno-use-ir Do not use the IR backend. Useful for a custom-built compiler where IR backend is enabled by default
|
||||
-Xprofile=<profilerPath:command:outputDir>
|
||||
Debug option: Run compiler with async profiler, save snapshots to outputDir, command is passed to async-profiler on start
|
||||
You'll have to provide async-profiler.jar on classpath to use this
|
||||
@@ -116,6 +115,7 @@ where advanced options include:
|
||||
Suppress the "cannot access built-in declaration" error (useful with -no-stdlib)
|
||||
-Xuse-ir Use the IR backend
|
||||
-Xuse-javac Use javac for Java source and class files analysis
|
||||
-Xuse-old-backend Use the old JVM backend
|
||||
-Xuse-old-class-files-reading Use old class files reading implementation. This may slow down the build and cause problems with Groovy interop.
|
||||
Should be used in case of problems with the new implementation
|
||||
-Xuse-14-inline-classes-mangling-scheme
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.intellij.psi.MultiRangeReference
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.util.containers.MultiMap
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
||||
import org.jetbrains.kotlin.config.KotlinFacetSettings
|
||||
import org.jetbrains.kotlin.config.KotlinFacetSettingsProvider
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
@@ -273,14 +274,19 @@ private class ElementAnnotator(
|
||||
}
|
||||
|
||||
private fun isUnstableAbiClassDiagnosticForModulesWithEnabledUnstableAbi(diagnostic: Diagnostic): Boolean {
|
||||
val setting = when (diagnostic.factory) {
|
||||
Errors.IR_WITH_UNSTABLE_ABI_COMPILED_CLASS -> K2JVMCompilerArguments::useIR
|
||||
Errors.FIR_COMPILED_CLASS -> K2JVMCompilerArguments::useFir
|
||||
else -> return false
|
||||
}
|
||||
val factory = diagnostic.factory
|
||||
if (factory != Errors.IR_WITH_UNSTABLE_ABI_COMPILED_CLASS && factory != Errors.FIR_COMPILED_CLASS) return false
|
||||
|
||||
val module = element.module ?: return false
|
||||
val moduleFacetSettings = KotlinFacetSettingsProvider.getInstance(element.project)?.getSettings(module) ?: return false
|
||||
return moduleFacetSettings.isCompilerSettingPresent(setting)
|
||||
return when (factory) {
|
||||
Errors.IR_WITH_UNSTABLE_ABI_COMPILED_CLASS ->
|
||||
moduleFacetSettings.isCompilerSettingPresent(K2JVMCompilerArguments::useIR) &&
|
||||
!moduleFacetSettings.isCompilerSettingPresent(K2JVMCompilerArguments::useOldBackend)
|
||||
Errors.FIR_COMPILED_CLASS ->
|
||||
moduleFacetSettings.isCompilerSettingPresent(K2JVMCompilerArguments::useFir)
|
||||
else -> error(factory)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -51,7 +51,8 @@ tasks {
|
||||
"-Xopt-in=kotlin.contracts.ExperimentalContracts",
|
||||
"-Xcoroutines=enable",
|
||||
"-XXLanguage:-ReleaseCoroutines",
|
||||
"-Xno-use-ir"
|
||||
"-Xno-use-ir",
|
||||
"-Xuse-old-backend"
|
||||
)
|
||||
moduleName = "kotlin-coroutines-experimental-compat"
|
||||
}
|
||||
@@ -62,7 +63,8 @@ tasks {
|
||||
apiVersion = "1.2"
|
||||
freeCompilerArgs = listOf(
|
||||
"-Xcoroutines=enable",
|
||||
"-Xno-use-ir"
|
||||
"-Xno-use-ir",
|
||||
"-Xuse-old-backend"
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -71,7 +73,8 @@ tasks {
|
||||
languageVersion = "1.3"
|
||||
apiVersion = "1.3"
|
||||
freeCompilerArgs = listOf(
|
||||
"-Xno-use-ir"
|
||||
"-Xno-use-ir",
|
||||
"-Xuse-old-backend"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -17,4 +17,4 @@ interface KotlinCommonOptions : org.jetbrains.kotlin.gradle.dsl.KotlinCommonToo
|
||||
* Default value: null
|
||||
*/
|
||||
var languageVersion: kotlin.String?
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -58,4 +58,10 @@ interface KotlinJvmOptions : org.jetbrains.kotlin.gradle.dsl.KotlinCommonOption
|
||||
* Default value: false
|
||||
*/
|
||||
var useIR: kotlin.Boolean
|
||||
|
||||
/**
|
||||
* Use the old JVM backend
|
||||
* Default value: false
|
||||
*/
|
||||
var useOldBackend: kotlin.Boolean
|
||||
}
|
||||
|
||||
+9
@@ -102,6 +102,13 @@ internal abstract class KotlinJvmOptionsBase : org.jetbrains.kotlin.gradle.dsl.K
|
||||
useIRField = 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 }
|
||||
@@ -117,6 +124,7 @@ internal abstract class KotlinJvmOptionsBase : org.jetbrains.kotlin.gradle.dsl.K
|
||||
noReflectField?.let { args.noReflect = it }
|
||||
noStdlibField?.let { args.noStdlib = it }
|
||||
useIRField?.let { args.useIR = it }
|
||||
useOldBackendField?.let { args.useOldBackend = it }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,4 +143,5 @@ internal fun org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments.fi
|
||||
noReflect = true
|
||||
noStdlib = true
|
||||
useIR = false
|
||||
useOldBackend = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user