rust-lang / libc

Raw bindings to platform APIs for Rust
https://docs.rs/libc
Apache License 2.0
2.12k stars 1.04k forks source link

0.2.44 breaks fairly recent compiler #1136

Closed przygienda closed 6 years ago

przygienda commented 6 years ago
error[E0432]: unresolved import `core::ffi::c_void`
    --> /b/prz/PVT_RIFT_184/obj//cargo_home/registry/src/github.com-1ecc6299db9ec823/libc-0.2.44/src/unix/mod.rs:1151:17
     |
1151 |         pub use core::ffi::c_void;
     |                 ^^^^^^^^^^^^^^^^^ no `c_void` in `ffi`

error[E0432]: unresolved import `core::ffi::c_void`
    --> /b/prz/PVT_RIFT_184/obj//cargo_home/registry/src/github.com-1ecc6299db9ec823/libc-0.2.44/src/unix/mod.rs:1151:17
     |
1151 |         pub use core::ffi::c_void;
     |                 ^^^^^^^^^^^^^^^^^ no `c_void` in `ffi`

error[E0641]: cannot cast to a pointer of an unknown kind
   --> /b/prz/PVT_RIFT_184/obj//cargo_home/registry/src/github.com-1ecc6299db9ec823/libc-0.2.44/src/unix/bsd/freebsdlike/mod.rs:864:56
    |
864 | pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = 0 as *mut _;
    |                                                        ^^^^^------
    |                                                             |
    |                                                             help: consider giving more type information
    |
    = note: The type information given here is insufficient to check whether the pointer cast is valid

error[E0641]: cannot cast to a pointer of an unknown kind
   --> /b/prz/PVT_RIFT_184/obj//cargo_home/registry/src/github.com-1ecc6299db9ec823/libc-0.2.44/src/unix/bsd/freebsdlike/mod.rs:865:54
    |
865 | pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = 0 as *mut _;
    |                                                      ^^^^^------
    |                                                           |
    |                                                           help: consider giving more type information
    |
    = note: The type information given here is insufficient to check whether the pointer cast is valid

error[E0641]: cannot cast to a pointer of an unknown kind
   --> /b/prz/PVT_RIFT_184/obj//cargo_home/registry/src/github.com-1ecc6299db9ec823/libc-0.2.44/src/unix/bsd/freebsdlike/mod.rs:866:58
    |
866 | pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = 0 as *mut _;
    |                                                          ^^^^^------
    |                                                               |
    |                                                               help: consider giving more type information
    |
    = note: The type information given here is insufficient to check whether the pointer cast is valid
gnzlbg commented 6 years ago

Damn, we recently lowered the required Rust version for core::ffi::c_void, maybe that was one version too low. Which Rust version are you using? rustc --version

gnzlbg commented 6 years ago

So I've added a build bot to check that everything still works with 1.30.0 (https://github.com/rust-lang/libc/pull/1138), so that does not appear to be the case.

It would be very helpful to know which compiler version you are using, which target are you targeting (are you using your own libcore ?), and ideally a minimum working example that reproduces the issue.

przygienda commented 6 years ago

.../rustc --version rustc 1.30.0-nightly (f7202e40f 2018-08-27)

przygienda commented 6 years ago

linux cross-compiling into a BSD variant ...

gnzlbg commented 6 years ago

I see. So this breakage is intended. That nightly is both too new - part of the 1.30 cycle - and too old: older than the first nightly in the 1.30 cycle that had core::ffi::c_void type. So when libc checks for Rust version >= 1.30 that returns true for your nightly (the reason is that we only support "the latest nightly", and Rust stable 1.30 has more features than your nightly).

We could patch the build.rs to detect whether its a nightly, and its date, and only enable c_void in new enough nightlies (I don't think this is worth doing but if you send a PR I don't really mind merging it). Alternatively, you can just override the libc version to one that works (e.g. 0.2.43), or upgrade your toolchain to a newer nightly version: this PR of Sept 17 moved c_void into libcore, the next nightly toolchain might be new enough.

gnzlbg commented 6 years ago

I'm closing this as it is probably "INVALID"/"WONT FIX".