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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasm-pack build failed when some crate depend on the net2 crate! #657

Closed
Itanq opened this issue May 25, 2019 · 2 comments
Closed

wasm-pack build failed when some crate depend on the net2 crate! #657

Itanq opened this issue May 25, 2019 · 2 comments

Comments

@Itanq
Copy link

Itanq commented May 25, 2019

馃悰 Bug description

When I clone the project template with this command:

argo generate --git https://github.com/rustwasm/wasm-pack-template

I can build the rust wasm project successffuly. But when I write same dependencies, such as url, reqwest, openssl, I build failed. This error looks like the reason for using the rust2015 version, such as following:

[INFO]: Checking for the Wasm target...
[INFO]: Compiling to Wasm...
   Compiling net2 v0.2.33
   Compiling failure_derive v0.1.5
   Compiling ryu v0.2.8
   Compiling serde v1.0.91
   Compiling foreign-types v0.3.2
   Compiling httparse v1.3.3
   Compiling regex v1.1.6
   Compiling regex-syntax v0.6.6
   Compiling crc32fast v1.2.0
   Compiling miniz_oxide v0.2.1
   Compiling encoding_rs v0.8.17
   Compiling rustc_version v0.2.3
   Compiling rand_pcg v0.1.2
   Compiling rand_chacha v0.1.1
   Compiling rand v0.6.5
error[E0432]: unresolved import `sys`
  --> /home/zmant/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/net2-0.2.33/src/tcp.rs:18:5
   |
18 | use sys::c;
   |     ^^^ maybe a missing `extern crate sys;`?

error[E0432]: unresolved import `sys`
  --> /home/zmant/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/net2-0.2.33/src/udp.rs:18:5
   |
18 | use sys::c;
   |     ^^^ maybe a missing `extern crate sys;`?

error[E0432]: unresolved import `sys`
  --> /home/zmant/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/net2-0.2.33/src/socket.rs:22:5
   |
22 | use sys;
   |     ^^^ no `sys` in the root

error[E0432]: unresolved import `sys`
  --> /home/zmant/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/net2-0.2.33/src/socket.rs:23:5
   |
23 | use sys::c;
   |     ^^^ maybe a missing `extern crate sys;`?

error[E0432]: unresolved import `sys`
  --> /home/zmant/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/net2-0.2.33/src/ext.rs:19:5
   |
19 | use sys;
   |     ^^^ no `sys` in the root

error[E0432]: unresolved import `sys`
  --> /home/zmant/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/net2-0.2.33/src/ext.rs:20:5
   |
20 | use sys::c;
   |     ^^^ maybe a missing `extern crate sys;`?

   Compiling rand_isaac v0.1.1
   Compiling rand_xorshift v0.1.1
   Compiling rand_hc v0.1.0
   Compiling libc v0.2.55
error[E0412]: cannot find type `c_int` in this scope
  --> /home/zmant/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/net2-0.2.33/src/socket.rs:30:24
   |
30 |     pub fn new(family: c_int, ty: c_int) -> io::Result<Socket> {
   |                        ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
   |
11 | use std::os::raw::c_int;

But the relevant build tools are the latest, such as following:

zmant@zmant-desktop:~/Project/Rust/wasm-pack-template$ rustc --version
rustc 1.36.0-nightly (73a3a90d2 2019-05-17)
zmant@zmant-desktop:~/Project/Rust/wasm-pack-template$ cargo --version
cargo 1.36.0-nightly (c4fcfb725 2019-05-15)
zmant@zmant-desktop:~/Project/Rust/wasm-pack-template$ wasm-pack --version
wasm-pack 0.8.1

I can successfully build net2 crates with cargo build command

zmant@zmant-desktop:~/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/net2-0.2.33$ cargo build
    Updating `git://mirrors.ustc.edu.cn/crates.io-index` index
   Compiling libc v0.2.55
   Compiling cfg-if v0.1.9
   Compiling net2 v0.2.33 (/home/zmant/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/net2-0.2.33)

I have been working on this problem for several days, and I haven't found a solution on other websites, such as stackoverflow. Can someone please help me to find out what the problem is.
Thanks you very much.

馃 Expected Behavior

Build success

馃憻 Steps to reproduce

cargo generate --git https://github.com/rustwasm/wasm-pack-template

enter:

wasm-pack-template

and then go to the wasm-pack-template floder.
Edit the Cargo.toml such as:

[package]
name = "music"
version = "0.1.0"
authors = [""]
edition = "2018"

[lib]
crate-type = ["cdylib", "rlib"]

[features]
default = ["console_error_panic_hook"]

[dependencies]
url = "1.7"
reqwest = "0.9"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
md5 = "0.6"
hex = "0.3"
openssl = "0.10"
regex = "1.1"
wasm-bindgen = "0.2"

console_error_panic_hook = { version = "0.1.1", optional = true }
wee_alloc = { version = "0.4.2", optional = true }

[dev-dependencies]
wasm-bindgen-test = "0.2"

[profile.release]
opt-level = "s"

use wasm-pack build to build, will build failed! 100% reproduce

Does anyone have the same problem?

馃實 Your environment

wasm-pack version: wasm-pack 0.8.1
rustc version: rustc 1.36.0-nightly (73a3a90d2 2019-05-17)

@csmoe
Copy link
Member

csmoe commented Jul 3, 2019

wasm-pack's target_os is wasm32, which isn't included here.
https://github.com/rust-lang-nursery/net2-rs/blob/eda403f03033b58560d81b821f0df822f50cde4d/src/socket.rs#L15-L16
some of your dependies cannot work on wasm32.

@Itanq
Copy link
Author

Itanq commented Jul 3, 2019

wasm-pack's target_os is wasm32, which isn't included here.
https://github.com/rust-lang-nursery/net2-rs/blob/eda403f03033b58560d81b821f0df822f50cde4d/src/socket.rs#L15-L16
some of your dependies cannot work on wasm32.

Yes, the net2 can't build on wasm32, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants