menu

Wasmer

Wasmer is a organization dedicated to the advancement and development of WebAssembly through open-source software.

Channels
Team

Imported functions documentation?

March 6, 2019 at 8:35pm

Imported functions documentation?

March 6, 2019 at 8:35pm

I'm interested in writing wasmer apps, but I have no clue what imports are available to me. Any place I can look to find out?


March 6, 2019 at 8:52pm

only emscripten imports are provided afaik. You can find them enumerated here

like-fill
2
  • reply
  • like

Thank you! :)

  • reply
  • like

is there some special flag I need to get the emscripten imports?

  • reply
  • like

wasmer run wasmer.wasm "Can\'t instantiate module: LinkError([ImportNotFound { namespace: \"env\", name: \"printf\" }])"

  • reply
  • like

I get this when I run wasmer

  • reply
  • like

oh, it seems I need to have a certain function

  • reply
  • like

pub fn isemscripten_module(module: &Module) -> bool { for (, import_name) in &module.info().imported_functions { let namespace = module .info() .namespace_table .get(import_name.namespace_index); let field = module.info().name_table.get(import_name.name_index); if field == "_emscripten_memcpy_big" && namespace == "env" { return true; } } false }

  • reply
  • like

The emscripten compatibility layer is touch-and-go sometimes. Sometimes, when you compile rust into wasm, it compresses the signals and removes unused ones, which makes it unrunnable.

  • reply
  • like

It looks like from the code it’s implying we just need one import, and would be nice to know the exact min reqs of a module

Edited
  • reply
  • like