Does wasm-c-abi flag work with the wasm32-wasip1 target? on nightly? ie: -Zwasm-c-abi. I'm trying to bind a C ECS library (flecs) and compile to WASM for my game engine while using the WASM component model and wit-bindgen / cargo component. Also why does cargo component use wasm32-wasip1, should I be using wasm32-wasip2 at this point instead? What about wasm32-wasip1-threads and wasm64-unknown-unknown? These targets could solve several issues for me, if possible to use.
The wasm-c-abi
flag should have no effect on any WASI target, they already adhere to the specification.
C bindings generated by CC doesn't appear to work on the wasm32-wasip1 target on stable. Same with nightly and with the c abi flag.
TARGET = Some(wasm32-wasip1)
OPT_LEVEL = Some(0)
HOST = Some(x86_64-pc-windows-msvc)
cargo:rerun-if-env-changed=CC_wasm32-wasip1
CC_wasm32-wasip1 = None
cargo:rerun-if-env-changed=CC_wasm32_wasip1
CC_wasm32_wasip1 = None
cargo:rerun-if-env-changed=TARGET_CC
TARGET_CC = None
cargo:rerun-if-env-changed=CC
CC = None
cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
RUSTC_WRAPPER = None
cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
CRATE_CC_NO_DEFAULTS = None
cargo:rerun-if-env-changed=WASI_SYSROOT
WASI_SYSROOT = None
DEBUG = Some(true)
cargo:rerun-if-env-changed=CFLAGS_wasm32-wasip1
CFLAGS_wasm32-wasip1 = None
cargo:rerun-if-env-changed=CFLAGS_wasm32_wasip1
CFLAGS_wasm32_wasip1 = None
cargo:rerun-if-env-changed=TARGET_CFLAGS
TARGET_CFLAGS = None
cargo:rerun-if-env-changed=CFLAGS
CFLAGS = None
cargo:warning=In file included from flecs.c:20:
cargo:warning=./flecs.h:692:10: fatal error: 'assert.h' file not found
cargo:warning= 692 | #include <assert.h>
cargo:warning= | ^~~~~~~~~~
cargo:warning=1 error generated.
--- stderr
wasm32-wasip1
This doesn't look like an ABI issue to me.
daxpedda said:
This doesn't look like an ABI issue to me.
Hmm, you're right. It's a standard library dependency that would normally be provided by Emscripten. Is there no way for WASI to shim this in a similar way?
I think you might be looking for wasi-sdk?
It is indeed, I was able to get it to work by specifying the WASI-DK in many different build flags (RUSTFLAGS, CXXSTDLIB, CC, CXX, CXXFLAGS, build.rs bindgen and cc). I should really document this somewhere for Rust, the only place where I was able to find some of this is outdated information in this blog that has an expired SSL certificate that I had to look up on archive.org: https://web.archive.org/web/20240419144307/https://benw.is/posts/compiling-rust-to-wasi
Thank you though!
cc @benwis regarding the SSL cert expiration
Last updated: Nov 22 2024 at 16:03 UTC