-
Notifications
You must be signed in to change notification settings - Fork 15
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
compile a wasm file compiled by assemblyscript #51
Comments
Can you upload the assembly script source and the resulting wasm file? |
|
This is the problem. Assemblyscript is apparently creating it's own "init" function that does not adhere to any actual webassembly standard. inNative cannot support arbitrary start functions - this particular one takes a completely custom set of arguments that do not make sense outside of assemblyscript. This would require, at minimum, an assemblyscript environment that itself knows how to pass the correct arguments to this function - whatever they are. Alternatively, you can compile a DLL instead of an EXE and call this function yourself. Simply use Note that the current assemblyscript environment is available here, which will allow it to link but won't actually do anything: https://github.com/innative-sdk/innative/blob/master/innative-assemblyscript/assemblyscript.c |
how can i compile DLL, is there any guide? And i'm also confuse how to use the assemblyscript.c you given? thanks |
Please read the Wiki for detailed instructions. The assemblyscript library would be used like this:
Check the Quick Start Guide for a quick overview of how to compile and load a DLL. |
Assemblyscript uses Binaryen for wasm codegen (same as emscripten btw). And all follow by wasm spec. That wasm module is highly depend on web host and just expose (exported) two functions. So you really need compile it as dynamic library |
The assemblyscript is assuming there is an entry function with arguments, but because you can't set that as the "start" function in the webassembly module, it's set to "empty" and you must manually invoke whatever init function in order to run the program. "init" may be a common entry point, but it is not a standard one, and thus a runtime like inNative cannot possibly know it exists, which means it cannot compile an EXE. Whether or not this is "Standard" is up for debate, but this is a problem that keeps coming up over and over again - people try to build a program with a standard main function, then complain because it is impossible for a runtime like this to actually run the program. |
No, it's just some exported function by user which manually called on host specifically for this module |
At this point it might be worth making a library the default behavior if nothing actually compiles things that are executables. |
What if follow this rules?
|
I will likely have to do this, yes. I was trying to make everything explicit, but if this is a common situation I have no choice but to simply default to a library if no start function is found. This change will go in the next release. |
Thanks for you reply, i have read (https://github.com/innative-sdk/innative/wiki/Quick-Start-Guide), but i still not very clear how to build the dll, it said "Simply place this library files somewhere in your project" But my wasm file just use Assemblyscript to obtain? where these libs to put? how to compile lib i needed? is it mean i should compile assemblyscript.c file you provided to a lib file using gcc. And then where the command "err = (exports.AddEmbedding)(env, 0, (void)"innative-assemblyscript.lib", 0);" should i add? The instruction also said a lot commands about set up the environment, but i also don't know where these commands to add? In addition, i tried to run wast file in spec\test\core to know more about how innative works, it also has error: no start start function . how can i to run tests you provided ? is there any standalone webassembly files can be compiled by innative, thanks a lot! |
I do not know how to set up a project using only assemblyscript. The provided instructions are for a C program that loads the DLL. If you need to load the DLL using assemblyscript, I cannot provide instructions. You can try to ask in the discord chat, but I don't know of anyone who has actually gotten this to work. You cannot create standalone assemblyscript binaries from webassembly right now. It is not possible. It might be possible after WASI support is added, but it hasn't been added yet. The tests are not standalone. There are operating system specific example scripts located in |
Thanks for your reply. Is it mean Innative only can be used for wasm file compiled from c program? I have cloned this project, If i want to run innative-sdk/innative/innative-test/ in this project, what should i do? just make in this directory? |
For all practical purposes, inNative currently can only be embedded from inside a C program. It provides a C interface that will allow languages with FFI to call it as well, but no such bindings have been written yet. Follow the instructions for building from source, and |
This can't be fully addressed because there's no way to build an EXE out of something that takes an arbitrary init function. Custom start functions were added with b69b45a |
Hi, Can I compile a wasm file compiled by assemblyscript not from c++, when i executed innative xx.wasm, it said ERR_FATAL_INVALID_MODULE, why? thanks
The text was updated successfully, but these errors were encountered: