Skip to content

Cross-compile linuxArm64 tests on x86_64 (was: failing on arm64 host) - #9

Merged
IRus merged 1 commit into
mainfrom
fix/linux-arm64-compile-only
Jul 18, 2026
Merged

Cross-compile linuxArm64 tests on x86_64 (was: failing on arm64 host)#9
IRus merged 1 commit into
mainfrom
fix/linux-arm64-compile-only

Conversation

@IRus

@IRus IRus commented Jul 18, 2026

Copy link
Copy Markdown
Member

Problem

The `Linux arm64 tests` matrix entries (in `ci.yml`) and `Linux arm64 Native` (in `pinned-conformance.yml`) fail at Gradle configuration time:

```

A problem occurred configuring project ':benchmarks'.
Caused by: org.jetbrains.kotlin.konan.target.TargetSupportException:
Unknown host target: linux aarch64
```

Root cause: Kotlin/Native (Konan) does not publish a linux-aarch64 host toolchain in any version. `HostManager` cannot determine the host on `ubuntu-24.04-arm`, so Gradle cannot configure `:benchmarks` (or any project declaring a K/N target). This blocks every gradle command on that runner, not just the arm64 tests.

Why "just run linuxArm64Test" is not possible

Even if the Konan host problem were worked around (QEMU on x86_64, etc.), the `linuxArm64Test` task does not exist on any host. `KotlinMultiplatformTargetPresetSetupAction` only registers a host test-run task for `{LINUX_X64, MACOS_X64, MACOS_ARM64, MINGW_X64}`. `LINUX_ARM64` instantiates a plain `KotlinNativeTarget` with no test-run, so `tasks.register("linuxArm64Test", ...)` is never called. The CI invocation `:core:linuxArm64Test` would fail with "task not found" regardless of host. (kotlinx-benchmark has the same limitation for `linuxArm64Benchmark`.)

Fix

Move the matrix entries onto `ubuntu-24.04` (x86_64, where Konan's host is supported) and cross-compile the linuxArm64 test compilation instead of running it:

```
:core:compileTestKotlinLinuxArm64 (was :core:linuxArm64Test)
:snapshot:compileTestKotlinLinuxArm64
:wasi:compileTestKotlinLinuxArm64
:bindgen-api:compileTestKotlinLinuxArm64
:bindgen-runtime:compileTestKotlinLinuxArm64
:tck:compileTestKotlinLinuxArm64
```

This validates that every module's `commonTest`/`linuxArm64` source compiles against the aarch64 Kotlin/Native toolchain on every PR — catching target-specific signature/API errors — without depending on a host that does not exist.

What this does NOT cover

  • Runtime execution of aarch64 test binaries is out of scope. KGP provides no DSL to run them cross-host; doing so would require a custom `Exec` task wrapping `qemu-aarch64-static` + JUnit-XML parsing — a follow-up if runtime arm64 coverage is wanted.
  • linuxArm64 benchmarks remain without CI coverage (kotlinx-benchmark does not register them on a non-matching host; same class of limitation).

Both are tracked upstream as KT-36871 (linux aarch64 host support).

Verification

```
./gradlew :core:compileTestKotlinLinuxArm64 :tck:compileTestKotlinLinuxArm64
-> BUILD SUCCESSFUL
```

All six `compileTestKotlinLinuxArm64` tasks resolve and cross-compile against the linuxArm64 klib toolchain. YAML for both workflows validated.

The "Linux arm64 tests" matrix entries ran on ubuntu-24.04-arm and
failed at Gradle configuration time with
"Unknown host target: linux aarch64": Kotlin/Native (Konan) does not
publish a linux-aarch64 host toolchain in any version, so HostManager
cannot determine the host and Gradle cannot configure :benchmarks or
any project that declares a Kotlin/Native target.

  > A problem occurred configuring project ':benchmarks'.
  > Caused by: org.jetbrains.kotlin.konan.target.TargetSupportException:
  >   Unknown host target: linux aarch64

Running the aarch64 test binaries is also not possible from the KGP
DSL: KotlinMultiplatformTargetPresetSetupAction only registers a host
test-run task (linuxArm64Test) for {LINUX_X64, MACOS_X64, MACOS_ARM64,
MINGW_X64}. LINUX_ARM64 instantiates a plain KotlinNativeTarget with no
test-run, so the linuxArm64Test task never exists on any host — the CI
invocation :core:linuxArm64Test would fail with "task not found" even
with the Konan host problem worked around.

Move the matrix entries onto ubuntu-24.04 (x86_64), where Konan's host
is supported, and cross-compile the linuxArm64 test compilation instead
of running it: :core:compileTestKotlinLinuxArm64 (and the five sibling
modules), plus :tck:compileTestKotlinLinuxArm64 in pinned conformance.
This validates that every module's commonTest/linuxArm64 source
compiles against the aarch64 Kotlin/Native toolchain on every PR,
catching target-specific signature and API errors, without depending on
a host that does not exist.

Runtime execution of aarch64 test binaries (and linuxArm64 benchmarks,
which kotlinx-benchmark likewise does not register on a non-matching
host) is out of scope; tracked upstream as KT-36871.

Verified locally:
  ./gradlew :core:compileTestKotlinLinuxArm64 :tck:compileTestKotlinLinuxArm64
  -> BUILD SUCCESSFUL (cross-compiles against the linuxArm64 klib toolchain)
@IRus
IRus merged commit 86af19f into main Jul 18, 2026
12 of 14 checks passed
@IRus
IRus deleted the fix/linux-arm64-compile-only branch July 19, 2026 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant