Can wasm-tools parse
understand a (start $hello)
section?
It should, yes, but are you seeing otherwise?
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`
wasm-tools is wasm-tools 1.0.54 (39a60291b 2023-11-29)
ignore that, I need to reembed the meta data after parsing the wat.
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" ?
These are the host component wasm, and the final composed wasm
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.
Scott Waye has marked this topic as resolved.
Oh roundtripping through the text format loses custom sections which are used to encode component type information
Thanks, obvvious once I realised it.
Last updated: Dec 23 2024 at 12:05 UTC