-
Notifications
You must be signed in to change notification settings - Fork 165
Does compiler attribute also work in wasm32-wasi-gcc? #259
Comments
We haven't tried using gcc to emit wasm at all. In theory, the wasm it emits should work. I'm not sure how to ensure that gcc will emit an export for a given function. I'm not able to find docs on gcc's support of wasm on the gnu site, where did you get this gcc toolchain from? |
Isn't I believe I have to elaborate on my issue. All I want to do is to let a function // a.c -> a.wasm
extern void foo();
int main() {
foo();
}
// b.c -> b.wasm
#include <stdio.h>
void foo() {
printf("this is foo function");
} Specifically, I already know if I use Sorry for not describing my issue clearly. |
Solving your immediate issue should be as simple as defining a macro like:
And then prepend your function definitions with the macro in the same way as the The larger thing you’re trying to do with dynamic linking is a little trickier. Lucet provides a lower level interface to working with wasm modules and instances. In principle, there’s no reason you can’t do it. But it won’t be quite as straight-forward as in javascript. |
@tyler
As you can see, I failed to export foo function from
I wonder if those steps make sense and possible to do it. By the way, I use the attribute which is mentioned here. I am able to specify exactly which module to link the |
Are you using the If you are using |
To answer the second part of the question - at this time, there is not a straightforward way to instantiate two webassembly modules and link them together using Lucet. You'd have to create rust functions in order to call the export function of one module from the import function of another. Even if you could do that, there's no way to share other imported/exported instance resources (memories, tables, globals) between instances in Lucet. This isn't a restriction we intend to have forever, but at the moment, adding those capabilities isn't a high priority, because the applications we're using Lucet for does not require that sort of sophistication. If you absolutely need those capabilities, you could look into https://github.com/CraneStation/wasmtime/, which I believe does support that kind of thing. Lucet and Wasmtime share a bunch of code but I'm not super familiar with that aspect of their codebase. |
@pchickey
After I manually add |
I believe wasmtime really would be a better place to discuss my issue and I already create another issue in that repo.wasmtime's contributor offers some useful comments. I will close this issue. Feel free to ask me if someone is curious about how I solve the issue. Thank you both @pchickey and @tyler . |
I try to use
used
attribute in gcc to force myenterFunc
appears in the wasm name section. However, it seems doesn't work. I wonder could I use all features in original clang or gcc and if not, how can I force my function to be compiled?The text was updated successfully, but these errors were encountered: