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.76k stars 425 forks source link

>= 1.0.102 wasm build breaks #1125

Closed juntyr closed 2 days ago

juntyr commented 3 days ago

https://github.com/rust-lang/cc-rs/pull/1114 conflates wasm with wasi targets. While wasi targets should change the sysroot to the wasi-sdk-provided one, the non-wasi target wasm32-unknown-unknown should probably keep the default sysroot.

https://github.com/rust-lang/cc-rs/pull/1105 extended the disabling of wasm exceptions from just wasm32-wasip1 to all wasi wasm targets. While this is technically correct, I am building a wasip1 module with exceptions (by stubbing some functions), which broke after upgrading cc. Perhaps cc could somehow allow a build-script to opt out of disabling the exceptions?

Thank you for your help!

NobodyXu commented 3 days ago

the non-wasi target wasm32-unknown-unknown should probably keep the default sysroot.

Thanks, so looks like we need to special case it.

While this is technically correct, I am building a wasip1 module with exceptions (by stubbing some functions), which broke after upgrading cc.

Maybe CRATE_CC_NO_DEFAULTS could help here?

juntyr commented 2 days ago

While this is technically correct, I am building a wasip1 module with exceptions (by stubbing some functions), which broke after upgrading cc.

Maybe CRATE_CC_NO_DEFAULTS could help here?

Thanks for the suggestion! Setting CRATE_CC_NO_DEFAULTS=1 did get me closer to a solution, though I had to manually set some flags, e.g. -O3, myself to regain the previous behavior. This is good enough for me right now :)