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

Support wasm3 compile flags #22

Open
jiayihu opened this issue Oct 19, 2020 · 3 comments
Open

Support wasm3 compile flags #22

jiayihu opened this issue Oct 19, 2020 · 3 comments

Comments

@jiayihu
Copy link
Contributor

jiayihu commented Oct 19, 2020

With #21 one can pass the propert clang flags in order to set the compilation flags in https://github.com/wasm3/wasm3/blob/master/source/m3_config.h, for instance:

BINDGEN_EXTRA_CLANG_ARGS="--sysroot=/usr/local/opt/gcc-arm-none-eabi/arm-none-eabi -Dd_m3HasFloat=0" cargo build

Currently passing -Dd_m3HasFloat=0 results in this error because the wasm3 signature changes:

error[E0061]: this function takes 4 arguments but 5 arguments were supplied
   --> /Users/jiayihu/Desktop/Repo/wasm3-rs/src/function.rs:185:13
    |
185 |             (*_pc.cast::<ffi::IM3Operation>()).expect("IM3Operation was null")(
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 4 arguments
186 |                 _pc.add(1),
    |                 ----------
187 |                 _sp,
    |                 ---
188 |                 _mem,
    |                 ----
189 |                 _r0,
    |                 ---
190 |                 _fp0,
    |                 ---- supplied 5 arguments

Passing d_m3FixedHeap, such as -Dd_m3FixedHeap=(8 * 1024), also results in compilation error because the (8 * 1024) syntax is not supported by #21 .

I just wanted to report the issues and causes for anyone interested. After being finally able to compile everything, I realized while I was implementing the intrinsics for calloc, free, realloc (required if d_m3FixedHeap is unset) that I was not very satisfied with the wasm3 implementation itself. Its C code is very hard to read and extend IMO. I'm ditching in favor of https://github.com/paritytech/wasmi or writing a WASM runtime myself.

@Veykril
Copy link
Collaborator

Veykril commented Oct 19, 2020

Thanks for the heads up, I'll take a look at this when I can. I can agree that the C-source of wasm3 is very difficult to read as it looks very opinionated style-wise with the massive amount of macro magic going on. I hope wasmi will do you well 👍

@jiayihu
Copy link
Contributor Author

jiayihu commented Oct 19, 2020

Thanks! Also additional note: although wasm3 supports d_m3HasFloat to disable float operations, it's a all-or-nothing flag. In my case, the STM32F4 board has FPU support but only for single-precision operations. Disabling floating point operations would severely limit the runnable WASM modules, while enabling the flag would probably result in runtime error for f64 types I guess.

@vshymanskyy
Copy link
Member

@jiayihu i think we could add a flag to treat all f64 types as f32 (loosing precision), at some point.
Regarding the changing signatute. @Veykril with the latest wasm3, you should be able to use just the public API (only wasm3.h). Let me know if you struggle to implement some functionality via the new API.

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

No branches or pull requests

3 participants