Uploaded image for project: 'Rust Driver'
  1. Rust Driver
  2. RUST-822

Error: Compiling your crate to WebAssembly failed

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      I'm not sure what is going on here, but without adding anything to my lib.rs to reference any of this code, simply adding the 2.0.0-beta to my TOML and attempting to wasm-pack it fails. 

      It seems clear that some dependany might not be configured for wasm32-unknown-unknown because of a "Unsupported target OS!" error. 

      The rest is extremely confusing, I keep reading examples of how to implement mongo in rust, but this and/or other early versions of the crates just throw errors.

      Is none of this designed to support WASM? I would love to be able to directly connect to a mongodb instance from WASM so that I can move forward with my project. 

      I apologize if this isn't the appropriate place for this, I'm at my wits end trying to figure out how to get past square one with this and the examples all use main() and don't seem to be configured to run with bind-gen. 

      Below are the wasm-pack errors I'm getting simply adding your package.

      [INFO]: Checking for the Wasm target...
      [INFO]: Compiling to Wasm...
      Compiling socket2 v0.4.0
      Compiling hostname v0.3.1
      Compiling generic-array v0.14.4
      Compiling futures-macro v0.3.15
      Compiling tokio v1.6.0
      Compiling futures-util v0.3.15
      Compiling crossbeam-utils v0.8.4
      Compiling indexmap v1.6.2
      Compiling parking_lot_core v0.8.3
      Compiling ahash v0.7.3
      Compiling futures-core v0.3.15
      Compiling memchr v2.4.0
      error: Unsupported target OS! Create an issue: https://github.com/svartalf/hostname/issues/new
      --> C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\hostname-0.3.1\src\lib.rs:81:9

      81 | compile_error!("Unsupported target OS! Create an issue: https://github.com/svartalf/hostname/issues/new");

      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

      error[E0433]: failed to resolve: use of undeclared crate or module `sys`
      --> C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\hostname-0.3.1\src\lib.rs:105:5

      105 | sys::get()

      ^^^ use of undeclared crate or module `sys`

      error: aborting due to 2 previous errors

      For more information about this error, try `rustc --explain E0433`.
      error: could not compile `hostname`

      To learn more, run the command again with --verbose.
      warning: build failed, waiting for other jobs to finish...
      error[E0432]: unresolved import `crate::sys`
      --> C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\sockaddr.rs:5:12

      5 | use crate::sys::

      { | ^^^ | | | unresolved import | help: a similar path exists: `crate::socket::io::sys` error[E0432]: unresolved imports `crate::sys`, `crate::sys` --> C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\socket.rs:21:12 | 21 | use crate::sys::\{self, c_int, getsockopt, setsockopt, Bool}

      ;

      ^^^ ^^^^ no `sys` in the root
       
      unresolved import
      help: a similar path exists: `crate::socket::io::sys`

      error[E0432]: unresolved import `sys`
      --> C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\lib.rs:129:5

      129 | use sys::c_int;

      ^^^ use of undeclared crate or module `sys`

      error[E0433]: failed to resolve: unresolved import
      --> C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\sockaddr.rs:114:29

      114 | let ip = crate::sys::from_in_addr(addr.sin_addr);

      ^^^
       
      unresolved import
      help: a similar path exists: `crate::socket::io::sys`

      error[E0433]: failed to resolve: unresolved import
      --> C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\sockaddr.rs:121:29

      121 | let ip = crate::sys::from_in6_addr(addr.sin6_addr);

      ^^^
       
      unresolved import
      help: a similar path exists: `crate::socket::io::sys`

      error[E0433]: failed to resolve: unresolved import
      --> C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\sockaddr.rs:172:30

      172 | sin_addr: crate::sys::to_in_addr(&addr.ip()),

      ^^^
       
      unresolved import
      help: a similar path exists: `crate::socket::io::sys`

      error[E0433]: failed to resolve: unresolved import
      --> C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\sockaddr.rs:207:31

      207 | sin6_addr: crate::sys::to_in6_addr(addr.ip()),

      ^^^
       
      unresolved import
      help: a similar path exists: `crate::socket::io::sys`

      error[E0433]: failed to resolve: use of undeclared crate or module `sys`
      --> C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\lib.rs:149:37

      149 | pub const IPV4: Domain = Domain(sys::AF_INET);

      ^^^ use of undeclared crate or module `sys`

      error[E0433]: failed to resolve: use of undeclared crate or module `sys`
      --> C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\lib.rs:152:37

      152 | pub const IPV6: Domain = Domain(sys::AF_INET6);

      ^^^ use of undeclared crate or module `sys`

      error[E0433]: failed to resolve: use of undeclared crate or module `sys`
      --> C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\lib.rs:191:35

      191 | pub const STREAM: Type = Type(sys::SOCK_STREAM);

      ^^^ use of undeclared crate or module `sys`

      error[E0433]: failed to resolve: use of undeclared crate or module `sys`
      --> C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\lib.rs:196:34

      196 | pub const DGRAM: Type = Type(sys::SOCK_DGRAM);

      ^^^ use of undeclared crate or module `sys`

      error[E0433]: failed to resolve: use of undeclared crate or module `sys`
      --> C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\lib.rs:200:38

      200 | pub const SEQPACKET: Type = Type(sys::SOCK_SEQPACKET);

      ^^^ use of undeclared crate or module `sys`

      error[E0433]: failed to resolve: use of undeclared crate or module `sys`
      --> C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\lib.rs:204:32

      204 | pub const RAW: Type = Type(sys::SOCK_RAW);

      ^^^ use of undeclared crate or module `sys`

      error[E0433]: failed to resolve: use of undeclared crate or module `sys`
      --> C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\lib.rs:231:43

      231 | pub const ICMPV4: Protocol = Protocol(sys::IPPROTO_ICMP);

      ^^^ use of undeclared crate or module `sys`

      error[E0433]: failed to resolve: use of undeclared crate or module `sys`
      --> C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\lib.rs:234:43

      234 | pub const ICMPV6: Protocol = Protocol(sys::IPPROTO_ICMPV6);

      ^^^ use of undeclared crate or module `sys`

      error[E0433]: failed to resolve: use of undeclared crate or module `sys`
      --> C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\lib.rs:237:40

      237 | pub const TCP: Protocol = Protocol(sys::IPPROTO_TCP);

      ^^^ use of undeclared crate or module `sys`

      error[E0433]: failed to resolve: use of undeclared crate or module `sys`
      --> C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\lib.rs:240:40

      240 | pub const UDP: Protocol = Protocol(sys::IPPROTO_UDP);

      ^^^ use of undeclared crate or module `sys`

      error[E0433]: failed to resolve: use of undeclared crate or module `sys`
      --> C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\lib.rs:272:18

      272 | self.0 & sys::MSG_TRUNC != 0

      ^^^ use of undeclared crate or module `sys`

      error[E0433]: failed to resolve: use of undeclared crate or module `sys`
      --> C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\lib.rs:280:33

      280 | pub struct MaybeUninitSlice<'a>(sys::MaybeUninitSlice<'a>);

      ^^^ use of undeclared crate or module `sys`

      error[E0433]: failed to resolve: use of undeclared crate or module `sys`
      --> C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\lib.rs:299:31

      299 | MaybeUninitSlice(sys::MaybeUninitSlice::new(buf))

      ^^^^^^^^^^^^^^^^ not found in `sys`

      help: consider importing this struct

      62 | use crate::socket::MaybeUninitSlice;

      error[E0308]: mismatched types
      --> C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\socket.rs:1451:23

      1451 | from!(net::TcpStream, Socket);

      ^^^^^^ expected struct `Socket`, found `()`

      ::: C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\lib.rs:104:16

      104 | fn from(socket: $from) -> $for {

      ---- implicitly returns `()` as its body has no tail or `return` expression

      error[E0308]: mismatched types
      --> C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\socket.rs:1452:25

      1452 | from!(net::TcpListener, Socket);

      ^^^^^^ expected struct `Socket`, found `()`

      ::: C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\lib.rs:104:16

      104 | fn from(socket: $from) -> $for {

      ---- implicitly returns `()` as its body has no tail or `return` expression

      error[E0308]: mismatched types
      --> C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\socket.rs:1453:23

      1453 | from!(net::UdpSocket, Socket);

      ^^^^^^ expected struct `Socket`, found `()`

      ::: C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\lib.rs:104:16

      104 | fn from(socket: $from) -> $for {

      ---- implicitly returns `()` as its body has no tail or `return` expression

      error[E0308]: mismatched types
      --> C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\socket.rs:1454:15

      1454 | from!(Socket, net::TcpStream);

      ^^^^^^^^^^^^^^ expected struct `TcpStream`, found `()`

      ::: C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\lib.rs:104:16

      104 | fn from(socket: $from) -> $for {

      ---- implicitly returns `()` as its body has no tail or `return` expression

      error[E0308]: mismatched types
      --> C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\socket.rs:1455:15

      1455 | from!(Socket, net::TcpListener);

      ^^^^^^^^^^^^^^^^ expected struct `TcpListener`, found `()`

      ::: C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\lib.rs:104:16

      104 | fn from(socket: $from) -> $for {

      ---- implicitly returns `()` as its body has no tail or `return` expression

      error[E0308]: mismatched types
      --> C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\socket.rs:1456:15

      1456 | from!(Socket, net::UdpSocket);

      ^^^^^^^^^^^^^^ expected struct `UdpSocket`, found `()`

      ::: C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\lib.rs:104:16

      104 | fn from(socket: $from) -> $for {

      ---- implicitly returns `()` as its body has no tail or `return` expression

      error[E0061]: this function takes 4 arguments but 3 arguments were supplied
      --> C:\Users\Trevor\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.4.0\src\sockaddr.rs:123:33

      123 | Some(SocketAddr::V6(SocketAddrV6::new(

      ^^^^^^^^^^^^^^^^^ expected 4 arguments
      124
      ip,

      126

      addr.sin6_flowinfo,
      ------------------ supplied 3 arguments

      note: associated function defined here
      --> C:\Users\Trevor\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library/std/src/net/addr.rs:359:12

      359 | pub fn new(ip: Ipv6Addr, port: u16, flowinfo: u32, scope_id: u32) -> SocketAddrV6 {

      ^^^

      error: aborting due to 27 previous errors

      Some errors have detailed explanations: E0061, E0308, E0432, E0433.
      For more information about an error, try `rustc --explain E0061`.
      error: build failed
      Error: Compiling your crate to WebAssembly failed

            Assignee:
            patrick.freed@mongodb.com Patrick Freed
            Reporter:
            trevor@mailagc.com Trevor Green
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: