Initial support for MIPS
This commit is contained in:
committed by
ilmat192
parent
eb0415b2e5
commit
9187022721
+1
@@ -90,6 +90,7 @@ private val knownTargets = mapOf(
|
||||
"iphone_sim" to "ios_sim",
|
||||
"ios_sim" to "ios_sim",
|
||||
"raspberrypi" to "raspberrypi",
|
||||
"mips" to "mips",
|
||||
"android_arm32" to "android_arm32",
|
||||
"android_arm64" to "android_arm64",
|
||||
"mingw" to "mingw",
|
||||
|
||||
+6
-5
@@ -131,7 +131,7 @@ internal open class MacOSBasedPlatform(distribution: Distribution)
|
||||
listOf(dsymutil, "-dump-debug-map" ,executable)
|
||||
}
|
||||
|
||||
internal open class LinuxBasedPlatform(distribution: Distribution)
|
||||
internal open class LinuxBasedPlatform(val distribution: Distribution)
|
||||
: PlatformFlags(distribution.targetProperties) {
|
||||
|
||||
private val llvmLib = distribution.llvmLib
|
||||
@@ -139,7 +139,7 @@ internal open class LinuxBasedPlatform(distribution: Distribution)
|
||||
private val linker = "$targetToolchain/bin/ld.gold"
|
||||
private val pluginOptimizationFlags = propertyTargetList("pluginOptimizationFlags")
|
||||
private val specificLibs
|
||||
= propertyTargetList("abiSpecificLibraries").map{it -> "-L${targetSysRoot}/$it"}
|
||||
= propertyTargetList("abiSpecificLibraries").map { "-L${targetSysRoot}/$it" }
|
||||
|
||||
override fun filterStaticLibraries(binaries: List<String>)
|
||||
= binaries.filter { it.isUnixStaticLib }
|
||||
@@ -148,13 +148,14 @@ internal open class LinuxBasedPlatform(distribution: Distribution)
|
||||
// TODO: Can we extract more to the konan.properties?
|
||||
return mutableListOf(linker).apply {
|
||||
addAll(listOf("--sysroot=${targetSysRoot}",
|
||||
"-export-dynamic", "-z", "relro", "--hash-style=gnu",
|
||||
"-export-dynamic", "-z", "relro",
|
||||
"--build-id", "--eh-frame-hdr", // "-m", "elf_x86_64",
|
||||
"-dynamic-linker", propertyTargetString("dynamicLinker"),
|
||||
"-o", executable,
|
||||
"${targetSysRoot}/usr/lib64/crt1.o",
|
||||
"${targetSysRoot}/usr/lib64/crti.o", "${libGcc}/crtbegin.o",
|
||||
"-L${llvmLib}", "-L${libGcc}"))
|
||||
if (distribution.target != KonanTarget.MIPS) add("--hash-style=gnu") // MIPS doesn't support hash-style=gnu
|
||||
addAll(specificLibs)
|
||||
addAll(listOf("-L${targetSysRoot}/../lib", "-L${targetSysRoot}/lib", "-L${targetSysRoot}/usr/lib"))
|
||||
if (optimize) addAll(listOf("-plugin", "$llvmLib/LLVMgold.so") + pluginOptimizationFlags)
|
||||
@@ -217,7 +218,7 @@ internal class LinkStage(val context: Context) {
|
||||
private val distribution = context.config.distribution
|
||||
|
||||
private val platform = when (target) {
|
||||
KonanTarget.LINUX, KonanTarget.RASPBERRYPI ->
|
||||
KonanTarget.LINUX, KonanTarget.RASPBERRYPI, KonanTarget.MIPS ->
|
||||
LinuxBasedPlatform(distribution)
|
||||
KonanTarget.MACBOOK, KonanTarget.IPHONE, KonanTarget.IPHONE_SIM ->
|
||||
MacOSBasedPlatform(distribution)
|
||||
@@ -395,7 +396,7 @@ internal class LinkStage(val context: Context) {
|
||||
}
|
||||
outputStream.close()
|
||||
}
|
||||
val exitCode = process.waitFor()
|
||||
val exitCode = process.waitFor()
|
||||
return exitCode
|
||||
}
|
||||
|
||||
|
||||
@@ -148,6 +148,30 @@ abiSpecificLibraries.raspberrypi = \
|
||||
lib/arm-linux-gnueabihf \
|
||||
usr/lib/arm-linux-gnueabihf
|
||||
|
||||
# MIPS
|
||||
targetToolchain.linux-mips = target-gcc-toolchain-3-linux-x86-64/x86_64-unknown-linux-gnu
|
||||
dependencies.linux-mips = \
|
||||
clang-llvm-3.9.0-linux-x86-64 \
|
||||
target-gcc-toolchain-3-linux-x86-64 \
|
||||
target-sysroot-mips \
|
||||
libffi-3.2.1-2-linux-x86-64 \
|
||||
libffi-3.2.1-linux-mips
|
||||
quadruple.mips = mips-unknown-linux-gnu
|
||||
entrySelector.mips = --defsym main=Konan_main
|
||||
linkerOptimizationFlags.mips = --gc-sections
|
||||
targetSysRoot.mips = target-sysroot-mips
|
||||
# We could reuse host toolchain here.
|
||||
libffiDir.mips = libffi-3.2.1-linux-mips
|
||||
linkerKonanFlags.mips = -Bstatic -lstdc++ -Bdynamic -ldl -lm -lpthread
|
||||
# targetSysroot-relative.
|
||||
libGcc.mips = lib/gcc/mips-unknown-linux-gnu/4.9.4
|
||||
llvmLtoFlags.mips =
|
||||
llvmLtoOptFlags.mips = -O3 -function-sections
|
||||
llvmLtoNooptFlags.mips = -O1
|
||||
dynamicLinker.mips = /lib/ld.so.1
|
||||
# targetSysRoot relative
|
||||
abiSpecificLibraries.mips =
|
||||
|
||||
# Android ARM32, based on NDK for android-21.
|
||||
targetToolchain.osx-android_arm32 = target-toolchain-21-osx-android_arm32
|
||||
# TODO: split dependencies to host-dependent and host-independent parts.
|
||||
|
||||
@@ -2111,6 +2111,7 @@ task interop3(type: RunInteropKonanTest) {
|
||||
// There are plans to provide a solution and turn this
|
||||
// test back on.
|
||||
disabled = (project.testTarget == 'raspberrypi') ||
|
||||
(project.testTarget == 'mips') ||
|
||||
(project.testTarget == 'wasm32') // No interop for wasm yet.
|
||||
goldValue = "8 9 12 13 14 \n"
|
||||
source = "interop/basics/3.kt"
|
||||
|
||||
@@ -38,6 +38,13 @@ class ClangTarget(val target: KonanTarget, konanProperties: KonanProperties) {
|
||||
"-I$sysRoot/usr/include/c++/4.8.3",
|
||||
"-I$sysRoot/usr/include/c++/4.8.3/arm-linux-gnueabihf")
|
||||
|
||||
KonanTarget.MIPS ->
|
||||
listOf("-target", targetArg!!,
|
||||
"-DUSE_GCC_UNWIND=1", "-DUSE_ELF_SYMBOLS=1", "-DELFSIZE=32",
|
||||
"--sysroot=$sysRoot",
|
||||
"-I$sysRoot/usr/include/c++/4.9.4",
|
||||
"-I$sysRoot/usr/include/c++/4.9.4/mips-unknown-linux-gnu")
|
||||
|
||||
KonanTarget.MINGW ->
|
||||
listOf("-target", targetArg!!, "--sysroot=$sysRoot",
|
||||
"-DUSE_GCC_UNWIND=1", "-DUSE_PE_COFF_SYMBOLS=1", "-DKONAN_WINDOWS=1")
|
||||
|
||||
@@ -33,6 +33,7 @@ enum class KonanTarget(val targetSuffix: String, val programSuffix: String, var
|
||||
MINGW("mingw", "exe"),
|
||||
MACBOOK("osx", "kexe"),
|
||||
RASPBERRYPI("raspberrypi", "kexe"),
|
||||
MIPS("mips", "kexe"),
|
||||
WASM32("wasm32", "wasm");
|
||||
|
||||
val userName get() = name.toLowerCase()
|
||||
@@ -44,6 +45,7 @@ enum class KonanTarget(val targetSuffix: String, val programSuffix: String, var
|
||||
MACBOOK -> Platform.OSX
|
||||
RASPBERRYPI -> Platform.LINUX
|
||||
LINUX -> Platform.LINUX
|
||||
MIPS -> Platform.LINUX
|
||||
MINGW -> Platform.WINDOWS
|
||||
WASM32 -> Platform.WASM
|
||||
}
|
||||
@@ -162,6 +164,7 @@ class TargetManager(val userRequest: String? = null) {
|
||||
KonanTarget.LINUX -> {
|
||||
KonanTarget.LINUX.enabled = true
|
||||
KonanTarget.RASPBERRYPI.enabled = true
|
||||
KonanTarget.MIPS.enabled = true
|
||||
KonanTarget.ANDROID_ARM32.enabled = true
|
||||
KonanTarget.ANDROID_ARM64.enabled = true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user