build(io): Windows random-access reads for io-core and io-gguf (#911) - #916
Merged
michalharakal merged 1 commit intoAug 10, 2026
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #915 (base =
feature/911-mingw-target-group; retarget todevelopafter #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'snative64Mainposix source set:WindowsRandomAccessSource—CreateFileW+ReadFilewith anOVERLAPPED64-bit offset (true positional reads: thread-safe without locking, > 2 GB-safe viaOffset/OffsetHigh),GetFileSizeExfor size. Test suite is a 1:1 port ofPosixPreadRandomAccessSourceTest(kotlinx-io only, fully portable).sk.ainet.multiplatformwithmingw. The posixcreateRandomAccessSourceactual moves fromnativeMaininto a newposixMainintermediate (apple + linux leaves), andmingwX64Mainhangs offnativeMainwith a Win32-backed actual. Fallback contract unchanged:nullwhen the file cannot be opened → legacy sequential reader.A gotcha worth knowing
Custom
dependsOnedges 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 wiresnativeMain/posixMain/leaf edges by hand — the same patternskainet-backend-cpualready uses. Might deserve a line in the convention-plugin docs.Verified
compileKotlin{LinuxX64,MacosArm64,MingwX64}+compileTestKotlinMingwX64green.linuxX64Testgreen (posix path regression).Notes
windows-latestmingwX64TestCI 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.createRandomAccessSourceon Windows, which is why this is a real implementation rather than a stub.