Recently I knew about web assembly and was messing around with it in rust. Eventually I run into build problem. My toml file looks like this
[package]
name = "clipboard-manager"
version = "0.1.0"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
default = ["console_error_panic_hook"]
[dependencies]
x11-clipboard = "0.5.2"
wasm-bindgen = "0.2.63"
js-sys = "0.3.55"
console_error_panic_hook = { version = "0.1.6", optional = true }
#libc = "0.2.105"
# log = "0.4.14"
# x11 = "2.19.1"
[profile.release]
# Tell `rustc` to optimize for small code size.
opt-level = "s"
[lib]
crate-type = ["cdylib", "rlib"]
And when I want to build .wasm
file with wasm-pack build --target web
command I get bunch of errors like this
error[E0425]: cannot find function `malloc` in crate `libc`
--> /mnt/commondisk/filip/Development/personal/clipboard-manager/target/wasm32-unknown-unknown/release/build/xcb-64883900109c6e35/out/shape.rs:98:29
|
98 | let raw = libc::malloc(32 as usize) as *mut xcb_shape_notify_event_t;
| ^^^^^^ not found in `libc`
error[E0425]: cannot find function `malloc` in crate `libc`
--> /mnt/commondisk/filip/Development/personal/clipboard-manager/target/wasm32-unknown-unknown/release/build/xcb-64883900109c6e35/out/xfixes.rs:238:29
|
238 | let raw = libc::malloc(32 as usize) as *mut xcb_xfixes_selection_notify_event_t;
| ^^^^^^ not found in `libc`
error[E0425]: cannot find function `malloc` in crate `libc`
--> /mnt/commondisk/filip/Development/personal/clipboard-manager/target/wasm32-unknown-unknown/release/build/xcb-64883900109c6e35/out/xfixes.rs:330:29
|
330 | let raw = libc::malloc(32 as usize) as *mut xcb_xfixes_cursor_notify_event_t;
| ^^^^^^ not found in `libc`
I maneged to build wasm module by commenting out x11-clipboard
dependency. I tried to build this module with x11-clipboard
dependencies and it was also failing until I commented out xcb
dependency. It also fails if I add x11
crate. For a while I thought libc
could be a problem but I had not problem building module with this dependency.
Does anyone know why some dependencies cause building process failing and how to fix it? If it's impossible to fix can someone explain me why? Thanks in advance!