Support for macos_arm64 target in backend
(cherry picked from commit 82775e93c1389f21f9be97bd0edfd16dd50300ea)
This commit is contained in:
committed by
Vasily Levchenko
parent
616beedbcf
commit
fddf28ac47
+2
-1
@@ -18,7 +18,8 @@ internal fun Type.isStret(target: KonanTarget): Boolean {
|
||||
val unwrappedType = this.unwrapTypedefs()
|
||||
val abiInfo: ObjCAbiInfo = when (target) {
|
||||
KonanTarget.IOS_ARM64,
|
||||
KonanTarget.TVOS_ARM64 -> DarwinArm64AbiInfo()
|
||||
KonanTarget.TVOS_ARM64,
|
||||
KonanTarget.MACOS_ARM64 -> DarwinArm64AbiInfo()
|
||||
|
||||
KonanTarget.IOS_X64,
|
||||
KonanTarget.MACOS_X64,
|
||||
|
||||
+7
-1
@@ -52,13 +52,19 @@ internal class BitcodeCompiler(val context: Context) {
|
||||
|
||||
val profilingFlags = llvmProfilingFlags().map { listOf("-mllvm", it) }.flatten()
|
||||
|
||||
// LLVM we use does not have support for arm64_32.
|
||||
// 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 flags = overrideClangOptions.takeIf(List<String>::isNotEmpty)
|
||||
|
||||
+2
@@ -1671,6 +1671,7 @@ private fun Context.is64BitNSInteger(): Boolean = when (val target = this.config
|
||||
KonanTarget.TVOS_ARM64,
|
||||
KonanTarget.TVOS_X64,
|
||||
KonanTarget.MACOS_X64,
|
||||
KonanTarget.MACOS_ARM64,
|
||||
KonanTarget.WATCHOS_X64 -> true
|
||||
KonanTarget.WATCHOS_ARM64,
|
||||
KonanTarget.WATCHOS_ARM32,
|
||||
@@ -1702,6 +1703,7 @@ internal fun Context.is64BitLong(): Boolean = when (this.config.target) {
|
||||
KonanTarget.MINGW_X64,
|
||||
KonanTarget.LINUX_X64,
|
||||
KonanTarget.MACOS_X64,
|
||||
KonanTarget.MACOS_ARM64,
|
||||
KonanTarget.WATCHOS_X64 -> true
|
||||
KonanTarget.WATCHOS_ARM64,
|
||||
KonanTarget.WATCHOS_ARM32,
|
||||
|
||||
+2
-3
@@ -136,8 +136,7 @@ internal class ObjCExport(val context: Context, symbolTable: SymbolTable) {
|
||||
modules.child("module.modulemap").writeBytes(moduleMap.toByteArray())
|
||||
|
||||
emitInfoPlist(frameworkContents, frameworkName)
|
||||
|
||||
if (target == KonanTarget.MACOS_X64) {
|
||||
if (target.family == Family.OSX) {
|
||||
framework.child("Versions/Current").createAsSymlink("A")
|
||||
for (child in listOf(frameworkName, "Headers", "Modules", "Resources")) {
|
||||
framework.child(child).createAsSymlink("Versions/Current/$child")
|
||||
@@ -163,7 +162,7 @@ internal class ObjCExport(val context: Context, symbolTable: SymbolTable) {
|
||||
KonanTarget.IOS_X64 -> "iPhoneSimulator"
|
||||
KonanTarget.TVOS_ARM64 -> "AppleTVOS"
|
||||
KonanTarget.TVOS_X64 -> "AppleTVSimulator"
|
||||
KonanTarget.MACOS_X64 -> "MacOSX"
|
||||
KonanTarget.MACOS_X64, KonanTarget.MACOS_ARM64 -> "MacOSX"
|
||||
KonanTarget.WATCHOS_ARM32, KonanTarget.WATCHOS_ARM64 -> "WatchOS"
|
||||
KonanTarget.WATCHOS_X86, KonanTarget.WATCHOS_X64 -> "WatchSimulator"
|
||||
else -> error(target)
|
||||
|
||||
@@ -183,7 +183,7 @@ open class FrameworkTest : DefaultTask(), KonanTestExecutable {
|
||||
KonanTarget.IOS_ARM32, KonanTarget.IOS_ARM64 -> "iphoneos"
|
||||
KonanTarget.TVOS_X64 -> "appletvsimulator"
|
||||
KonanTarget.TVOS_ARM64 -> "appletvos"
|
||||
KonanTarget.MACOS_X64 -> "macosx"
|
||||
KonanTarget.MACOS_X64, KonanTarget.MACOS_ARM64 -> "macosx"
|
||||
KonanTarget.WATCHOS_ARM64 -> "watchos"
|
||||
KonanTarget.WATCHOS_X64, KonanTarget.WATCHOS_X86 -> "watchsimulator"
|
||||
else -> throw IllegalStateException("Test target $target is not supported")
|
||||
@@ -213,6 +213,7 @@ open class FrameworkTest : DefaultTask(), KonanTestExecutable {
|
||||
KonanTarget.TVOS_X64 -> "SIMCTL_CHILD_DYLD_LIBRARY_PATH"
|
||||
else -> "DYLD_LIBRARY_PATH"
|
||||
}
|
||||
// TODO: macos_arm64?
|
||||
return if (newMacos && target == KonanTarget.MACOS_X64) emptyMap() else mapOf(
|
||||
dyldLibraryPathKey to getSwiftLibsPathForTestTarget()
|
||||
)
|
||||
@@ -253,7 +254,8 @@ open class FrameworkTest : DefaultTask(), KonanTestExecutable {
|
||||
KonanTarget.WATCHOS_X64 -> return // bitcode-build-tool doesn't support simulators.
|
||||
KonanTarget.IOS_ARM64,
|
||||
KonanTarget.IOS_ARM32 -> Xcode.current.iphoneosSdk
|
||||
KonanTarget.MACOS_X64 -> Xcode.current.macosxSdk
|
||||
KonanTarget.MACOS_X64,
|
||||
KonanTarget.MACOS_ARM64 -> Xcode.current.macosxSdk
|
||||
KonanTarget.TVOS_ARM64 -> Xcode.current.appletvosSdk
|
||||
KonanTarget.WATCHOS_ARM32,
|
||||
KonanTarget.WATCHOS_ARM64 -> Xcode.current.watchosSdk
|
||||
|
||||
@@ -244,6 +244,7 @@ fun compileSwift(project: Project, target: KonanTarget, sources: List<String>, o
|
||||
KonanTarget.TVOS_X64 -> "x86_64-apple-tvos" + configs.osVersionMin
|
||||
KonanTarget.TVOS_ARM64 -> "arm64-apple-tvos" + configs.osVersionMin
|
||||
KonanTarget.MACOS_X64 -> "x86_64-apple-macosx" + configs.osVersionMin
|
||||
KonanTarget.MACOS_ARM64 -> "arm64-apple-macos" + configs.osVersionMin
|
||||
KonanTarget.WATCHOS_X86 -> "i386-apple-watchos" + configs.osVersionMin
|
||||
KonanTarget.WATCHOS_X64 -> "x86_64-apple-watchos" + configs.osVersionMin
|
||||
else -> throw IllegalStateException("Test target $target is not supported")
|
||||
|
||||
@@ -111,6 +111,34 @@ target-toolchain-xcode_12_2-macos_x64.default = \
|
||||
xcode-addon-xcode_12_2-macos_x64.default = \
|
||||
remote:internal
|
||||
|
||||
# macOS Apple Silicon
|
||||
targetToolchain.macos_x64-macos_arm64 = target-toolchain-xcode_12_2-macos_x64
|
||||
arch.macos_arm64 = arm64
|
||||
targetSysRoot.macos_arm64 = target-sysroot-xcode_12_2-macos_x64
|
||||
# TODO: Check Clang behaviour.
|
||||
targetCpu.macos_arm64 = cyclone
|
||||
clangFlags.macos_arm64 = -cc1 -emit-obj -disable-llvm-passes -x ir
|
||||
clangNooptFlags.macos_arm64 = -O1
|
||||
clangOptFlags.macos_arm64 = -O3
|
||||
# See clangDebugFlags.ios_arm64
|
||||
# TODO: Is it still necessary?
|
||||
clangDebugFlags.macos_arm64 = -O0 -mllvm -fast-isel=false -mllvm -global-isel=false
|
||||
|
||||
linkerKonanFlags.macos_arm64 = -lSystem -lc++ -lobjc -framework Foundation -sdk_version 11.0.1
|
||||
linkerOptimizationFlags.macos_arm64 = -dead_strip
|
||||
linkerNoDebugFlags.macos_arm64 = -S
|
||||
linkerDynamicFlags.macos_arm64 = -dylib
|
||||
|
||||
osVersionMinFlagLd.macos_arm64 = -macosx_version_min
|
||||
osVersionMinFlagClang.macos_arm64 = -mmacosx-version-min
|
||||
osVersionMin.macos_arm64 = 11.0
|
||||
runtimeDefinitions.macos_arm64 = KONAN_OSX=1 KONAN_MACOSX=1 KONAN_ARM64=1 KONAN_OBJC_INTEROP=1 \
|
||||
KONAN_CORE_SYMBOLICATION=1 KONAN_HAS_CXX11_EXCEPTION_FUNCTIONS=1
|
||||
dependencies.macos_x64-macos_arm64 = \
|
||||
libffi-3.2.1-3-darwin-macos
|
||||
|
||||
target-sysroot-xcode_12_2-macos_arm64.default = \
|
||||
remote:internal
|
||||
|
||||
# Apple's 32-bit iOS.
|
||||
targetToolchain.macos_x64-ios_arm32 = target-toolchain-xcode_12_2-macos_x64
|
||||
|
||||
@@ -33,7 +33,7 @@ class AppleConfigurablesImpl(
|
||||
|
||||
override val absoluteTargetSysRoot: String get() = when (val provider = xcodePartsProvider) {
|
||||
is XcodePartsProvider.Local -> when (target) {
|
||||
KonanTarget.MACOS_X64 -> provider.xcode.macosxSdk
|
||||
KonanTarget.MACOS_X64, KonanTarget.MACOS_ARM64 -> provider.xcode.macosxSdk
|
||||
KonanTarget.IOS_ARM32, KonanTarget.IOS_ARM64 -> provider.xcode.iphoneosSdk
|
||||
KonanTarget.IOS_X64 -> provider.xcode.iphonesimulatorSdk
|
||||
KonanTarget.TVOS_ARM64 -> provider.xcode.appletvosSdk
|
||||
|
||||
@@ -95,6 +95,14 @@ class ClangArgs(private val configurables: Configurables) : Configurables by con
|
||||
"-mmacosx-version-min=$osVersionMin"
|
||||
)
|
||||
|
||||
// Here we workaround Clang 8 limitation: macOS major version should be 10.
|
||||
// So we compile runtime with version 10.16 and then override version in BitcodeCompiler.
|
||||
// TODO: Fix with LLVM Update.
|
||||
KonanTarget.MACOS_ARM64 -> listOf(
|
||||
"-arch", "arm64",
|
||||
"-mmacosx-version-min=10.16"
|
||||
)
|
||||
|
||||
KonanTarget.IOS_ARM32 -> listOf(
|
||||
"-stdlib=libc++",
|
||||
"-arch", "armv7",
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ fun loadConfigurables(target: KonanTarget, properties: Properties, baseDir: Stri
|
||||
KonanTarget.LINUX_MIPS32, KonanTarget.LINUX_MIPSEL32 ->
|
||||
GccConfigurablesImpl(target, properties, baseDir)
|
||||
|
||||
KonanTarget.MACOS_X64,
|
||||
KonanTarget.MACOS_X64, KonanTarget.MACOS_ARM64,
|
||||
KonanTarget.IOS_ARM32, KonanTarget.IOS_ARM64, KonanTarget.IOS_X64,
|
||||
KonanTarget.TVOS_ARM64, KonanTarget.TVOS_X64,
|
||||
KonanTarget.WATCHOS_ARM64, KonanTarget.WATCHOS_ARM32,
|
||||
|
||||
Reference in New Issue
Block a user