From 2604208999a9ce7d40f32b337bfc995aebafb442 Mon Sep 17 00:00:00 2001 From: Michal Harakal Date: Mon, 20 Jul 2026 12:12:23 +0200 Subject: [PATCH] io-core: add androidNativeArm32 via 64-bit-only native64Main source set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Completes androidNative for skainet-io-core (arm64 landed in #836). The 32-bit target was blocked because PosixPreadRandomAccessSource uses posix pread, whose ssize_t/size_t are Int on 32-bit but Long on every other native target — mixing widths in the shared nativeMain metadata compile is illegal ('numbers with different bit widths'). Introduces a 64-bit-only intermediate source set native64Main (+ native64Test) between nativeMain and the six 64-bit native targets, and moves the posix source there. nativeMain is now width-uniform-agnostic (no posix), so it compiles across all native incl. androidNativeArm32; the posix code compiles only for the 64-bit group. Nothing in commonMain references PosixPreadRandomAccessSource (only its own test + external file-I/O consumers), so arm32 simply builds without it. Verified: compileNativeMainKotlinMetadata, compileKotlinAndroidNativeArm32, compileKotlinAndroidNativeArm64, compileKotlinLinuxX64, and compileTestKotlinMacosArm64 all green. Co-Authored-By: Claude Opus 4.8 (1M context) --- skainet-io/skainet-io-core/build.gradle.kts | 26 +++++++++++++++---- .../ainet/io/PosixPreadRandomAccessSource.kt | 0 .../io/PosixPreadRandomAccessSourceTest.kt | 0 3 files changed, 21 insertions(+), 5 deletions(-) rename skainet-io/skainet-io-core/src/{nativeMain => native64Main}/kotlin/sk/ainet/io/PosixPreadRandomAccessSource.kt (100%) rename skainet-io/skainet-io-core/src/{nativeTest => native64Test}/kotlin/sk/ainet/io/PosixPreadRandomAccessSourceTest.kt (100%) diff --git a/skainet-io/skainet-io-core/build.gradle.kts b/skainet-io/skainet-io-core/build.gradle.kts index eefa3860e..13dff0505 100644 --- a/skainet-io/skainet-io-core/build.gradle.kts +++ b/skainet-io/skainet-io-core/build.gradle.kts @@ -39,12 +39,13 @@ kotlin { macosArm64 () linuxX64 () linuxArm64 () - // androidNativeArm64 joins the existing 64-bit native targets in the shared nativeMain - // (PosixPreadRandomAccessSource uses posix pread, whose ssize_t/size_t are Long on all of - // them). androidNativeArm32 is intentionally NOT added here: those posix types are Int on - // 32-bit, and mixing widths in the shared nativeMain metadata is illegal — arm32 needs the - // posix source moved to a 64-bit-only source set (tracked as a follow-up). androidNativeArm64() + // androidNativeArm32 is 32-bit: posix ssize_t/size_t are Int here vs Long on every other + // native target. PosixPreadRandomAccessSource therefore lives in the 64-bit-only `native64Main` + // source set (wired below), NOT in the shared `nativeMain` — otherwise the shared native + // metadata compile fails ("numbers with different bit widths"). arm32 gets the rest of + // io-core (tokenizers etc.); on-device file I/O for arm32 is a separate concern. + androidNativeArm32() js { browser() @@ -60,7 +61,22 @@ kotlin { nodejs() } + // 64-bit-only intermediate source sets: hold the posix `pread` RandomAccessSource, whose + // ssize_t/size_t widths are uniform (Long) across every native target EXCEPT androidNativeArm32. + // Keeping it out of the all-native `nativeMain` avoids the mixed-width metadata compile error. + applyDefaultHierarchyTemplate() + val native64Targets = listOf("iosArm64", "iosSimulatorArm64", "macosArm64", "linuxX64", "linuxArm64", "androidNativeArm64") + sourceSets { + val nativeMain by getting + val nativeTest by getting + val native64Main by creating { dependsOn(nativeMain) } + val native64Test by creating { dependsOn(nativeTest) } + native64Targets.forEach { t -> + getByName("${t}Main").dependsOn(native64Main) + getByName("${t}Test").dependsOn(native64Test) + } + val commonMain by getting { dependencies { implementation(project(":skainet-lang:skainet-lang-core")) diff --git a/skainet-io/skainet-io-core/src/nativeMain/kotlin/sk/ainet/io/PosixPreadRandomAccessSource.kt b/skainet-io/skainet-io-core/src/native64Main/kotlin/sk/ainet/io/PosixPreadRandomAccessSource.kt similarity index 100% rename from skainet-io/skainet-io-core/src/nativeMain/kotlin/sk/ainet/io/PosixPreadRandomAccessSource.kt rename to skainet-io/skainet-io-core/src/native64Main/kotlin/sk/ainet/io/PosixPreadRandomAccessSource.kt diff --git a/skainet-io/skainet-io-core/src/nativeTest/kotlin/sk/ainet/io/PosixPreadRandomAccessSourceTest.kt b/skainet-io/skainet-io-core/src/native64Test/kotlin/sk/ainet/io/PosixPreadRandomAccessSourceTest.kt similarity index 100% rename from skainet-io/skainet-io-core/src/nativeTest/kotlin/sk/ainet/io/PosixPreadRandomAccessSourceTest.kt rename to skainet-io/skainet-io-core/src/native64Test/kotlin/sk/ainet/io/PosixPreadRandomAccessSourceTest.kt