rust-lang-nursery / unix-socket

Unix socket support for Rust
Apache License 2.0
53 stars 18 forks source link

Fix for target: x86_64-linux-android #31

Open sweisgerber-dev opened 6 years ago

sweisgerber-dev commented 6 years ago

When compiling my project for android x86_64, cargo complained when compiling unix-socket 0.5.0 with the following error:

error[E0308]: mismatched types
   --> /home/weisgerber/.cargo/registry/src/github.com-1ecc6299db9ec823/unix_socket-0.5.0/src/lib.rs:569:73
    |
569 |             try!(cvt(libc::bind(inner.0, &addr as *const _ as *const _, len)));
    |                                                                         ^^^ expected i32, found u32

error[E0308]: mismatched types
   --> /home/weisgerber/.cargo/registry/src/github.com-1ecc6299db9ec823/unix_socket-0.5.0/src/lib.rs:719:73
    |
719 |             try!(cvt(libc::bind(inner.0, &addr as *const _ as *const _, len)));
    |                                                                         ^^^ expected i32, found u32

error: aborting due to 2 previous errors

error: Could not compile `unix_socket`.
warning: build failed, waiting for other jobs to finish...
error: build failed

I added code, to support this minor difference to androids socket implementation.

#[cfg(target_os="android")]
(...)
#[cfg(not(target_os="android"))]
(...)

Target definition: .cargo/config:

[target.x86_64-linux-android]
ar = "toolchain/bin/x86_64-linux-android-ar"
linker = "toolchain/bin/x86_64-linux-android-clang"

The android toolchain i am using has been created with the following command [NDK: r16b]:

android-ndk/build/tools/make_standalone_toolchain.py \
 --arch x86_64 \
 --api 24 \
 --stl=gnustl \
 --install-dir=.
sfackler commented 6 years ago

Just so you're aware, Unix socket functionality is in the standard library now: https://doc.rust-lang.org/std/os/unix/net/

sweisgerber-dev commented 6 years ago

Thanks for the hint, does this mean, I need to submit the fix somewhere else?

sfackler commented 6 years ago

No, it means you can stop depending on this crate, and change your imports from unix_socket::... to std::os::unix::net::....

sweisgerber-dev commented 6 years ago

Okay, that's easily done for my code (already happened now), but there are also other crates depending on your external crate.