Skip to content

Linking in Instantiation stage #547

@q82419

Description

@q82419

Hi, here's from WasmEdge, and I would want to implement the component-model on this runtime.
Hence there's no spec to clearly introduce the steps of instantiation such as WASM core, I may have to ask some basic questions about linking for a better design of our runtime data structure.
Maybe the questions are simple, or are described in the proposal docs, thanks for you all to answer.

The main question is about the import searching when linking.
Take the linking example in this repo:

;; app.wat
(component
  (import "libc" (core module $Libc ...))
  (import "libzip" (core module $Libzip ...))
  (import "libimg" (core module $Libimg ...))

  (import "zipper" (component $Zipper ...))
  (import "imgmgk" (component $Imgmgk ...))

  (core module $Main
    (import "libc" "memory" (memory 1))
    (import "libc" "malloc" (func (param i32) (result i32)))
    (import "zipper" "zip" (func (param i32 i32) (result i32 i32)))
    (import "imgmgk" "transform" (func (param i32 i32) (result i32 i32)))
    ...
    (func (export "run") (param i32 i32) (result i32 i32)
      ...
    )
  )

  ;; ... ignore bellow
)

When instantiating this component, the core:module $Main will be instantiated also.
As above, this component imports "libc", "libzip", and "libimg" modules.
Assume that the validation is passed.
Can we assume that all the imports of the core:module $Main will be reserved (found) in this component imports?

Another example for the nested component.

(component $A
  (import "libc" (core module $Libc ...))
  (component $B
    (core module $Main
      (import "libc" "memory" (memory 1))
      ...
      (func (export "run") (param i32 i32) (result i32 i32)
        ...
      )
    )
  )
  ...
)

For the nested component $B, should this component also import "libc" for the core:module to import?
If the import of "libc" is not necessary in $B, the import searching of the core:module $Main in component $B should access the imports of component $A?

Thank you for answering.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions