bytecodealliance / wasm-micro-runtime

WebAssembly Micro Runtime (WAMR)
Apache License 2.0
4.99k stars 628 forks source link

Exception for Assemblyscript #3448

Open spino17 opened 6 months ago

spino17 commented 6 months ago

I build the .wasm binary by following the official link: https://www.assemblyscript.org/getting-started.html#setting-up-a-new-project. My code in /assembly/index.ts is

// The entry file of your WebAssembly module.

export function main(): void {
  console.log("Hello, world");
}

or even if I try:

console.log("Hello, world");

when I try command iwasm release.wasm, I am getting the following error:

[13:26:38:790 - 1ED737AC0]: failed to check signature '(i)' and resolve pointer params for import function (env abort)

[13:26:38:818 - 1ED737AC0]: warning: failed to link import function (env, console.log)
[13:26:38:820 - 1ED737AC0]: warning: failed to link import function (env, abort)

#00: 0x0000 - console.log
#01: 0x013e - $f2

WASM module instantiate failed: Exception: failed to call unlinked import function (env, console.log)
wenyongh commented 6 months ago

Hi, maybe you can refer to the assembly-script sample in wamr-app-framework repo: https://github.com/bytecodealliance/wamr-app-framework/tree/main/assembly-script

Here it defines Console APIs for console.log and console.log_number, which are implemented in: https://github.com/bytecodealliance/wamr-app-framework/blob/main/assembly-script/wamr_app_lib/console.ts