Closed
Description
Given a crate with:
[lib]
crate-type = ["cdylib", "lib", "staticlib"]
cargo build --target wasm32-unknown-emscripten
invokes:
rustc … --crate-type cdylib --crate-type lib --crate-type staticlib --emit=dep-info,link --target wasm32-unknown-emscripten …
which causes:
thread 'rustc' panicked at 'src/librustc_codegen_ssa/back/linker.rs:893: building dynamic library is unsupported on Emscripten', src/librustc_middle/util/bug.rs:37:26
This behavior makes it impossible to support WASM and native (not WASM) dynamic libraries in the same crate.
It would be helpful if Cargo knew that wasm32-unknown-emscripten
doesn't support cdylib
, and didn't try to build it.
Note that unsupported cdylib
breaks builds that don't use the crate as a dynamic library, because Cargo seems to unconditionally build cdylib
even when the crate is used as a regular dependency linked as .rlib
.