I'm trying to manually add a start
section to the final composed wasm. My wat then ends with :
(func $___start (canon lift
(core func 3 "___start")
))
(start $___start
I put that back through wasm-tools parse
and run it with wasmtime run --wasm component-model c:\tmp\calculator.start.wasm
and get the message
Error: failed to parse WebAssembly module
Caused by:
unknown core instance 3: instance index out of bounds (at offset 0x11711d4)
Which indicates it can't find instance 3, but even if I put 0 there (and I think 3 is correct), I get the same error. I must have a t least one instance in the wasm, in fact it looks like there are up to 26 core instance
sections, so confused that the error is index out of bounds.
I think the problem is there are no "core component" sections at this level. There are "component" sections, so maybe the func
should not have core func
but something else.
If it works I'd recommend using $
-names instead of raw indices. For example tag the core instance with "__start"
with $foo
and then use $foo
there and that might help surface whether the $foo
instance is in or out of scope
Thanks I will try that, I also need to understand better the composed structure
I'm still trying to get this wat right for defining a start
. I have a question about
(instance (;20;) (instantiate 0
(there are indices because it is the output of wasm-tools print
and changing them to names is not trivial). If component 0 exports a function, does the instance automatically export that funciton, or does it need to be an inline export? I did try
(with "____start" (instance (export "____start" )))
but that doesn't seem to be the right syntax:
error: expected `(`
--> c:\tmp\calculator.wat:6674915:55
|
6674915 | (with "____start" (instance (export "____start" func)))
|
ah sorry, got that wrong (with "____start" (instance (export "____start" (func 18))))
seems to parse ok. Now to work out how to reference that for the start ....
Should I alias it again in the outer scope, something like
(instance (;20;) (instantiate 0
(with "____start" (instance (export "____start" (func 18))))
)
)
(alias export 20 "____start" (func))
(start $____start)
(this doesn't parse, btw, I'm just trying things :-)
maybe I should be asking a more fundamental question, if a component has a start
section, does it need to be exposed all the way up through the composition, or should the host call start
functions whatever level they are at?
The start
section can appear anywhere in a component, but I should probably also confirm that you're aware that this is (or at least should be) a gated feature and is largely unimplemented in Wasmtime/tooling.
Right, but I'm running out of ideas of how to solve this. One of the ideas I have left is to fill out the implementations for start
at least for functions without value
s
A message was moved here from #wasmtime > compontent model wasm -> core wasm by Alex Crichton.
If you require the component-model start
function to work it won't be easy and I'd recommend trying to avoid it. It's got some pretty fundamental design questions associated with it so it's not as simple as just implementing a few unimplemented!()
blocks in Wasmtime
Thanks, ok point taken. I can probably disable getting all the environment variables from dotnet and then Wasi libc should lazy load. That might be acceptable upstream as long as it is temporary.
I mean make https://learn.microsoft.com/en-us/dotnet/api/system.environment.getenvironmentvariables?view=net-8.0 throw a PlatformNotSupportedException for Wasm/Wasi
Scott Waye has marked this topic as resolved.
Last updated: Nov 22 2024 at 17:03 UTC