Kotlin/Native 目标平台支持

The Kotlin/Native compiler supports a great number of different targets, though it is hard to provide the same level of support for all of them. This document describes which targets Kotlin/Native supports and breaks them into several tiers depending on how well the compiler supports them.

We can adjust the number of tiers, the list of supported targets, and their features as we go.

目标平台支持 - 图1

Mind the following terms used in tier tables:

  • Gradle target name is a target preset that is used in the Kotlin Multiplatform Gradle plugin to enable the target.
  • Target triple is a target name according to the <architecture>-<vendor>-<system>-<abi> structure that is commonly used by compilers.
  • Running tests indicates out of the box support for running tests in Gradle and IDE.

    This is only available on a native host for the specific target. For example, you can run macosX64 and iosX64 tests only on macOS x86-64 host.

Tier 1

Gradle target nameTarget tripleRunning testsDescription
linuxX64x86_64-unknown-linux-gnuLinux on x86_64 platforms
Apple macOS hosts only
macosX64x86_64-apple-macosApple macOS on x86_64 platforms
macosArm64aarch64-apple-macosApple macOS on Apple Silicon platforms
iosSimulatorArm64aarch64-apple-ios-simulatorApple iOS simulator on Apple Silicon platforms
iosX64x86_64-apple-ios-simulatorApple iOS simulator on x86-64 platforms

Tier 2

Gradle target nameTarget tripleRunning testsDescription
linuxArm64aarch64-unknown-linux-gnuLinux on ARM64 platforms
Apple macOS hosts only
watchosSimulatorArm64aarch64-apple-watchos-simulatorApple watchOS simulator on Apple Silicon platforms
watchosX64x86_64-apple-watchos-simulatorApple watchOS 64-bit simulator on x86_64 platforms
watchosArm32armv7k-apple-watchosApple watchOS on ARM32 platforms
watchosArm64arm64_32-apple-watchosApple watchOS on ARM64 platforms with ILP32
tvosSimulatorArm64aarch64-apple-tvos-simulatorApple tvOS simulator on Apple Silicon platforms
tvosX64x86_64-apple-tvos-simulatorApple tvOS simulator on x86_64 platforms
tvosArm64aarch64-apple-tvosApple tvOS on ARM64 platforms
iosArm64aarch64-apple-iosApple iOS and iPadOS on ARM64 platforms

We’re doing our best to move iosArm64 to Tier 1, as it’s a crucial target for Kotlin Multiplatform for mobile. To do that, we need first to create a dedicated testing infrastructure because platform limitations make it difficult to run compiler tests on Apple devices.

Meanwhile, we sometimes run tests manually on iOS devices and rely on testing similar targets, like iosSimulatorArm64, which should be sufficient in most cases.

目标平台支持 - 图2

Tier 3

  • The target is not guaranteed to be tested on CI.
  • We can’t promise a source and binary compatibility between different compiler releases, though such changes for these targets are quite rare.
Gradle target nameTarget tripleRunning testsDescription
androidNativeArm32arm-unknown-linux-androideabiAndroid NDK on ARM32 platforms
androidNativeArm64aarch64-unknown-linux-androidAndroid NDK on ARM64 platforms
androidNativeX86i686-unknown-linux-androidAndroid NDK on x86 platforms
androidNativeX64x86_64-unknown-linux-androidAndroid NDK on x86_64 platforms
mingwX64x86_64-pc-windows-gnu64-bit MinGW on Windows 7 and later
Apple macOS hosts only
watchosDeviceArm64aarch64-apple-watchosApple watchOS on ARM64 platforms

Deprecated targets

The following targets are deprecated since Kotlin 1.8.20 and will be removed in 1.9.20:

  • iosArm32
  • watchosX86
  • wasm32
  • mingwX86
  • linuxArm32Hfp
  • linuxMips32
  • linuxMipsel32

For library authors

We don’t recommend library authors to test more targets or provide stricter guarantees than the Kotlin/Native compiler does. You can use the following approach when considering support for native targets:

  • Support all the targets from tier 1, 2, and 3.
  • Regularly test targets from tier 1 and 2 that support running tests out of the box.

The Kotlin team uses this approach in the official Kotlin libraries, for example, kotlinx.coroutines and kotlinx.serialization.