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 component does not obey .cargo/config.toml #364

Open
oovm opened this issue Dec 22, 2024 · 2 comments
Open

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

oovm opened this issue Dec 22, 2024 · 2 comments

Comments

@oovm
Copy link

oovm commented Dec 22, 2024

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
@sunfishcode
Copy link
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.

@tpmccallum
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants