-
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
Need help to run a supplied WASM file #19
Comments
The start function is defined by the wasm module as the entry point, e.g. a main() function. As long as your c file contains a main() function, your compiler should generate a start function, and you would simply do:
However, this won't generate any output, so it'll be hard to tell if it works. |
Hi .. Thanks.
I realize now though that it is creating a .so file so do I misunderstand the function of the -r flag? Should I not interpret this -r flag will immediately run the fib2.so that is generated or should I assume innative in fact tried to run the .so but that it failed silently for some reason? Thanks. |
Innative generates a .so file and then loads and runs it when |
Ignore the previous comment. I think there was flag I passed to clang that prevented this from recognizing main. I'll confirm. |
You know .. I just can't get this to run. Is it looking for an export of _start or is it looking for main?
This above is what is being exported. Should innative register these exports and call main? |
None of these are a start function. WebAssembly defines a start function in a special section in the webassembly module. Someone else, however, has alerted me that compilers aren't actually using this part of the webassembly standard, so it seems that every single webassembly compiler isn't actually standards compliant. I may have to modify inNative to take an alternative start function if this is the case. For now, you can manually define |
I've added an issue tracking this and will be filing a bug with LLVM's webassembly codegen to try to fix this upstream. |
Thanks .. I was able to manually add the start after dumping to wat, but at first it did not work because my main function had been given 2 extra arguments at some point during compilation and required a return based on my original C code. I was forced to change the main in the original code to some other name and remove the int as a return ..
Then manually adding start by hand and running. I still am trying to figure a way to automate this though. I am using clang-8 with WASI support. My biggest problem appears to be a bunch of imports for wasi_unstable that get included unless I used the -nostartfiles flag. I am unsure of this flag because it is not mentioned in the --help but nonetheless greatly simplifies the WASM file and doesn't include unneeded imports. Unfortunately though no start function gets specified. Using linker flags like lto and gc-sections do not seem to help. |
inNative doesn't support WASI yet, so if clang is insisting on requiring WASI to compile standalone EXEs, there isn't much I can do until I add WASI support. I believe WASI defines it's own imaginary entry-point, which is incompatible with the standard webassembly entry-point, which is causing a lot of problems. Technically, |
Ok, Thanks. It's your call on whether to close this. I think I understand how to run, it's just that the toolchain I am using isn't producing WASM files that are compatible at this time. |
Related .. I am looking at your benchmark-fac.wat file and wondering how is the test script running this. I do not see a (start) instruction in the wat. I see in test.cpp and benchmark.cpp where it looks like you are loading benchmark-fac and then n-body, etc. But I am having a hard time parsing where you actually instantiate and where you decide to run. When I compile a wasm file it creates a .so file and then does nothing unless I manually add a start function that has the exactly zero return and zero parameters. If I wanted to automate running (without modifying files by hand and adding start functions) what are the steps then to link and run standalone this .so that is generated if I always have the same name for function entry?
I was trying to follow your test script. innative-cmd seems to generate a .so file and I assume it is loading and running .so when I supply the -r flag. If this is the case I would expect it to be possible to link that generated .so that's missing the entry with someother file that does have proper entry function that innative expects and then load and run that new .so with innative-cmd. However, I am not sure innative-cmd can load an .so that it didn't generate? Any pointers? |
I suggest reviewing the readme file, because you don't seem to completely understand how innative works. inNative can load any webassembly you want if you embed the library into your program. A standalone webassembly module is one that has a start function. If it doesn't have a start function, it's not standalone. The benchmarks are not standalone webassembly modules. |
Yes .. I see. I've actually run the embedded case with innative but was hoping innative-cmd was capable as a standalone. Sounds like it is, but there is no flexibility if the start function is not specified. Would it be straight-forward (which files) to add a flag to innative-cmd to specify a custom start function? |
Simply adding a flag to change the start function would be easy, but that's not necessarily sufficient. Clang is generating a start function with a return value and arguments, so the flag must either be defined as passing 0 to all parameters, or parameters must be added to the |
Hi .. What is the command line to use to run innative standalone (innative-cmd) with a wasm file that I supply. For example I have compiled fibonaci.c to a wasm, that relies on no imports and like to simply run this on the linux command line using innative-cmd
I see these options in help:
But it is still not clear the command line options to use.
What start function is innative looking for default? Can you provide a simple example here?
Thanks!
The text was updated successfully, but these errors were encountered: