From ccce0dbf84c2e0b7dd66e1d05fee5fff63dd81e9 Mon Sep 17 00:00:00 2001 From: zihang Date: Fri, 22 May 2026 12:17:18 +0800 Subject: [PATCH 1/3] fix: remove inline wasm ABI pointer shifts --- internal/ffi/top.mbt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/ffi/top.mbt b/internal/ffi/top.mbt index 4987450..cbb4783 100644 --- a/internal/ffi/top.mbt +++ b/internal/ffi/top.mbt @@ -39,14 +39,14 @@ pub fn malloc(size : Int) -> Int { ///| pub extern "wasm" fn free(position : Int) = - #|(func (param i32) local.get 0 i32.const 8 i32.sub call $moonbit.decref) + #|(func (param i32) local.get 0 call $moonbit.decref) ///| #owned(bytes) pub extern "wasm" fn byte_array2ptr(bytes : FixedArray[Byte]) -> Int = - #|(func (param i32) (result i32) local.get 0 i32.const 8 i32.add) + #|(func (param i32) (result i32) local.get 0) ///| #owned(bytes) pub extern "wasm" fn bytes2ptr(bytes : Bytes) -> Int = - #|(func (param i32) (result i32) local.get 0 i32.const 8 i32.add) + #|(func (param i32) (result i32) local.get 0) From 346ae755eed50177d79b365697c9c04751969559 Mon Sep 17 00:00:00 2001 From: zihang Date: Fri, 22 May 2026 13:40:55 +0800 Subject: [PATCH 2/3] docs: note MoonBit ABI layout change --- README.mbt.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.mbt.md b/README.mbt.md index d02c831..78a1165 100644 --- a/README.mbt.md +++ b/README.mbt.md @@ -9,6 +9,18 @@ Use it when you want a MoonBit executable that runs cleanly under `moon run`, `wasmtime`, or another WASIp1 host without tying your code to host-specific file and terminal APIs. +## ABI compatibility + +MiniIO uses inline wasm helpers to pass MoonBit strings, bytes, and arrays to +WASIp1 calls. MoonBit changed the ABI layout for these values so the data +pointer no longer needs the old 8-byte offset. This is a breaking change for +packages that use inline wasm, but it is not something the MoonBit compiler can +detect at the type level. + +Use this package with a MoonBit toolchain that has the updated ABI layout. If an +older toolchain or older inline-wasm bindings are mixed with MiniIO, programs +may still compile but fail at runtime with corrupted strings/bytes or traps. + ## Public API - `args_get()` From 18feb5ef7f85ff1b9be3d03660986bbc16a1b0d6 Mon Sep 17 00:00:00 2001 From: zihang Date: Fri, 22 May 2026 14:25:08 +0800 Subject: [PATCH 3/3] chore: bump version and update readme --- README.mbt.md | 11 ++--------- moon.mod.json | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/README.mbt.md b/README.mbt.md index 78a1165..dd25286 100644 --- a/README.mbt.md +++ b/README.mbt.md @@ -11,15 +11,8 @@ and terminal APIs. ## ABI compatibility -MiniIO uses inline wasm helpers to pass MoonBit strings, bytes, and arrays to -WASIp1 calls. MoonBit changed the ABI layout for these values so the data -pointer no longer needs the old 8-byte offset. This is a breaking change for -packages that use inline wasm, but it is not something the MoonBit compiler can -detect at the type level. - -Use this package with a MoonBit toolchain that has the updated ABI layout. If an -older toolchain or older inline-wasm bindings are mixed with MiniIO, programs -may still compile but fail at runtime with corrupted strings/bytes or traps. +0.1.0 is compatible with MoonBit < 0.9.3 +0.2.0 is compatible with MoonBit >= 0.9.3 ## Public API diff --git a/moon.mod.json b/moon.mod.json index b2cc3d5..bc8d357 100644 --- a/moon.mod.json +++ b/moon.mod.json @@ -1,6 +1,6 @@ { "name": "moonbit-community/miniio", - "version": "0.1.0", + "version": "0.2.0", "description": "Small, portable WASIp1 I/O SDK for building MoonBit CLI tools and agent skills.", "keywords": ["wasi", "wasip1", "io", "cli", "agent"], "readme": "README.md",