[K/N][codegen] Slightly refactored invocation of CAdapterGenerator
This commit is contained in:
+3
@@ -36,6 +36,9 @@ val KonanConfig.isFinalBinary: Boolean get() = when (this.produce) {
|
|||||||
CompilerOutputKind.FRAMEWORK -> !omitFrameworkBinary
|
CompilerOutputKind.FRAMEWORK -> !omitFrameworkBinary
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val CompilerOutputKind.isNativeLibrary: Boolean
|
||||||
|
get() = this == CompilerOutputKind.DYNAMIC || this == CompilerOutputKind.STATIC
|
||||||
|
|
||||||
val CompilerOutputKind.involvesBitcodeGeneration: Boolean
|
val CompilerOutputKind.involvesBitcodeGeneration: Boolean
|
||||||
get() = this != CompilerOutputKind.LIBRARY
|
get() = this != CompilerOutputKind.LIBRARY
|
||||||
|
|
||||||
|
|||||||
-5
@@ -346,11 +346,6 @@ internal class Context(config: KonanConfig) : KonanBackendContext(config) {
|
|||||||
|
|
||||||
var referencedFunctions: Set<IrFunction>? = null
|
var referencedFunctions: Set<IrFunction>? = null
|
||||||
|
|
||||||
val isNativeLibrary: Boolean by lazy {
|
|
||||||
val kind = config.configuration.get(KonanConfigKeys.PRODUCE)
|
|
||||||
kind == CompilerOutputKind.DYNAMIC || kind == CompilerOutputKind.STATIC
|
|
||||||
}
|
|
||||||
|
|
||||||
internal val stdlibModule
|
internal val stdlibModule
|
||||||
get() = this.builtIns.any.module
|
get() = this.builtIns.any.module
|
||||||
|
|
||||||
|
|||||||
+3
-4
@@ -95,10 +95,8 @@ internal val objCExportPhase = konanUnitPhase(
|
|||||||
|
|
||||||
internal val buildCExportsPhase = konanUnitPhase(
|
internal val buildCExportsPhase = konanUnitPhase(
|
||||||
op = {
|
op = {
|
||||||
if (this.isNativeLibrary) {
|
this.cAdapterGenerator = CAdapterGenerator(this).also {
|
||||||
this.cAdapterGenerator = CAdapterGenerator(this).also {
|
it.buildExports(this.symbolTable!!)
|
||||||
it.buildExports(this.symbolTable!!)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
name = "BuildCExports",
|
name = "BuildCExports",
|
||||||
@@ -481,6 +479,7 @@ internal fun PhaseConfig.konanPhasesConfig(config: KonanConfig) {
|
|||||||
disableUnless(saveAdditionalCacheInfoPhase, config.produce.isCache && config.lazyIrForCaches)
|
disableUnless(saveAdditionalCacheInfoPhase, config.produce.isCache && config.lazyIrForCaches)
|
||||||
disableUnless(finalizeCachePhase, config.produce.isCache)
|
disableUnless(finalizeCachePhase, config.produce.isCache)
|
||||||
disableUnless(exportInternalAbiPhase, config.produce.isCache)
|
disableUnless(exportInternalAbiPhase, config.produce.isCache)
|
||||||
|
disableUnless(buildCExportsPhase, config.produce.isNativeLibrary)
|
||||||
disableIf(backendCodegen, config.produce == CompilerOutputKind.LIBRARY || config.omitFrameworkBinary || config.produce == CompilerOutputKind.PRELIMINARY_CACHE)
|
disableIf(backendCodegen, config.produce == CompilerOutputKind.LIBRARY || config.omitFrameworkBinary || config.produce == CompilerOutputKind.PRELIMINARY_CACHE)
|
||||||
disableUnless(checkExternalCallsPhase, getBoolean(KonanConfigKeys.CHECK_EXTERNAL_CALLS))
|
disableUnless(checkExternalCallsPhase, getBoolean(KonanConfigKeys.CHECK_EXTERNAL_CALLS))
|
||||||
disableUnless(rewriteExternalCallsCheckerGlobals, getBoolean(KonanConfigKeys.CHECK_EXTERNAL_CALLS))
|
disableUnless(rewriteExternalCallsCheckerGlobals, getBoolean(KonanConfigKeys.CHECK_EXTERNAL_CALLS))
|
||||||
|
|||||||
+1
-1
@@ -443,7 +443,7 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
|||||||
overrideRuntimeGlobals()
|
overrideRuntimeGlobals()
|
||||||
appendLlvmUsed("llvm.used", context.llvm.usedFunctions + context.llvm.usedGlobals)
|
appendLlvmUsed("llvm.used", context.llvm.usedFunctions + context.llvm.usedGlobals)
|
||||||
appendLlvmUsed("llvm.compiler.used", context.llvm.compilerUsedGlobals)
|
appendLlvmUsed("llvm.compiler.used", context.llvm.compilerUsedGlobals)
|
||||||
if (context.isNativeLibrary) {
|
if (context.config.produce.isNativeLibrary) {
|
||||||
appendCAdapters()
|
appendCAdapters()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user