rust-lang / cc-rs

Rust library for build scripts to compile C/C++ code into a Rust library
https://docs.rs/cc
Apache License 2.0
1.77k stars 427 forks source link

Support compiling to wasm targets #1069

Open jozanza opened 2 months ago

jozanza commented 2 months ago

PR: https://github.com/rust-lang/cc-rs/pull/1068

For more context, in a wasm game engine SDK I maintain (turbo), I'm pulling in a crate (solana-sdk). However, cc-rs is deeply buried in dependencies of dependencies of that crate. This wouldn't be a terrible problem since cc-rs (especially the parallel feature stuff) is far from any code path that runs in wasm and optimization can get rid of a unused code, however, the compile_error! macro prevents cc-rs prevents builds from ever completing in the first place.

So the only option in my case (where cc-rs is buried deep in the dependency tree and I'm targeting wasm) currently is to fork and patch. This gets brittle fairly quickly since other dependencies can have version conflicts and force me to create more branches with version bumps and other minor tweaks over time.

I'm hoping we can land this patch and carve out exceptions for wasm with compile_error! moving forward 🙏🏽