Open AzureMarker opened 2 years ago
Do these crates support Newlib
/ a generic UNIX or do they only plan on supporting Linux? Making a full GNU Linux libc
implementation is way out of scope. Ok having support, but those systems are way to different (some may even require /dev/
paths or processes). We should be careful with what we want to support.
socket2
supports a lot of platforms, including tier 3 ones:
https://github.com/rust-lang/socket2/issues/78
They just have a "unix.rs" file with a bunch of cfgs:
https://github.com/rust-lang/socket2/blob/master/src/sys/unix.rs
mio
supports a good number of "different" platforms, but we might need to make a PR to get support (ex. disable pipe feature):
https://github.com/tokio-rs/mio#platforms
They have a unix folder:
https://github.com/tokio-rs/mio/tree/master/src/sys/unix
Neither library has an explicit newlib section, so more investigation is needed to check if it's feasible to implement support. I think the only concerns would be in mio since it requires OS support for async io. Edit: see for example https://github.com/ivmarkov/rust-esp32-std-demo/issues/9
Opened an issue here since https://github.com/Meziu/libc doesn't have issues enabled.
I was trying to get tokio console working, but after dealing with the missing
getrandom
support, I found that there's a bunch of libc items not present which are required by mio and socket2. These two crates are compiled because there's a crate in the tree which requires tokio'sio-util
feature. The exact path isconsole-subscriber
->tonic
->h2
->tokio
->mio
andsocket2
. These errors would show up if anyone wanted to use tokio'sio-util
feature, so it's not just limited to tokio console.One of the errors from mio is related to missing pipe support, which we may not be able to work around without submitting a PR to that repo. But it still gives some interesting error messages which we can use to improve our libc support.
Errors I saw with `cargo 3ds build --example futures-tokio` (after adding tokio console support)
```rust Running Cargo Updating crates.io index Compiling log v0.4.14 Compiling futures-core v0.3.21 Compiling futures-channel v0.3.21 Compiling indexmap v1.8.0 Compiling httparse v1.6.0 Compiling miniz_oxide v0.4.4 Compiling crc32fast v1.3.2 Compiling serde v1.0.136 Compiling crossbeam-utils v0.8.7 Compiling num-traits v0.2.14 Compiling serde_json v1.0.79 Compiling nom v7.1.0 Compiling bytes v1.1.0 Compiling lazy_static v1.4.0 Compiling futures-sink v0.3.21 Compiling itoa v1.0.1 Compiling hashbrown v0.11.2 Compiling fnv v1.0.7 Compiling ppv-lite86 v0.2.16 Compiling try-lock v0.2.3 Compiling tower-service v0.3.1 Compiling pin-project v1.0.10 Compiling httpdate v1.0.2 Compiling base64 v0.13.0 Compiling adler v1.0.2 Compiling tower-layer v0.3.1 Compiling percent-encoding v2.1.0 Compiling once_cell v1.9.0 Compiling minimal-lexical v0.2.1 Compiling ryu v1.0.9 Compiling byteorder v1.4.3 Compiling ctru-rs v0.7.1 (/home/mark/media/Projects/3DS/ctru-rs/ctru-rs) Compiling humantime v2.1.0 Compiling socket2 v0.4.4 Compiling getrandom v0.2.4 (/home/mark/media/Projects/3DS/getrandom) Compiling console-api v0.1.2 error[E0432]: unresolved import `libc::SOCK_RAW` --> /home/mark/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.4/src/sys/unix.rs:64:16 | 64 | pub(crate) use libc::SOCK_RAW; | ^^^^^^^^^^^^^^ no `SOCK_RAW` in the root error[E0432]: unresolved import `libc::SOCK_SEQPACKET` --> /home/mark/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.4/src/sys/unix.rs:66:16 | 66 | pub(crate) use libc::SOCK_SEQPACKET; | ^^^^^^^^^^^^^^^^^^^^ no `SOCK_SEQPACKET` in the root error[E0432]: unresolved import `libc::MSG_TRUNC` --> /home/mark/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.4/src/sys/unix.rs:76:23 | 76 | pub(crate) use libc::{MSG_TRUNC, SO_OOBINLINE}; | ^^^^^^^^^ | | | no `MSG_TRUNC` in the root | help: a similar name exists in the module: `O_TRUNC` error[E0432]: unresolved import `libc::IP_HDRINCL` --> /home/mark/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.4/src/sys/unix.rs:79:16 | 79 | pub(crate) use libc::IP_HDRINCL; | ^^^^^^^^^^^^^^^^ no `IP_HDRINCL` in the root Compiling tracing-core v0.1.22 Compiling sharded-slab v0.1.4 error[E0433]: failed to resolve: use of undeclared type `IovLen` --> /home/mark/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.4/src/sys/unix.rs:769:38 | 769 | msg.msg_iovlen = min(bufs.len(), IovLen::MAX as usize) as IovLen; | ^^^^^^ use of undeclared type `IovLen` error[E0433]: failed to resolve: use of undeclared type `IovLen` --> /home/mark/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.4/src/sys/unix.rs:829:38 | 829 | msg.msg_iovlen = min(bufs.len(), IovLen::MAX as usize) as IovLen; | ^^^^^^ use of undeclared type `IovLen` error[E0531]: cannot find unit struct, unit variant or constant `SOCK_RAW` in crate `libc` --> /home/mark/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.4/src/sys/unix.rs:341:11 | 341 | libc::SOCK_RAW, | ^^^^^^^^ not found in `libc` error[E0531]: cannot find unit struct, unit variant or constant `SOCK_RDM` in crate `libc` --> /home/mark/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.4/src/sys/unix.rs:343:11 | 343 | libc::SOCK_RDM, | ^^^^^^^^ not found in `libc` error[E0531]: cannot find unit struct, unit variant or constant `SOCK_SEQPACKET` in crate `libc` --> /home/mark/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.4/src/sys/unix.rs:344:11 | 344 | libc::SOCK_SEQPACKET, | ^^^^^^^^^^^^^^ not found in `libc` error[E0425]: cannot find value `MSG_EOR` in crate `libc` --> /home/mark/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.4/src/sys/unix.rs:388:24 | 388 | self.0 & libc::MSG_EOR != 0 | ^^^^^^^ help: a constant with a similar name exists: `MSG_MORE` | ::: /home/mark/.cargo/git/checkouts/libc-445906a8a7176182/389e566/src/unix/newlib/horizon/mod.rs:116:1 | 116 | pub const MSG_MORE: ::c_int = 0; | -------------------------------- similarly named constant `MSG_MORE` defined here error[E0412]: cannot find type `msghdr` in crate `libc` --> /home/mark/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.4/src/sys/unix.rs:765:24 | 765 | let mut msg: libc::msghdr = unsafe { mem::zeroed() }; | ^^^^^^ not found in `libc` error[E0412]: cannot find type `IovLen` in this scope --> /home/mark/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.4/src/sys/unix.rs:769:63 | 769 | msg.msg_iovlen = min(bufs.len(), IovLen::MAX as usize) as IovLen; | ^^^^^^ not found in this scope error[E0425]: cannot find function `recvmsg` in crate `libc` --> /home/mark/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.4/src/sys/unix.rs:770:14 | 770 | syscall!(recvmsg(fd, &mut msg, flags)) | ^^^^^^^ not found in `libc` error[E0412]: cannot find type `msghdr` in crate `libc` --> /home/mark/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.4/src/sys/unix.rs:821:24 | 821 | let mut msg: libc::msghdr = unsafe { mem::zeroed() }; | ^^^^^^ not found in `libc` error[E0412]: cannot find type `IovLen` in this scope --> /home/mark/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.4/src/sys/unix.rs:829:63 | 829 | msg.msg_iovlen = min(bufs.len(), IovLen::MAX as usize) as IovLen; | ^^^^^^ not found in this scope error[E0425]: cannot find function `sendmsg` in crate `libc` --> /home/mark/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.4/src/sys/unix.rs:830:14 | 830 | syscall!(sendmsg(fd, &msg, flags)).map(|n| n as usize) | ^^^^^^^ not found in `libc` error[E0412]: cannot find type `ip_mreqn` in crate `libc` --> /home/mark/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.4/src/sys/unix.rs:1013:12 | 1013 | ) -> libc::ip_mreqn { | ^^^^^^^^ help: a struct with a similar name exists: `ip_mreq` | ::: /home/mark/.cargo/git/checkouts/libc-445906a8a7176182/389e566/src/unix/newlib/mod.rs:41:1 | 41 | / s! { 42 | | // The order of the `ai_addr` field in this struct is crucial 43 | | // for converting between the Rust and C types. 44 | | pub struct addrinfo { ... | 219 | | } 220 | | } | |_- similarly named struct `ip_mreq` defined here error[E0422]: cannot find struct, variant or union type `ip_mreqn` in crate `libc` --> /home/mark/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.4/src/sys/unix.rs:1015:75 | 1015 | crate::socket::InterfaceIndexOrAddress::Index(interface) => libc::ip_mreqn { | ^^^^^^^^ help: a struct with a similar name exists: `ip_mreq` | ::: /home/mark/.cargo/git/checkouts/libc-445906a8a7176182/389e566/src/unix/newlib/mod.rs:41:1 | 41 | / s! { 42 | | // The order of the `ai_addr` field in this struct is crucial 43 | | // for converting between the Rust and C types. 44 | | pub struct addrinfo { ... | 219 | | } 220 | | } | |_- similarly named struct `ip_mreq` defined here error[E0422]: cannot find struct, variant or union type `ip_mreqn` in crate `libc` --> /home/mark/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.4/src/sys/unix.rs:1020:77 | 1020 | crate::socket::InterfaceIndexOrAddress::Address(interface) => libc::ip_mreqn { | ^^^^^^^^ help: a struct with a similar name exists: `ip_mreq` | ::: /home/mark/.cargo/git/checkouts/libc-445906a8a7176182/389e566/src/unix/newlib/mod.rs:41:1 | 41 | / s! { 42 | | // The order of the `ai_addr` field in this struct is crucial 43 | | // for converting between the Rust and C types. 44 | | pub struct addrinfo { ... | 219 | | } 220 | | } | |_- similarly named struct `ip_mreq` defined here Compiling async-stream v0.3.2 Compiling mio v0.8.0 Compiling want v0.3.0 Compiling thread_local v1.1.4 error: unsupported target for `mio::unix::pipe` --> /home/mark/.cargo/registry/src/github.com-1ecc6299db9ec823/mio-0.8.0/src/sys/unix/pipe.rs:197:5 | 197 | compile_error!("unsupported target for `mio::unix::pipe`"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0432]: unresolved imports `self::selector::event`, `self::selector::Event`, `self::selector::Events`, `self::selector::Selector` --> /home/mark/.cargo/registry/src/github.com-1ecc6299db9ec823/mio-0.8.0/src/sys/unix/mod.rs:18:37 | 18 | pub(crate) use self::selector::{event, Event, Events, Selector}; | ^^^^^ ^^^^^ ^^^^^^ ^^^^^^^^ no `Selector` in `sys::unix::selector` | | | | | | | no `Events` in `sys::unix::selector` | | no `Event` in `sys::unix::selector` | no `event` in `sys::unix::selector` error[E0432]: unresolved import `self::waker::Waker` --> /home/mark/.cargo/registry/src/github.com-1ecc6299db9ec823/mio-0.8.0/src/sys/unix/mod.rs:24:20 | 24 | pub(crate) use self::waker::Waker; | ^^^^^^^^^^^^^^^^^^ no `Waker` in `sys::unix::waker` error[E0425]: cannot find value `stream` in this scope --> /home/mark/.cargo/registry/src/github.com-1ecc6299db9ec823/mio-0.8.0/src/sys/unix/tcp.rs:112:58 | 112 | unsafe { to_socket_addr(addr.as_ptr()) }.map(|addr| (stream, addr)) | ^^^^^^ not found in this scope error[E0425]: cannot find value `SOCK_NONBLOCK` in crate `libc` --> /home/mark/.cargo/registry/src/github.com-1ecc6299db9ec823/mio-0.8.0/src/sys/unix/uds/listener.rs:53:27 | 53 | let flags = libc::SOCK_NONBLOCK | libc::SOCK_CLOEXEC; | ^^^^^^^^^^^^^ help: a constant with a similar name exists: `O_NONBLOCK` | ::: /home/mark/.cargo/git/checkouts/libc-445906a8a7176182/389e566/src/unix/newlib/mod.rs:436:1 | 436 | pub const O_NONBLOCK: ::c_int = 16384; | -------------------------------------- similarly named constant `O_NONBLOCK` defined here error[E0425]: cannot find function `accept4` in crate `libc` --> /home/mark/.cargo/registry/src/github.com-1ecc6299db9ec823/mio-0.8.0/src/sys/unix/uds/listener.rs:54:18 | 54 | syscall!(accept4( | ^^^^^^^ help: a function with a similar name exists: `accept` | ::: /home/mark/.cargo/git/checkouts/libc-445906a8a7176182/389e566/src/unix/mod.rs:618:5 | 618 | pub fn accept(socket: ::c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> ::c_int; | ----------------------------------------------------------------------------------------------- similarly named function `accept` defined here error[E0425]: cannot find value `SOCK_NONBLOCK` in crate `libc` --> /home/mark/.cargo/registry/src/github.com-1ecc6299db9ec823/mio-0.8.0/src/sys/unix/uds/mod.rs:81:35 | 81 | let flags = flags | libc::SOCK_NONBLOCK | libc::SOCK_CLOEXEC; | ^^^^^^^^^^^^^ help: a constant with a similar name exists: `O_NONBLOCK` | ::: /home/mark/.cargo/git/checkouts/libc-445906a8a7176182/389e566/src/unix/newlib/mod.rs:436:1 | 436 | pub const O_NONBLOCK: ::c_int = 16384; | -------------------------------------- similarly named constant `O_NONBLOCK` defined here Compiling rand_core v0.6.3 Some errors have detailed explanations: E0412, E0422, E0425, E0432, E0433, E0531. For more information about an error, try `rustc --explain E0412`. error: could not compile `socket2` due to 19 previous errors warning: build failed, waiting for other jobs to finish... Some errors have detailed explanations: E0425, E0432. For more information about an error, try `rustc --explain E0425`. error: build failed ```cc: @Meziu @ian-h-chamberlain