Skip to content

cargo component does not obey .cargo/config.toml #364

Open

Description

@oovm

I use .cargo/config.toml to control the compilation of workspace.

# .cargo/config.toml
[build]
target = "wasm32-wasip2"

But cargo component build still generates wasm32-wasip1

cargo-component-component 0.19.0

Activity

  1. sunfishcode commented on Jan 7, 2025

    @sunfishcode
    Member

    cargo component itself uses the Rust wasm32-wasip1 target to produce core Wasm modules, and applies the component adapter to produce Wasm components. It doesn't currently work with the wasm32-wasip2 target.

  2. tpmccallum commented on Feb 26, 2025

    @tpmccallum

    Thanks @sunfishcode I also just ran into this issue.
    Interestingly cargo component will actually create a .wasm file in the wasm32-**wasip2** path though:

    rm -rf target
    ls target/wasm32-wasip2/debug/compress.wasm

    Correctly produces:

    ls: target/wasm32-wasip2/debug/compress.wasm: No such file or directory

    If we:

    cargo component build --target wasm32-wasip2

    We get:

    Generating bindings for compress (src/bindings.rs)
    Compiling wasm-metadata v0.225.0
    
    ...
    
    Compiling wit-component v0.225.0
    Compiling wit-bindgen v0.39.0
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 29.20s
     Creating component target/wasm32-**wasip1**/debug/compress.wasm

    And interestingly the wasip2 path has a newly generated .wasm file:

    ls -lah target/wasm32-wasip2/debug/compress.wasm

    Produces:

    -rw-r--r--  1 tpmccallum  tpmccallum   8.4M 26 Feb 11:24 target/wasm32-wasip2/debug/compress.wasm

    To prevent confusion, could the command warn/mention that "cargo component doesn't currently work with the wasm32-wasip2 target" and then only write to the target/wasm32-wasip1 path?

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions