Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cargo tries to build dynamic libraries for Emscripten targets #8496

Closed
kornelski opened this issue Jul 17, 2020 · 2 comments
Closed

Cargo tries to build dynamic libraries for Emscripten targets #8496

kornelski opened this issue Jul 17, 2020 · 2 comments
Labels
C-bug Category: bug

Comments

@kornelski
Copy link
Contributor

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.

@ehuss
Copy link
Contributor

ehuss commented Jul 17, 2020

This seems to have been changed in 1.45 (it no longer errors via rust-lang/rust#71804). Which version are you using?

This also sounds like a rustc issue (rust-lang/rust#67782), not a cargo one. Typically rustc ignores unsupported crate types (here)

@kornelski
Copy link
Contributor Author

Ah, I've had 1.44.1. Thanks for fixing this in negative amount of time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants