Use TargetTriple in backend to simplify code.
This commit is contained in:
committed by
TeamCityServer
parent
f94e8f95d1
commit
15dcb36f47
+5
-15
@@ -50,25 +50,15 @@ internal class BitcodeCompiler(val context: Context) {
|
||||
private fun clang(configurables: ClangFlags, file: BitcodeFile): ObjectFile {
|
||||
val objectFile = temporary("result", ".o")
|
||||
|
||||
// TODO: fix with LLVM update.
|
||||
val targetTriple = when (context.config.target) {
|
||||
// LLVM we use does not have support for arm64_32.
|
||||
KonanTarget.WATCHOS_ARM64 -> {
|
||||
require(configurables is AppleConfigurables)
|
||||
"arm64_32-apple-watchos${configurables.osVersionMin}"
|
||||
}
|
||||
// Runtime generates bitcode for mythical macos 10.16 because of old Clang.
|
||||
// Let's fix it.
|
||||
KonanTarget.MACOS_ARM64 -> {
|
||||
require(configurables is AppleConfigurables)
|
||||
"arm64-apple-macos${configurables.osVersionMin}"
|
||||
}
|
||||
else -> context.llvm.targetTriple
|
||||
val targetTriple = if (configurables is AppleConfigurables) {
|
||||
platform.targetTriple.withOSVersion(configurables.osVersionMin)
|
||||
} else {
|
||||
platform.targetTriple
|
||||
}
|
||||
val flags = overrideClangOptions.takeIf(List<String>::isNotEmpty)
|
||||
?: mutableListOf<String>().apply {
|
||||
addNonEmpty(configurables.clangFlags)
|
||||
addNonEmpty(listOf("-triple", targetTriple))
|
||||
addNonEmpty(listOf("-triple", targetTriple.toString()))
|
||||
if (configurables is ZephyrConfigurables) {
|
||||
addNonEmpty(configurables.constructClangCC1Args())
|
||||
}
|
||||
|
||||
+3
-11
@@ -145,6 +145,8 @@ internal class ObjCExport(val context: Context, symbolTable: SymbolTable) {
|
||||
}
|
||||
|
||||
private fun emitInfoPlist(frameworkContents: File, name: String) {
|
||||
val properties = context.config.platform.configurables as AppleConfigurables
|
||||
|
||||
val directory = when (target.family) {
|
||||
Family.IOS,
|
||||
Family.WATCHOS,
|
||||
@@ -157,17 +159,7 @@ internal class ObjCExport(val context: Context, symbolTable: SymbolTable) {
|
||||
val pkg = guessMainPackage() // TODO: consider showing warning if it is root.
|
||||
val bundleId = pkg.child(Name.identifier(name)).asString()
|
||||
|
||||
val platform = when (target) {
|
||||
KonanTarget.IOS_ARM32, KonanTarget.IOS_ARM64 -> "iPhoneOS"
|
||||
KonanTarget.IOS_X64 -> "iPhoneSimulator"
|
||||
KonanTarget.TVOS_ARM64 -> "AppleTVOS"
|
||||
KonanTarget.TVOS_X64 -> "AppleTVSimulator"
|
||||
KonanTarget.MACOS_X64, KonanTarget.MACOS_ARM64 -> "MacOSX"
|
||||
KonanTarget.WATCHOS_ARM32, KonanTarget.WATCHOS_ARM64 -> "WatchOS"
|
||||
KonanTarget.WATCHOS_X86, KonanTarget.WATCHOS_X64 -> "WatchSimulator"
|
||||
else -> error(target)
|
||||
}
|
||||
val properties = context.config.platform.configurables as AppleConfigurables
|
||||
val platform = properties.platformName()
|
||||
val minimumOsVersion = properties.osVersionMin
|
||||
|
||||
val contents = StringBuilder()
|
||||
|
||||
@@ -171,10 +171,6 @@ class MacOSBasedLinker(targetProperties: AppleConfigurables)
|
||||
private val strip = "$absoluteTargetToolchain/usr/bin/strip"
|
||||
private val dsymutil = "$absoluteTargetToolchain/usr/bin/dsymutil"
|
||||
|
||||
private val KonanTarget.isSimulator: Boolean
|
||||
get() = this == KonanTarget.TVOS_X64 || this == KonanTarget.IOS_X64 ||
|
||||
this == KonanTarget.WATCHOS_X86 || this == KonanTarget.WATCHOS_X64
|
||||
|
||||
private val compilerRtDir: String? by lazy {
|
||||
val dir = File("$absoluteTargetToolchain/usr/lib/clang/").listFiles.firstOrNull()?.absolutePath
|
||||
if (dir != null) "$dir/lib/darwin/" else null
|
||||
@@ -188,7 +184,7 @@ class MacOSBasedLinker(targetProperties: AppleConfigurables)
|
||||
Family.OSX -> "osx"
|
||||
else -> error("Target $target is unsupported")
|
||||
}
|
||||
val suffix = if (libraryName.isNotEmpty() && target.isSimulator) {
|
||||
val suffix = if (libraryName.isNotEmpty() && targetTriple.isSimulator) {
|
||||
"sim"
|
||||
} else {
|
||||
""
|
||||
|
||||
Reference in New Issue
Block a user