Stream: general

Topic: ✔ wasm-tools parse and start


view this post on Zulip Scott Waye (Dec 08 2023 at 18:22):

Can wasm-tools parse understand a (start $hello) section?

view this post on Zulip Alex Crichton (Dec 08 2023 at 18:24):

It should, yes, but are you seeing otherwise?

view this post on Zulip Scott Waye (Dec 09 2023 at 02:10):

There is something I don't understand here, although its not related to start that was just moved to the end of the file. Should I be able to take a wasm file that can succesully be compose to a componet with c:\tmp\wasm-tools component new C:\github\wasm-component-sdk\samples\calculator\CalculatorHost\bin\Debug\net8.0\wasi-wasm\native\CalculatorHost.wasm -o c:\tmp\CalculatorHost.composed.wasm --adapt C:\github\wasm-component-sdk\src\WasmComponent.Sdk\tools\wasi-wasm\wasi_snapshot_preview1.command.wasm,
rountrip it through print and parse

c:\tmp\wasm-tools print C:\github\wasm-component-sdk\samples\calculator\CalculatorHost\bin\Debug\net8.0\wasi-wasm\native\CalculatorHost.wasm -o c:\tmp\calculatorhost.wat

c:\github\runtimelab>c:\tmp\wasm-tools parse c:\tmp\calculatorhost.wat  -o c:\tmp\calculator.copy.wasm

And successfully create a component from the new c:\tmp\calculator.copy.wasm ? I ask because when I try this I get

c:\github\runtimelab>c:\tmp\wasm-tools component new C:\tmp\calculator.copy.wasm -o c:\tmp\CalculatorHost.composed.wasm --adapt C:\github\wasm-component-sdk\src\WasmComponent.Sdk\tools\wasi-wasm\wasi_snapshot_preview1.command.wasm
error: failed to encode a component from module

Caused by:
    0: module requires an import interface named `example:calculator/operations`

view this post on Zulip Scott Waye (Dec 09 2023 at 02:12):

wasm-tools is wasm-tools 1.0.54 (39a60291b 2023-11-29)

view this post on Zulip Scott Waye (Dec 09 2023 at 03:31):

ignore that, I need to reembed the meta data after parsing the wat.

view this post on Zulip Scott Waye (Dec 09 2023 at 03:57):

I added the start to the core module, and its still in the core instance after composing the final wasm and is not called. Thinking about where this goes wrong, after the wasm-tools compose new step should the start function be extracted into the "component wasm sections" ?

view this post on Zulip Scott Waye (Dec 09 2023 at 03:59):

CalculatorHost.composed.zip

These are the host component wasm, and the final composed wasm

view this post on Zulip Scott Waye (Dec 09 2023 at 12:34):

I see, reading the explainer componet start functions are marked for a future milestone https://github.com/WebAssembly/component-model/blob/main/design/mvp/Explainer.md#-start-definitions . I will look for another solution to my problem.

view this post on Zulip Notification Bot (Dec 09 2023 at 12:34):

Scott Waye has marked this topic as resolved.

view this post on Zulip Alex Crichton (Dec 09 2023 at 22:20):

Oh roundtripping through the text format loses custom sections which are used to encode component type information

view this post on Zulip Scott Waye (Dec 10 2023 at 02:29):

Thanks, obvvious once I realised it.


Last updated: Nov 22 2024 at 16:03 UTC