backend: implement '-nativelibrary' command line argument

This commit is contained in:
Svyatoslav Scherbina
2017-02-03 15:10:10 +07:00
committed by SvyatoslavScherbina
parent cf3b95fb3d
commit 97cd2b4d5f
5 changed files with 13 additions and 1 deletions
@@ -62,6 +62,9 @@ class K2Native : CLICompiler<K2NativeCompilerArguments>() {
put(LIBRARY_FILES,
arguments.libraries.toNonNullList())
put(NATIVE_LIBRARY_FILES,
arguments.nativeLibraries.toNonNullList())
// TODO: Collect all the explicit file names into an object
// and teach the compiler to work with temporaries and -save-temps.
val bitcodeFile = if (arguments.nolink) {
@@ -21,6 +21,10 @@ public class K2NativeCompilerArguments extends CommonCompilerArguments {
@ValueDescription("<path>")
public String[] libraries;
@Argument(value = "nativelibrary", alias = "nl", description = "Link with the native library")
@ValueDescription("<path>")
public String[] nativeLibraries;
@Argument(value = "nolink", description = "Don't link, just produce a bitcode file")
public boolean nolink;
@@ -29,6 +29,9 @@ class KonanConfig(val project: Project, val configuration: CompilerConfiguration
private val loadedDescriptors = loadLibMetadata(libraries)
internal val librariesToLink: List<String>
get() = libraries + configuration.getList(KonanConfigKeys.NATIVE_LIBRARY_FILES)
val moduleId: String
get() = configuration.getNotNull(CommonConfigurationKeys.MODULE_NAME)
@@ -7,6 +7,8 @@ class KonanConfigKeys {
companion object {
val LIBRARY_FILES: CompilerConfigurationKey<List<String>>
= CompilerConfigurationKey.create("library file paths")
val NATIVE_LIBRARY_FILES: CompilerConfigurationKey<List<String>>
= CompilerConfigurationKey.create("native library file paths")
val BITCODE_FILE: CompilerConfigurationKey<String>
= CompilerConfigurationKey.create("emitted bitcode file path")
val EXECUTABLE_FILE: CompilerConfigurationKey<String>
@@ -144,7 +144,7 @@ internal class LinkStage(val context: Context) {
val optimize = config.get(KonanConfigKeys.OPTIMIZATION) ?: false
val emitted = config.get(KonanConfigKeys.BITCODE_FILE)!!
val nostdlib = config.get(KonanConfigKeys.NOSTDLIB) ?: false
val libraries = context.config.libraries
val libraries = context.config.librariesToLink
fun llvmLto(files: List<BitcodeFile>): ObjectFile {
val tmpCombined = File.createTempFile("combined", ".o")