WebAssembly / component-model

Repository for design and specification of the Component Model
Other
945 stars 79 forks source link

Static and dynamic libraries #359

Open oovm opened 4 months ago

oovm commented 4 months ago

Is there a specification to mark whether a component model should be (as a suggestion) a static library or a dynamic library?

Assume lib.wasm is a library, app.wasm is an application, and depends on lib.wasm.


Motivation

Although dynamic linking hell is a very bad problem, I think limited dynamic linking helps reduce the overall size of the final executable file

I developed a command line tool legion.wasm, which automatically looks for legion-plugin.wasm when encountering unknown instructions.

The plugin needs to use some definitions of the original application, which makes the plugin even larger.

Therefore, I hope there is some convention to specify that some dependencies should be compiled as a shared library as a whole, This can effectively reduce the overall size.

lukewagner commented 4 months ago

The Component Model mostly leaves all these options open to the producer toolchain, providing the raw linking primitives to allow the producer toolchain to precisely say what it wants. For example, check out this example, which I think avoids DLL hell while also sharing the appropriate amount of code, all unambiguously linked together via the C-M: https://github.com/WebAssembly/component-model/blob/main/design/mvp/examples/SharedEverythingDynamicLinking.md