SwadicalRag / wasm2lua

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

cannot work on wasm32-unknown-unknown target from rust #39

Open walksanatora opened 1 year ago

walksanatora commented 1 year ago

when compiling for this target and then running wasm2lua on it you end up with

Unsupported export type: 0x2
/usr/lib/node_modules/wasm2lua/resources/patches/decoder.js:618
          throw new _helperApiError.CompileError("Unexpected valtype: " + toHex(valtypeByte));
          ^

CompileError: Unexpected valtype: 0x61
    at parseCodeSection (/usr/lib/node_modules/wasm2lua/resources/patches/decoder.js:618:17)
    at parseSection (/usr/lib/node_modules/wasm2lua/resources/patches/decoder.js:1487:13)
    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:1233:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)

Node.js v20.5.1
walksanatora commented 1 year ago

same error when exporting from wasm32-wasi

walksanatora commented 1 year ago

nvm. but when exporting with wasm32-wasi it does complain at me Unsupported export type: 0x2

walksanatora commented 1 year ago

and after modifying the basic function to export the add function properly you then get met with

/usr/lib/node_modules/wasm2lua/resources/patches/decoder.js:1314
      if (sectionId !== _helperWasmBytecode.default.sections.custom) throw new _helperApiError.CompileError("Unexpected section: " + toHex(sectionId));
                                                                     ^

CompileError: Unexpected section: 0x3
    at parseSection (/usr/lib/node_modules/wasm2lua/resources/patches/decoder.js:1314:76)
    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:1233:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)

Node.js v20.5.1
walksanatora commented 1 year ago

https://github.com/walksanatora/wasm_hell

Vurv78 commented 1 year ago

@walksanatora if you want a webassembly to luau solution probably https://github.com/Rerumu/Wasynth is your best bet. although just noticed you have an issue there too, unfortunately a bit late then.

wasm2lua is still nice for everything else since they actually did the hard part supporting native lua, without luajit's ffi.