backend: implement '-linkerArg' to pass arguments to the linker
This commit is contained in:
committed by
SvyatoslavScherbina
parent
46fde200be
commit
7ad36ac035
@@ -60,6 +60,8 @@ class K2Native : CLICompiler<K2NativeCompilerArguments>() {
|
||||
put(LIBRARY_FILES,
|
||||
arguments.libraries.toNonNullList())
|
||||
|
||||
put(LINKER_ARGS, arguments.linkerArguments.toNonNullList())
|
||||
|
||||
put(NATIVE_LIBRARY_FILES,
|
||||
arguments.nativeLibraries.toNonNullList())
|
||||
|
||||
|
||||
@@ -28,6 +28,10 @@ public class K2NativeCompilerArguments extends CommonCompilerArguments {
|
||||
@Argument(value = "nolink", description = "Don't link, just produce a bitcode file")
|
||||
public boolean nolink;
|
||||
|
||||
@Argument(value = "linkerArg", description = "Add argument to linker")
|
||||
@ValueDescription("<arg>")
|
||||
public String[] linkerArguments;
|
||||
|
||||
@Argument(value = "nostdlib", description = "Don't link with stdlib")
|
||||
public boolean nostdlib;
|
||||
|
||||
|
||||
+2
@@ -27,6 +27,8 @@ class KonanConfigKeys {
|
||||
= CompilerConfigurationKey.create("compile the module as stdlib")
|
||||
val NOLINK: CompilerConfigurationKey<Boolean>
|
||||
= CompilerConfigurationKey.create("don't link, only produce a bitcode file ")
|
||||
val LINKER_ARGS: CompilerConfigurationKey<List<String>>
|
||||
= CompilerConfigurationKey.create("additional linker arguments")
|
||||
val TARGET: CompilerConfigurationKey<String?>
|
||||
= CompilerConfigurationKey.create("target we compile for")
|
||||
val LIST_TARGETS: CompilerConfigurationKey<Boolean>
|
||||
|
||||
+3
-1
@@ -178,7 +178,9 @@ internal class LinkStage(val context: Context) {
|
||||
fun link(objectFiles: List<ObjectFile>): ExecutableFile {
|
||||
val executable = config.get(KonanConfigKeys.EXECUTABLE_FILE)!!
|
||||
|
||||
val linkCommand = platform.linkCommand(objectFiles, executable, optimize)
|
||||
val linkCommand = platform.linkCommand(objectFiles, executable, optimize) +
|
||||
config.getNotNull(KonanConfigKeys.LINKER_ARGS)
|
||||
|
||||
runTool(*linkCommand.toTypedArray())
|
||||
|
||||
return executable
|
||||
|
||||
Reference in New Issue
Block a user