Skip to content

WASI components import wasi:cli/environemnt and wasi:cli/exit when not being used #107405

Open
@jsturtevant

Description

@jsturtevant

problem statement

When building a component for wasi:http when running in wasmtime I get the following error:

wasmtime serve .\bin\Debug\net8.0\wasi-wasm\native\MyApp.wasm --addr 127.0.0.1:3000
Error: component imports instance `wasi:cli/environment@0.2.0`, but a matching implementation was not found in the linker

Caused by:
    0: instance export `get-environment` has the wrong type
    1: function implementation is missing

When inspecting the component built I see imports for wasi:cli/environemnt and wasi:cli/exit, even though I only built against the wasi:http world:

wasm-tools.exe component wit .\bin\Debug\net8.0\wasi-wasm\native\MyApp.wasm
package root:component;

world root {
  import wasi:cli/environment@0.2.0;
  import wasi:cli/exit@0.2.0;
....

I was able to work around it by telling wasmtime to provide the cli imports:

wasmtime serve -S cli ...

question

Should these imports be included in the component? Is there a way to detect during compilation if the env/exit are being used and not include them?

Discussion in Bytecode Alliance Zulip: https://bytecodealliance.zulipchat.com/#narrow/stream/407028-C.23.2F.2Enet-collaboration/topic/missing.20implementation.20was.20not.20found.20in.20linker

example

https://github.com/jsturtevant/wasi-http-oci

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions