SwadicalRag / wasm2lua

wasm2lua: converting WASM into Lua
MIT License
194 stars 11 forks source link

Could not turn a bare c program to lua #41

Closed MCorange99 closed 3 months ago

MCorange99 commented 3 months ago

Error:

# wasm2lua build/keypadOS.wasm build/keypadOS.lua --libmode --pureLua
Unsupported export type: 0x2
/usr/lib/node_modules/wasm2lua/resources/patches/decoder.js:1679
    throw new _helperApiError.CompileError("Unexpected section: " + toHex(sectionId));
    ^

CompileError: Unexpected section: 0x11
    at parseSection (/usr/lib/node_modules/wasm2lua/resources/patches/decoder.js:1679:11)
    at Object.decode (/usr/lib/node_modules/wasm2lua/resources/patches/decoder.js:1697:25)
    at Object.decode (/usr/lib/node_modules/wasm2lua/node_modules/@webassemblyjs/wasm-parser/lib/index.js:253:21)
    at new wasm2lua (/usr/lib/node_modules/wasm2lua/js/index.js:104:42)
    at Object.<anonymous> (/usr/lib/node_modules/wasm2lua/js/bin/wasm2lua.js:85:12)
    at Module._compile (node:internal/modules/cjs/loader:1546:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
    at Module.load (node:internal/modules/cjs/loader:1317:32)
    at Module._load (node:internal/modules/cjs/loader:1127:12)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)

Node.js v22.6.0
make: *** [Makefile:30: build/keypadOS.lua] Error 1

Wasm:

(module $keypadOS.wasm
  (type (;0;) (func))
  (type (;1;) (func (param i32 i32) (result i32)))
  (func $__wasm_call_ctors (type 0))
  (func $main (type 1) (param i32 i32) (result i32)
    i32.const 0)
  (memory (;0;) 92)
  (global $__stack_pointer (mut i32) (i32.const 6001024))
  (global (;1;) i32 (i32.const 1024))
  (global (;2;) i32 (i32.const 1024))
  (global (;3;) i32 (i32.const 1024))
  (global (;4;) i32 (i32.const 6001024))
  (global (;5;) i32 (i32.const 1024))
  (global (;6;) i32 (i32.const 6001024))
  (global (;7;) i32 (i32.const 6029312))
  (global (;8;) i32 (i32.const 0))
  (global (;9;) i32 (i32.const 1))
  (export "memory" (memory 0))
  (export "__wasm_call_ctors" (func $__wasm_call_ctors))
  (export "__main_argc_argv" (func $main))
  (export "__dso_handle" (global 1))
  (export "__data_end" (global 2))
  (export "__stack_low" (global 3))
  (export "__stack_high" (global 4))
  (export "__global_base" (global 5))
  (export "__heap_base" (global 6))
  (export "__heap_end" (global 7))
  (export "__memory_base" (global 8))
  (export "__table_base" (global 9)))

C Program:


int main() {
    return 0;
}
MCorange99 commented 3 months ago

Oh and the commands to build the C that im using:

/opt/wasi-sdk/bin/clang -c -o build/obj/main.c.o src/main.c -Isrc/include -std=c23 --target=wasm32-wasi -O3 -flto -nostdlib --sysroot=/opt/wasi-sdk/share/wasi-sysroot -fvisibility=hidden
wasm-ld  -o build/keypadOS.wasm build/obj/main.c.o --no-entry --export-all --lto-O3 -z stack-size=6000000 --allow-undefined -export-dynamic
wasm2wat build/keypadOS.wasm -o build/keypadOS.wat
wasm2lua build/keypadOS.wasm build/keypadOS.lua --libmode --pureLua
MCorange99 commented 3 months ago

nvm just discovered this is a dead project