Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Rlib and .d file instead of .wasm

I want to compile a .rs file in a Rust lib to a .wasm.

RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown

Instead of a .wasm file I get a .Rlib and .d file. What do I need to change to get a .wasm?

like image 398
SurpriseMF Avatar asked Oct 19 '25 02:10

SurpriseMF


1 Answers

rustc considers .wasm files to fill the “native dynamic library” role in the WASM target. Add this to your Cargo.toml configuration to request that build instead of the default .rlib:

[lib]
crate-type = ["cdylib"]
like image 112
Kevin Reid Avatar answered Oct 20 '25 17:10

Kevin Reid