-
Notifications
You must be signed in to change notification settings - Fork 564
Conversation
contents.append(when (target.family) { | ||
Family.IOS -> """ | ||
| <key>MinimumOSVersion</key> | ||
| <string>$minimumOsVersion</string> | ||
| <key>UIDeviceFamily</key> | ||
| <array> | ||
| <integer>1</integer> | ||
| <integer>2</integer> | ||
| $uiDeviceFamilyValues |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this emit proper indent for second uiDeviceFamilyValues
line?
| </array> | ||
|
||
""".trimMargin() | ||
Family.OSX -> "" | ||
else -> error(target) | ||
}) | ||
|
||
if (target == KonanTarget.IOS_ARM64) { | ||
if (target.architecture == Architecture.ARM64) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does Xcode emit UIRequiredDeviceCapabilities
with arm64
for tvOS arm64 device framework?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, it's incorrect. 👍
|
||
private val KonanConfig.bitcodeEmbeddingMode: Mode | ||
get() = when { | ||
shouldForceBitcodeEmbedding() -> if (debug) Mode.MARKER else Mode.FULL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if CLI compiler driver should do this.
Does clang
enforce bitcode for tvOS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, it's a responsibility of a build system.
Does clang enforce bitcode for tvOS?
No.
@@ -18,6 +19,13 @@ internal fun determineLinkerOutput(context: Context): LinkerOutputKind = | |||
else -> TODO("${context.config.produce} should not reach native linker stage") | |||
} | |||
|
|||
// TODO: Move to a more appropriate place. | |||
internal val KonanTarget.isAppleTarget: Boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This name doesn't reflect the actual conditions that need to be checked on its use sites.
This is generally more like IsThisParticularKindOfObjCInteropEnabled
.
I would prefer using old target-family-based approach for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless you have short-term plans to add more relevant target families of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think we should introduce Family.TVOS
, Family.WATCHOS
because different flavours of iOS
have different platform libs and runtime libraries (compiler_rt.*
). And when
over all Apple targets is getting kinda cumbersome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean platform libraries are deduced from the family in
kotlin-native/platformLibs/build.gradle
Line 39 in bcfd196
file("src/platform/${getVisibleName(target.family)}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's one of the reasons.
internal val KonanTarget.isAppleTarget: Boolean | ||
get() = family == Family.IOS || family == Family.OSX | ||
|
||
internal val KonanTarget.isTvOs: Boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isTvOS
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to isTvOsBased
. Will be removed with introduction of Family.TVOS
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, isTvOS
is good. I mean that s
should probably be capital.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Anyway, isTvOsBased
feels a bit better since target is not an OS :)
@@ -131,9 +150,10 @@ open class FrameworkTest : DefaultTask() { | |||
val bitcodeBuildTool = "${configurables.absoluteAdditionalToolsDir}/bin/bitcode-build-tool" | |||
val ldPath = "${configurables.absoluteTargetToolchain}/usr/bin/ld" | |||
val sdk = when (testTarget) { | |||
KonanTarget.IOS_X64 -> return // bitcode-build-tool doesn't support iPhone Simulator. | |||
KonanTarget.IOS_X64, KonanTarget.TVOS_X64 -> return // bitcode-build-tool doesn't support iPhone Simulator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment should be updated too.
@@ -69,6 +69,12 @@ class ClangArgs(private val configurables: Configurables) : Configurables by con | |||
KonanTarget.IOS_ARM64 -> | |||
listOf("-stdlib=libc++", "-arch", "arm64", "-isysroot", absoluteTargetSysRoot, "-miphoneos-version-min=9.0.0") | |||
|
|||
KonanTarget.TVOS_ARM64 -> | |||
listOf("-stdlib=libc++", "-arch", "arm64", "-isysroot", absoluteTargetSysRoot, "-mtvos-version-min=12.2") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better use older version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we have osVersionMin.tvos_x64
and such?
if (version1[index] < version2[index]) return -1; | ||
if (version1[index] > version2[index]) return 1; | ||
} | ||
return when { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it different from
return version1.size.compareTo(version2.size)
?
@@ -136,19 +136,22 @@ open class MacOSBasedLinker(targetProperties: AppleConfigurables) | |||
private val dsymutil = "$absoluteLlvmHome/bin/llvm-dsymutil" | |||
|
|||
private fun provideCompilerRtLibrary(libraryName: String): String? { | |||
val suffix = if (libraryName.isNotEmpty() && target == KonanTarget.IOS_X64) { | |||
"iossim" | |||
val prefix = when (val family = target.family) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just have when
over targets?
This would be simpler and more discoverable.
|
||
linkerNoDebugFlags.tvos_arm64 = -S | ||
linkerDynamicFlags.tvos_arm64 = -dylib | ||
linkerKonanFlags.tvos_arm64 = -lSystem -lc++ -lobjc -framework Foundation -sdk_version 11.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Different SDK versions for tvos_arm64 and tvos_x64.
@@ -247,15 +248,15 @@ internal val ObjCContainer.classOrProtocol: ObjCClassOrProtocol | |||
*/ | |||
internal fun Type.isStret(target: KonanTarget): Boolean { | |||
val unwrappedType = this.unwrapTypedefs() | |||
return when (target) { | |||
KonanTarget.IOS_ARM64 -> | |||
return when (target.architecture) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking only architecture here is wrong, as targets with same architecture can have different ABIs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, guess current approach with explicit selection seems better fitting.
val sourceFileExtension = when (target.family) { | ||
Family.OSX, Family.IOS -> { | ||
val sourceFileExtension = when { | ||
target.isAppleTarget -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guess previous version was readable enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we introduce Family.TVOS
, Family.WATCHOS
then it will be replaced with something like target.family.isAppleFamily
/ isDarwinBased
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TVOS and WATCHOS are pretty much the same as IOS, so why not just stick this way.
@@ -0,0 +1,63 @@ | |||
package org.jetbrains.kotlin | |||
|
|||
import kotlinx.serialization.Serializable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, is it indeed a good idea to depend on kotlinx.serialization.
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have dependencies on it in build-utils
(see ExternalReportUtils.kt
) and I don't think it can cause any trouble.
What about platform libs? |
I suggest to add them separately to make review easier. |
ee535d2
to
34742a1
Compare
version1.size == version2.size -> 0 | ||
version1.size < version2.size -> -1 | ||
else -> 1 | ||
if (version1[index] < version2[index]) return -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use compareTo here as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we want to continue iteration in case of equality.
|
||
KonanTarget.IOS_ARM32 -> | ||
listOf("-stdlib=libc++", "-arch", "armv7", "-isysroot", absoluteTargetSysRoot, "-miphoneos-version-min=9.0.0") | ||
listOf("-stdlib=libc++", "-arch", "armv7", "-isysroot", absoluteTargetSysRoot, "-miphoneos-version-min=$osVersionMin") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't osVersionMin
actually differ from "9.0.0"
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it's 9.0. What kind of problem may it cause?
// 1 - iPhone | ||
// 2 - iPad | ||
// 3 - AppleTV | ||
val uiDeviceFamilyValues = if (target.isTvOsBased) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will anyway turn into when
over target (or target family) after adding watchOS, making isTvOsBased
unnecessary. Then why not just use this fact?
| $uiDeviceFamilyValues | ||
${uiDeviceFamilyValues.joinToString(separator = "\n") { | ||
"| <integer>$it</integer>" | ||
}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird indent?
@@ -16,6 +16,7 @@ | |||
|
|||
package org.jetbrains.kotlin.native.interop.gen | |||
|
|||
import org.jetbrains.kotlin.konan.target.Architecture |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused import.
@@ -248,19 +249,24 @@ internal val ObjCContainer.classOrProtocol: ObjCClassOrProtocol | |||
internal fun Type.isStret(target: KonanTarget): Boolean { | |||
val unwrappedType = this.unwrapTypedefs() | |||
return when (target) { | |||
KonanTarget.IOS_ARM64 -> | |||
KonanTarget.IOS_ARM64, | |||
KonanTarget.TVOS_ARM64 -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, have you verified that tvOS arm64 ABI doesn't use stret too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
KonanTarget.IOS_X64, | ||
KonanTarget.MACOS_X64, | ||
KonanTarget.WATCHOS_X64, | ||
KonanTarget.TVOS_X64 -> when (unwrappedType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please ensure that watchOS and tvOS simulators use regular macOS x86_64 ABI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
9245a93
to
a47d3c6
Compare
| <key>MinimumOSVersion</key> | ||
| <string>$minimumOsVersion</string> | ||
| <key>UIDeviceFamily</key> | ||
| <array> | ||
| <integer>1</integer> | ||
| <integer>2</integer> | ||
|$xmlValues |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second line doesn't have |
prefix. Does this work properly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
addEmptyMarker(llvm, "konan_llvm_cmdline", "__LLVM,__cmdline") | ||
private val KonanConfig.bitcodeEmbeddingMode: Mode | ||
get() = configuration.get(KonanConfigKeys.BITCODE_EMBEDDING_MODE)!!.also { | ||
// TODO: We cannot produce programs due to `-alias` linked flag. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, so why not fix alias with LLVM API call as suggested in #3288?
a47d3c6
to
b18edd5
Compare
No description provided.