Skip to content

build(io): Windows random-access reads for io-core and io-gguf (#911) - #916

Merged
michalharakal merged 1 commit into
feature/911-mingw-target-groupfrom
feature/911-mingw-windows-io
Aug 10, 2026
Merged

michalharakal merged 1 commit into
feature/911-mingw-target-groupfrom
feature/911-mingw-windows-io

Conversation

@michalharakal

Copy link
Copy Markdown
Contributor

Stacked on #915 (base = feature/911-mingw-target-group; retarget to develop after #915 merges). Completes #911's Windows file-access story.

What

POSIX pread(2) does not exist on mingw, and mingwX64 is LLP64 — so Windows gets a separate leaf implementation instead of joining io-core's native64Main posix source set:

  • io-core: WindowsRandomAccessSourceCreateFileW + ReadFile with an OVERLAPPED 64-bit offset (true positional reads: thread-safe without locking, > 2 GB-safe via Offset/OffsetHigh), GetFileSizeEx for size. Test suite is a 1:1 port of PosixPreadRandomAccessSourceTest (kotlinx-io only, fully portable).
  • io-gguf: migrated to sk.ainet.multiplatform with mingw. The posix createRandomAccessSource actual moves from nativeMain into a new posixMain intermediate (apple + linux leaves), and mingwX64Main hangs off nativeMain with a Win32-backed actual. Fallback contract unchanged: null when the file cannot be opened → legacy sequential reader.

A gotcha worth knowing

Custom dependsOn edges silently disable the default hierarchy template: with the first wiring attempt io-gguf's compilations collapsed to [leaf, commonMain] (no warning for this module) and the posix actual went unresolved. The module now opts out explicitly (kotlin.mpp.applyDefaultHierarchyTemplate=false) and wires nativeMain/posixMain/leaf edges by hand — the same pattern skainet-backend-cpu already uses. Might deserve a line in the convention-plugin docs.

Verified

  • io-gguf: compileKotlin{LinuxX64,MacosArm64,MingwX64} + compileTestKotlinMingwX64 green.
  • io-core: mingw main + test klibs compile; linuxX64Test green (posix path regression).

Notes

  • A windows-latest mingwX64Test CI lane is prepared but ships separately (workflow-scope constraint on the pushing token). Windows-runner execution of the ported test suite is the acceptance for this PR's Win32 code.
  • Downstream consumer: whisper-cli — its streaming GGUF loader needs a working createRandomAccessSource on Windows, which is why this is a real implementation rather than a stub.

posix pread(2) does not exist on mingw, and mingwX64 is LLP64 — so the
Win32 path is a separate leaf implementation instead of joining
io-core's native64Main posix source set:

- io-core: WindowsRandomAccessSource (CreateFileW + ReadFile with an
  OVERLAPPED 64-bit offset — positional, thread-safe without locking,
  >2 GB-safe via Offset/OffsetHigh; GetFileSizeEx for size). Test is a
  port of PosixPreadRandomAccessSourceTest (kotlinx-io only).
- io-gguf: migrated to sk.ainet.multiplatform with mingw enabled. The
  posix createRandomAccessSource actual moves from nativeMain into a
  new posixMain intermediate; the module opts out of the default
  hierarchy template (custom dependsOn edges silently disable it — the
  compilations collapsed to [leaf, commonMain] until wired by hand,
  same pattern as backend-cpu) and wires nativeMain/posixMain/leaf
  edges explicitly, with mingwX64Main off nativeMain carrying the
  Win32 actual. Fallback contract unchanged: null when the file cannot
  be opened -> legacy sequential reader.

A windows-latest mingwX64Test CI lane follows in a separate workflow
change (token pushing this branch lacks the workflow scope).

Verified locally: linuxX64/macosArm64/mingwX64 compile green for
io-gguf; mingw test klibs compile for io-core and io-gguf.
@michalharakal
michalharakal merged commit d8a714d into feature/911-mingw-target-group Aug 10, 2026
1 check passed
@michalharakal
michalharakal deleted the feature/911-mingw-windows-io branch August 10, 2026 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant