Welcome to the Linux Foundation Forum!

Rust WebAssembly Host Runtimes - wasm3 bindgen compilation issue

Hello. I'm encountering an error in this section of the course:

  1. Using WebAssembly Host Runtimes
    Ways To Host WebAssembly Modules
    Creating a Wasm3 Host

If anyone can help me resolve it, it'd be much appreciated

I've installed clang with the following commands:

sudo apt update
sudo apt install clang

I get this error when I try to run the project:

cargo run 
...
Compiling bindgen v0.59.2
error: failed to run custom build command for `wasm3-sys v0.3.0`

Caused by:
  process didn't exit successfully: `rust-host/target/debug/build/wasm3-sys-5d19accd8ca6b736/build-script-build` (exit status: 101)
  --- stderr
  thread 'main' panicked at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.59.2/src/ir/context.rs:878:9:
  "M3Global_union_(anonymous_at_wasm3/source/m3_env_h_131_5)" is not a valid Ident
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Here is my setup:
clang:
Ubuntu clang version 18.1.3 (1ubuntu1)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
rustc:
rustc 1.83.0 (90b35a623 2024-11-26)
cargo:
cargo 1.83.0 (5ffbef321 2024-10-29)
OS:
Ubuntu 24.04
x86_64 GNU/Linux (kernel 6.1.112+)

Here is my Cargo.toml

[package]
name = "rust-host"
version = "0.1.0"
edition = "2021"

[dependencies]
wasm3 = { version = "0.3.0", features = ["build-bindgen"] }

This StackOverflow post mentions upgrading to bindgen 0.6.2 for Clang versions >= 16. But I'm not sure how I can do that as the build seems to be stuck on Bindgen v0.59.2. I'm quite new to Rust. If anyone can help solve this, it'd be great

Categories

Upcoming Training