Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embedding multiple engines implementing wasm C API #165

Open
chfast opened this issue Feb 15, 2021 · 3 comments
Open

Embedding multiple engines implementing wasm C API #165

chfast opened this issue Feb 15, 2021 · 3 comments

Comments

@chfast
Copy link

chfast commented Feb 15, 2021

Hi there,

Is there any practical way of building a binary containing multiple different wasm engines which all implement the WebAssembly C API?

@rossberg
Copy link
Member

Given typical linking models, which rely on a more or less global name space for public symbols, I don't that can be done in common environments. This isn't a problem specific to this API, though, AFAIAA.

What is the use case? If it is to select one engine at runtime, could you dynamically link it?

@jakobkummerow
Copy link
Collaborator

As long as you're building everything from source and you're using C++, I think this could fairly easily be done by adding namespaces: include several copies of wasm.hh, wrap the first in a namespace engine1 { ... }, the second in namespace engine2 { ... }, and so on. You'll then have to make the same edit to the respective engine's implementation of the API. Anywhere else in your code you can then choose to work with, for example, engine1::wasm::Store or engine2::wasm::Store.

If your requirement is to use unmodified/prebuilt engines, then I agree with @rossberg that you can only link one implementation of any given API at a time.

@zu1k
Copy link

zu1k commented Nov 7, 2022

We have a similar problem, but our needs are more specific in that we need to use multiple engines at the same time.

It looks like the go-bindings for all engines are using cgo, which are all load-time linking. Depending on the situation it looks like we need to maintain all the engine go-bindings ourselves to implement the runtime linking. This is very tedious work, I came to see any friend who encountered a similar problem and already had a more elegant solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants