Skip to content

Add C++ Support for WebAssembly #2857

@NathanKolbas

Description

@NathanKolbas

Is your feature request related to a problem? Please describe.
I have a Rust crate that uses some C++ code. The C++ code is compiled when the Rust code is compiled using build.rs with cc-rs. Since the target is wasm32-unknown-unknown when compiling for web with flutter_rust_bridge_codegen build-web cc-rs uses the C compiler. However, wasm32-unknown-unknown is needed since wasm-bindgen uses this build to generate the JavaScript glue. I can compile the code just fine using emscripten with target wasm32-unknown-emscripten.

Describe the solution you'd like
Would it be possible to support emscripten so that we can take advantage of C++ in WebAssembly? What would it take for flutter_rust_bridge to support C++?

Describe alternatives you've considered
I tried to compile separately and then link after the fact but I run into error: cannot import from modules (env) with --no-modules (missing symbols) and the linker ends up using the C linker instead of the C++ due to the target.
Perhaps there is a workaround that I am not aware of? Maybe there is something better that I should be using instead of emscripten.

Additional context
I wouldn't mind helping out with this or working on a PR but would like some direction first or how web support currently works today.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions