[K/N] Move isFinalBinary and involvesLinkStage checks to KonanConfig

It allows to make more precise checks by accessing KonanConfig
properties.
This commit is contained in:
Sergey Bogolepov
2022-07-20 11:15:36 +03:00
committed by Space
parent ebe292ffe9
commit 30f1af7ce0
6 changed files with 9 additions and 9 deletions
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.utils.addToStdlib.ifNotEmpty
/**
* Supposed to be true for a single LLVM module within final binary.
*/
val CompilerOutputKind.isFinalBinary: Boolean get() = when (this) {
val KonanConfig.isFinalBinary: Boolean get() = when (this.produce) {
CompilerOutputKind.PROGRAM, CompilerOutputKind.DYNAMIC,
CompilerOutputKind.STATIC, CompilerOutputKind.FRAMEWORK -> true
CompilerOutputKind.DYNAMIC_CACHE, CompilerOutputKind.STATIC_CACHE,
@@ -41,8 +41,8 @@ val CompilerOutputKind.involvesBitcodeGeneration: Boolean
internal val Context.producedLlvmModuleContainsStdlib: Boolean
get() = this.llvmModuleSpecification.containsModule(this.stdlibModule)
val CompilerOutputKind.involvesLinkStage: Boolean
get() = when (this) {
val KonanConfig.involvesLinkStage: Boolean
get() = when (this.produce) {
CompilerOutputKind.PROGRAM, CompilerOutputKind.DYNAMIC,
CompilerOutputKind.DYNAMIC_CACHE, CompilerOutputKind.STATIC_CACHE,
CompilerOutputKind.STATIC, CompilerOutputKind.FRAMEWORK -> true
@@ -204,7 +204,7 @@ internal class Linker(val context: Context) {
private fun shouldPerformPreLink(caches: CachesToLink, linkerOutputKind: LinkerOutputKind): Boolean {
// Pre-link is only useful when producing static library. Otherwise its just a waste of time.
val isStaticLibrary = linkerOutputKind == LinkerOutputKind.STATIC_LIBRARY &&
context.config.produce.isFinalBinary
context.config.isFinalBinary
val enabled = context.config.cacheSupport.preLinkCaches
val nonEmptyCaches = caches.static.isNotEmpty()
return isStaticLibrary && enabled && nonEmptyCaches
@@ -627,7 +627,7 @@ internal fun PhaseConfig.konanPhasesConfig(config: KonanConfig) {
disableUnless(rewriteExternalCallsCheckerGlobals, getBoolean(KonanConfigKeys.CHECK_EXTERNAL_CALLS))
disableUnless(stringConcatenationTypeNarrowingPhase, config.optimizationsEnabled)
disableUnless(optimizeTLSDataLoadsPhase, config.optimizationsEnabled)
if (!config.produce.involvesLinkStage) {
if (!config.involvesLinkStage) {
disable(bitcodePostprocessingPhase)
disable(linkBitcodeDependenciesPhase)
disable(objectFilesPhase)
@@ -2748,7 +2748,7 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
}
private fun overrideRuntimeGlobals() {
if (!context.config.produce.isFinalBinary)
if (!context.config.isFinalBinary)
return
overrideRuntimeGlobal("Kotlin_destroyRuntimeMode", Int32(context.config.destroyRuntimeMode.value))
@@ -2882,7 +2882,7 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
}
private fun appendGlobalCtors(ctorFunctions: List<LLVMValueRef>) {
if (context.config.produce.isFinalBinary) {
if (context.config.isFinalBinary) {
// Generate function calling all [ctorFunctions].
val globalCtorFunction = generateFunctionNoRuntime(codegen, kVoidFuncType, "_Konan_constructors") {
ctorFunctions.forEach {
@@ -15,7 +15,7 @@ import org.jetbrains.kotlin.backend.konan.objcexport.ObjCExportNamer
internal fun patchObjCRuntimeModule(context: Context): LLVMModuleRef? {
val config = context.config
if (!(config.produce.isFinalBinary && config.target.family.isAppleFamily)) return null
if (!(config.isFinalBinary && config.target.family.isAppleFamily)) return null
val patchBuilder = PatchBuilder(context)
patchBuilder.addObjCPatches()
@@ -83,7 +83,7 @@ internal class ObjCExport(val context: Context, symbolTable: SymbolTable) {
ObjCExportBlockCodeGenerator(codegen).generate()
}
if (!context.config.produce.isFinalBinary) return // TODO: emit RTTI to the same modules as classes belong to.
if (!context.config.isFinalBinary) return // TODO: emit RTTI to the same modules as classes belong to.
val mapper = exportedInterface?.mapper ?: ObjCExportMapper(unitSuspendFunctionExport = context.config.unitSuspendFunctionObjCExport)
namer = exportedInterface?.namer ?: ObjCExportNamerImpl(