Move linker selection to konan.properties
This commit is contained in:
committed by
Stanislav Erokhin
parent
e8e705bf68
commit
0f733b6baf
@@ -403,6 +403,14 @@ linkerKonanFlags.linux_x64 = -Bstatic -lstdc++ -Bdynamic -ldl -lm -lpthread \
|
||||
linkerOptimizationFlags.linux_x64 =
|
||||
linkerNoDebugFlags.linux_x64 = -S
|
||||
linkerDynamicFlags.linux_x64 = -shared
|
||||
|
||||
linker.linux_x64 = $targetToolchain.linux_x64/bin/ld.gold
|
||||
linkerHostSpecificFlags.linux_x64-linux_x64 =
|
||||
linker.mingw_x64-linux_x64 = $targetToolchain.mingw_x64-linux_x64/bin/ld.gold
|
||||
linkerHostSpecificFlags.mingw_x64-linux_x64 =
|
||||
linker.macos_x64-linux_x64 = $targetToolchain.macos_x64-linux_x64/bin/ld.lld
|
||||
linkerHostSpecificFlags.macos_x64-linux_x64 = --no-threads
|
||||
|
||||
dynamicLinker.linux_x64 = /lib64/ld-linux-x86-64.so.2
|
||||
# targetSysRoot relative
|
||||
abiSpecificLibraries.linux_x64 = lib usr/lib ../lib64 lib64 usr/lib64
|
||||
@@ -450,6 +458,13 @@ clangOptFlags.linux_arm32_hfp = -O3 -ffunction-sections
|
||||
clangDebugFlags.linux_arm32_hfp = -O0
|
||||
dynamicLibraryRelocationMode.linux_arm32_hfp = pic
|
||||
staticLibraryRelocationMode.linux_arm32_hfp = pic
|
||||
|
||||
linker.linux_x64-linux_arm32_hfp = $targetToolchain.linux_x64-linux_arm32_hfp/bin/ld
|
||||
linkerHostSpecificFlags.linux_x64-linux_arm32_hfp =
|
||||
linker.mingw_x64-linux_arm32_hfp = $targetToolchain.mingw_x64-linux_arm32_hfp/bin/ld
|
||||
linkerHostSpecificFlags.mingw_x64-linux_arm32_hfp =
|
||||
linker.macos_x64-linux_arm32_hfp = $targetToolchain.macos_x64-linux_arm32_hfp/bin/ld.lld
|
||||
linkerHostSpecificFlags.macos_x64-linux_arm32_hfp = --no-threads
|
||||
dynamicLinker.linux_arm32_hfp = /lib/ld-linux-armhf.so.3
|
||||
# targetSysRoot relative
|
||||
abiSpecificLibraries.linux_arm32_hfp = lib usr/lib
|
||||
@@ -495,6 +510,13 @@ clangOptFlags.linux_arm64 = -O3 -ffunction-sections
|
||||
clangDebugFlags.linux_arm64 = -O0
|
||||
dynamicLibraryRelocationMode.linux_arm64 = pic
|
||||
staticLibraryRelocationMode.linux_arm64 = pic
|
||||
|
||||
linker.linux_x64-linux_arm64 = $targetToolchain.linux_x64-linux_arm64/bin/ld.gold
|
||||
linkerHostSpecificFlags.linux_x64-linux_arm64 =
|
||||
linker.mingw_x64-linux_arm64 = $targetToolchain.mingw_x64-linux_arm64/bin/ld.gold
|
||||
linkerHostSpecificFlags.mingw_x64-linux_arm64 =
|
||||
linker.macos_x64-linux_arm64 = $targetToolchain.macos_x64-linux_arm64/bin/ld.lld
|
||||
linkerHostSpecificFlags.macos_x64-linux_arm64 = --no-threads
|
||||
dynamicLinker.linux_arm64 = /lib/ld-linux-aarch64.so.1
|
||||
# targetSysRoot relative
|
||||
abiSpecificLibraries.linux_arm64 = lib usr/lib
|
||||
@@ -530,6 +552,9 @@ clangOptFlags.linux_mips32 = -O3 -ffunction-sections
|
||||
clangDebugFlags.linux_mips32 = -O0
|
||||
dynamicLibraryRelocationMode.linux_mips32 = pic
|
||||
staticLibraryRelocationMode.linux_mips32 = pic
|
||||
|
||||
linker.linux_x64-linux_mips32 = $targetToolchain.linux_x64-linux_mips32/bin/ld
|
||||
linkerHostSpecificFlags.linux_x64-linux_mips32 =
|
||||
dynamicLinker.linux_mips32 = /lib/ld.so.1
|
||||
# targetSysRoot relative
|
||||
abiSpecificLibraries.linux_mips32 = lib usr/lib
|
||||
@@ -566,6 +591,9 @@ clangOptFlags.linux_mipsel32 = -O3 -ffunction-sections
|
||||
clangDebugFlags.linux_mipsel32 = -O0
|
||||
dynamicLibraryRelocationMode.linux_mipsel32 = pic
|
||||
staticLibraryRelocationMode.linux_mipsel32 = pic
|
||||
|
||||
linker.linux_x64-linux_mipsel32 = $targetToolchain.linux_x64-linux_mipsel32/bin/ld
|
||||
linkerHostSpecificFlags.linux_x64-linux_mipsel32 =
|
||||
dynamicLinker.linux_mipsel32 = /lib/ld.so.1
|
||||
# targetSysRoot relative
|
||||
abiSpecificLibraries.linux_mipsel32 = lib usr/lib
|
||||
|
||||
+5
@@ -112,6 +112,11 @@ interface GccConfigurables : TargetableConfigurables, ClangFlags {
|
||||
val dynamicLinker get() = targetString("dynamicLinker")!!
|
||||
val abiSpecificLibraries get() = targetList("abiSpecificLibraries")
|
||||
val crtFilesLocation get() = targetString("crtFilesLocation")!!
|
||||
|
||||
val linker get() = hostTargetString("linker")
|
||||
val linkerHostSpecificFlags get() = hostTargetList("linkerHostSpecificFlags")
|
||||
val absoluteLinker get() = absolute(linker)
|
||||
|
||||
val linkerGccFlags get() = targetList("linkerGccFlags")
|
||||
}
|
||||
|
||||
|
||||
@@ -337,17 +337,11 @@ class GccBasedLinker(targetProperties: GccConfigurables)
|
||||
needsProfileLibrary: Boolean, mimallocEnabled: Boolean): List<Command> {
|
||||
if (kind == LinkerOutputKind.STATIC_LIBRARY)
|
||||
return staticGnuArCommands(ar, executable, objectFiles, libraries)
|
||||
// TODO: Control via properties.
|
||||
val (linker, linkerSpecificFlags) = when {
|
||||
HostManager.hostIsMac -> "$absoluteLlvmHome/bin/ld.lld" to listOf("--no-threads")
|
||||
else -> "$absoluteTargetToolchain/bin/ld.gold" to emptyList()
|
||||
}
|
||||
|
||||
val isMips = target == KonanTarget.LINUX_MIPS32 || target == KonanTarget.LINUX_MIPSEL32
|
||||
val dynamic = kind == LinkerOutputKind.DYNAMIC_LIBRARY
|
||||
val crtPrefix = "$absoluteTargetSysRoot/$crtFilesLocation"
|
||||
// TODO: Can we extract more to the konan.configurables?
|
||||
return listOf(Command(linker).apply {
|
||||
return listOf(Command(absoluteLinker).apply {
|
||||
+"--sysroot=${absoluteTargetSysRoot}"
|
||||
+"-export-dynamic"
|
||||
+"-z"
|
||||
@@ -355,8 +349,8 @@ class GccBasedLinker(targetProperties: GccConfigurables)
|
||||
+"--build-id"
|
||||
+"--eh-frame-hdr"
|
||||
+"-dynamic-linker"
|
||||
linkerSpecificFlags.forEach { +it }
|
||||
+dynamicLinker
|
||||
linkerHostSpecificFlags.forEach { +it }
|
||||
+"-o"
|
||||
+executable
|
||||
if (!dynamic) +"$crtPrefix/crt1.o"
|
||||
|
||||
Reference in New Issue
Block a user