Skip to content

Cyclic import dependencies #1333

@sunfishcode

Description

@sunfishcode

Several folks having been looking at running AssemblyScript programs in Wasmtime, and while single-module programs work great, multiple-module programs, and programs which call into host APIs that need to call back into the AssemblyScript runtime, currently depend on cyclic imports, which not supported in the wasm spec.

There are two main techniques for avoiding such cycles:

  • In some cases, modules can be split, eg. replacing A -> B; B-> A with A0 -> B; B-> A1. This technique might be useful for the AssemblyScript memory allocation functions, splitting them into a separate module that other modules, and the host, can depend on.
  • Otherwise, import edges can be converted to dynamic edges, using call_indirect as described here.

One example of this is mentioned in this comment in an earlier issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions