Deal with entry points and launcher bcs for shared object generation.
This commit is contained in:
committed by
alexander-gorshenev
parent
0d0a2b4c99
commit
4236bb22fb
+5
-1
@@ -33,8 +33,12 @@ internal fun produceOutput(context: Context) {
|
||||
val output = "$program.kt.bc"
|
||||
context.bitcodeFileName = output
|
||||
|
||||
val nativeLibraries =
|
||||
context.config.nativeLibraries +
|
||||
context.config.defaultNativeLibraries
|
||||
|
||||
PhaseManager(context).phase(KonanPhase.BITCODE_LINKER) {
|
||||
for (library in context.config.nativeLibraries) {
|
||||
for (library in nativeLibraries) {
|
||||
val libraryModule = parseBitcodeFile(library)
|
||||
val failed = LLVMLinkModules2(llvmModule, libraryModule)
|
||||
if (failed != 0) {
|
||||
|
||||
+1
@@ -46,6 +46,7 @@ class Distribution(val targetManager: TargetManager,
|
||||
|
||||
val klib = "$konanHome/klib"
|
||||
val stdlib = "$klib/common/stdlib"
|
||||
val defaultNatives = "$konanHome/konan/targets/${targetName}/native"
|
||||
val runtime = runtimeFileOverride ?: "$stdlib/targets/${targetName}/native/runtime.bc"
|
||||
|
||||
val dependenciesDir = DependencyProcessor.defaultDependenciesRoot.absolutePath
|
||||
|
||||
+5
@@ -103,6 +103,11 @@ class KonanConfig(val project: Project, val configuration: CompilerConfiguration
|
||||
|
||||
private val loadedDescriptors = loadLibMetadata()
|
||||
|
||||
internal val defaultNativeLibraries =
|
||||
if (produce == CompilerOutputKind.PROGRAM)
|
||||
File(distribution.defaultNatives).listFiles.map { it.absolutePath }
|
||||
else emptyList()
|
||||
|
||||
internal val nativeLibraries: List<String> =
|
||||
configuration.getList(KonanConfigKeys.NATIVE_LIBRARY_FILES)
|
||||
|
||||
|
||||
+1
-2
@@ -37,8 +37,7 @@ import org.jetbrains.kotlin.utils.alwaysTrue
|
||||
internal fun findMainEntryPoint(context: Context): FunctionDescriptor? {
|
||||
|
||||
val config = context.config.configuration
|
||||
if (config.get(KonanConfigKeys.PRODUCE) != PROGRAM &&
|
||||
config.get(KonanConfigKeys.PRODUCE) != DYNAMIC) return null
|
||||
if (config.get(KonanConfigKeys.PRODUCE) != PROGRAM) return null
|
||||
|
||||
val entryPoint = FqName(config.get(KonanConfigKeys.ENTRY) ?:
|
||||
if (context.shouldGenerateTestRunner()) testEntryName else defaultEntryName)
|
||||
|
||||
+7
-2
@@ -259,16 +259,21 @@ targetList.each { target ->
|
||||
destinationDir distDir
|
||||
|
||||
from(project(':runtime').file("build/$target")) {
|
||||
include("*.bc")
|
||||
include("runtime.bc")
|
||||
into("$stdlib/targets/$target/native")
|
||||
}
|
||||
from(project(':runtime').file("build/$target")) {
|
||||
include("*.bc")
|
||||
exclude("runtime.bc")
|
||||
into("konan/targets/$target/native")
|
||||
}
|
||||
from(project(':runtime').file("build/${target}Stdlib")) {
|
||||
include('**')
|
||||
into(stdlib)
|
||||
}
|
||||
from(project(':runtime').file("build/${target}Start.bc")) {
|
||||
rename("${target}Start.bc", 'start.bc')
|
||||
into("$stdlib/targets/$target/native")
|
||||
into("konan/targets/$target/native")
|
||||
}
|
||||
if (target == 'wasm32') {
|
||||
from(project(':runtime').file('src/launcher/js')) {
|
||||
|
||||
Reference in New Issue
Block a user