Move exported runtime Obj-C classes from dynamic cache to final binary
Otherwise Swift/Obj-C code requires linking with cache directly too.
This commit is contained in:
committed by
SvyatoslavScherbina
parent
da328576ce
commit
3eefdad759
+13
-4
@@ -51,11 +51,20 @@ internal fun produceCStubs(context: Context) {
|
||||
}
|
||||
|
||||
private fun linkAllDependencies(context: Context, generatedBitcodeFiles: List<String>) {
|
||||
val runtimeNativeLibraries = context.config.runtimeNativeLibraries
|
||||
val config = context.config
|
||||
|
||||
val runtimeNativeLibraries = config.runtimeNativeLibraries
|
||||
.takeIf { context.producedLlvmModuleContainsStdlib }.orEmpty()
|
||||
val launcherNativeLibraries = context.config.launcherNativeLibraries
|
||||
.takeIf { context.config.produce == CompilerOutputKind.PROGRAM }.orEmpty()
|
||||
val nativeLibraries = context.config.nativeLibraries + runtimeNativeLibraries + launcherNativeLibraries
|
||||
|
||||
val launcherNativeLibraries = config.launcherNativeLibraries
|
||||
.takeIf { config.produce == CompilerOutputKind.PROGRAM }.orEmpty()
|
||||
|
||||
val objCNativeLibraries = config.objCNativeLibraries
|
||||
.takeIf { config.produce.isFinalBinary && config.target.family.isAppleFamily }.orEmpty()
|
||||
|
||||
val nativeLibraries = config.nativeLibraries + runtimeNativeLibraries +
|
||||
launcherNativeLibraries + objCNativeLibraries
|
||||
|
||||
val bitcodeLibraries = context.llvm.bitcodeToLink.map { it.bitcodePaths }.flatten().filter { it.isBitcode }
|
||||
val additionalBitcodeFilesToLink = context.llvm.additionalProducedBitcodeFiles
|
||||
val bitcodeFiles = (nativeLibraries + generatedBitcodeFiles + additionalBitcodeFilesToLink + bitcodeLibraries).toSet()
|
||||
|
||||
+4
@@ -181,6 +181,10 @@ class KonanConfig(val project: Project, val configuration: CompilerConfiguration
|
||||
File(distribution.defaultNatives(target)).child(it).absolutePath
|
||||
}
|
||||
|
||||
internal val objCNativeLibraries: List<String> = listOf("objc.bc").map {
|
||||
File(distribution.defaultNatives(target)).child(it).absolutePath
|
||||
}
|
||||
|
||||
internal val nativeLibraries: List<String> =
|
||||
configuration.getList(KonanConfigKeys.NATIVE_LIBRARY_FILES)
|
||||
|
||||
|
||||
-6
@@ -473,12 +473,6 @@ internal class Llvm(val context: Context, val llvmModule: LLVMModuleRef) {
|
||||
val Kotlin_ObjCExport_refToObjC by lazyRtFunction
|
||||
val Kotlin_ObjCExport_refFromObjC by lazyRtFunction
|
||||
val Kotlin_ObjCExport_CreateNSStringFromKString by lazyRtFunction
|
||||
val Kotlin_Interop_CreateNSArrayFromKList by lazyRtFunction
|
||||
val Kotlin_Interop_CreateNSMutableArrayFromKList by lazyRtFunction
|
||||
val Kotlin_Interop_CreateNSSetFromKSet by lazyRtFunction
|
||||
val Kotlin_Interop_CreateKotlinMutableSetFromKSet by lazyRtFunction
|
||||
val Kotlin_Interop_CreateNSDictionaryFromKMap by lazyRtFunction
|
||||
val Kotlin_Interop_CreateKotlinMutableDictonaryFromKMap by lazyRtFunction
|
||||
val Kotlin_ObjCExport_convertUnit by lazyRtFunction
|
||||
val Kotlin_ObjCExport_GetAssociatedObject by lazyRtFunction
|
||||
val Kotlin_ObjCExport_AbstractMethodCalled by lazyRtFunction
|
||||
|
||||
+40
-29
@@ -560,35 +560,7 @@ private fun ObjCExportCodeGenerator.emitSpecialClassesConvertions() {
|
||||
constPointer(context.llvm.Kotlin_ObjCExport_CreateNSStringFromKString)
|
||||
)
|
||||
|
||||
setObjCExportTypeInfo(
|
||||
symbols.list.owner,
|
||||
constPointer(context.llvm.Kotlin_Interop_CreateNSArrayFromKList)
|
||||
)
|
||||
|
||||
setObjCExportTypeInfo(
|
||||
symbols.mutableList.owner,
|
||||
constPointer(context.llvm.Kotlin_Interop_CreateNSMutableArrayFromKList)
|
||||
)
|
||||
|
||||
setObjCExportTypeInfo(
|
||||
symbols.set.owner,
|
||||
constPointer(context.llvm.Kotlin_Interop_CreateNSSetFromKSet)
|
||||
)
|
||||
|
||||
setObjCExportTypeInfo(
|
||||
symbols.mutableSet.owner,
|
||||
constPointer(context.llvm.Kotlin_Interop_CreateKotlinMutableSetFromKSet)
|
||||
)
|
||||
|
||||
setObjCExportTypeInfo(
|
||||
symbols.map.owner,
|
||||
constPointer(context.llvm.Kotlin_Interop_CreateNSDictionaryFromKMap)
|
||||
)
|
||||
|
||||
setObjCExportTypeInfo(
|
||||
symbols.mutableMap.owner,
|
||||
constPointer(context.llvm.Kotlin_Interop_CreateKotlinMutableDictonaryFromKMap)
|
||||
)
|
||||
emitCollectionConverters()
|
||||
|
||||
emitBoxConverters()
|
||||
|
||||
@@ -597,6 +569,45 @@ private fun ObjCExportCodeGenerator.emitSpecialClassesConvertions() {
|
||||
emitBlockToKotlinFunctionConverters()
|
||||
}
|
||||
|
||||
private fun ObjCExportCodeGenerator.emitCollectionConverters() {
|
||||
|
||||
fun importConverter(name: String): ConstPointer = constPointer(context.llvm.externalFunction(
|
||||
name,
|
||||
kotlinToObjCFunctionType,
|
||||
CurrentKlibModuleOrigin
|
||||
))
|
||||
|
||||
setObjCExportTypeInfo(
|
||||
symbols.list.owner,
|
||||
importConverter("Kotlin_Interop_CreateNSArrayFromKList")
|
||||
)
|
||||
|
||||
setObjCExportTypeInfo(
|
||||
symbols.mutableList.owner,
|
||||
importConverter("Kotlin_Interop_CreateNSMutableArrayFromKList")
|
||||
)
|
||||
|
||||
setObjCExportTypeInfo(
|
||||
symbols.set.owner,
|
||||
importConverter("Kotlin_Interop_CreateNSSetFromKSet")
|
||||
)
|
||||
|
||||
setObjCExportTypeInfo(
|
||||
symbols.mutableSet.owner,
|
||||
importConverter("Kotlin_Interop_CreateKotlinMutableSetFromKSet")
|
||||
)
|
||||
|
||||
setObjCExportTypeInfo(
|
||||
symbols.map.owner,
|
||||
importConverter("Kotlin_Interop_CreateNSDictionaryFromKMap")
|
||||
)
|
||||
|
||||
setObjCExportTypeInfo(
|
||||
symbols.mutableMap.owner,
|
||||
importConverter("Kotlin_Interop_CreateKotlinMutableDictonaryFromKMap")
|
||||
)
|
||||
}
|
||||
|
||||
private inline fun ObjCExportCodeGenerator.generateObjCImpBy(
|
||||
methodBridge: MethodBridge,
|
||||
genBody: FunctionGenerationContext.() -> Unit
|
||||
|
||||
@@ -22,6 +22,7 @@ targetList.each { targetName ->
|
||||
dependsOn "${targetName}Strict"
|
||||
dependsOn "${targetName}Relaxed"
|
||||
dependsOn "${targetName}ProfileRuntime"
|
||||
dependsOn "${targetName}ObjC"
|
||||
target targetName
|
||||
includeRuntime(delegate)
|
||||
linkerArgs project.file("../common/build/$targetName/hash.bc").path
|
||||
@@ -67,6 +68,13 @@ targetList.each { targetName ->
|
||||
srcRoot file('src/profile_runtime')
|
||||
target targetName
|
||||
}
|
||||
|
||||
task ("${targetName}ObjC", type: CompileCppToBitcode) {
|
||||
name "objc"
|
||||
srcRoot file('src/objc')
|
||||
target targetName
|
||||
includeRuntime(delegate)
|
||||
}
|
||||
}
|
||||
|
||||
task hostRuntime(dependsOn: "${hostName}Runtime")
|
||||
|
||||
Reference in New Issue
Block a user