Stream: general

Topic: Does wasm-c-abi flag work with the wasm32-wasip1 target?


view this post on Zulip Troy Edwards (Sep 15 2024 at 12:13):

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.

view this post on Zulip daxpedda (Sep 15 2024 at 12:31):

The wasm-c-abi flag should have no effect on any WASI target, they already adhere to the specification.

view this post on Zulip Troy Edwards (Sep 15 2024 at 18:29):

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

view this post on Zulip daxpedda (Sep 15 2024 at 18:32):

This doesn't look like an ABI issue to me.

view this post on Zulip Troy Edwards (Sep 15 2024 at 18:35):

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?

view this post on Zulip Ramon Klass (Sep 15 2024 at 18:37):

I think you might be looking for wasi-sdk?

view this post on Zulip Troy Edwards (Sep 16 2024 at 15:50):

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

Is WASI preview 2 ready for prime time? I explore using it for my Rust/C project to bring additional functionality to the browser!

view this post on Zulip Troy Edwards (Sep 16 2024 at 15:50):

Thank you though!

view this post on Zulip Joel Dice (Sep 16 2024 at 17:00):

cc @benwis regarding the SSL cert expiration


Last updated: Dec 23 2024 at 12:05 UTC