Skip to content

unstable different-binary-name is not compatible with wasm32-unknown-emscripten #13358

@weihanglo

Description

@weihanglo

Problem

For wasm32-unknown-emscripten target, the path of the .wasm file name is embedded in the output .js file. However, different-binary-name changes both file name of .wasm and .js when uplifting final binaries to target/debug directory, but not the .wasm path embedded in .js file.

Steps

  1. Have a project enabling different-binary-name unstable feature
    cargo-features = ["different-binary-name"]
    
    [package]
    name = "a-b-c"
    version = "0.1.0"
    edition = "2021"
    [[bin]]
    name = "a-b-c"
    filename = "a-b-c_a_b_c"
    path = "src/main.rs"
    
  2. nix-shell -p emscripten
  3. rustup +nightly target add wasm32-unknown-emscripten
  4. cargo +nightly build
  5. ls target/wasm32-unknown-emscripten/debug/a-b-c_a_b_c.wasm and observe it exists
  6. rg '\.wasm' target/wasm32-unknown-emscripten/debug/a-b-c_a_b_c.js and observe wasmBinaryFile = 'a_b_c.wasm'

Possible Solution(s)

Do not change name of the .wasm file for wasm32-unknown-emscripten.

Notes

No response

Version

cargo 1.77.0-nightly (7bb7b5395 2024-01-20)
release: 1.77.0-nightly
commit-hash: 7bb7b539558dc88bea44cee4168b6269bf8177b0
commit-date: 2024-01-20

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-cargo-targetsArea: selection and definition of targets (lib, bins, examples, tests, benches)A-layoutArea: target output directory layout, naming, and organizationC-bugCategory: bugO-wasmOS: WASM target released issuesS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions