Skip to content

Cargo tries to build dynamic libraries for Emscripten targets #8496

Description

@kornelski

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions