rust-lang / libc

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

Missing documentation for apple and microsoft target on docs.rs #3289

Closed roblabla closed 9 months ago

roblabla commented 1 year ago

The latest version of libc only has documentation for the following targets on docs.rs:

This is missing any documentation at least for the windows and macos versions (which were there in 0.2.146 and below, see this, and it doesn't seem to be in the build queue anymore.

JohnTitor commented 1 year ago

I believe it's an issue of docs.rs? We surely added all the supported targets in https://github.com/rust-lang/libc/pull/3279. cc @GuillaumeGomez

GuillaumeGomez commented 1 year ago

Taking a look!

jyn514 commented 1 year ago

docs.rs by default limits all crates to max 10 targets. i don't mind raising the limit as long as we decrease the max build time per target. cargo doc --features const-extern-fn,extra_traits -Zbuild-std --target x86_64-pc-windows-msvc -j2 takes 64 seconds for me on a T480s laptop, including the time to build std - does a 2 minute limit seem reasonable? (-j2 is what we use in production)

JohnTitor commented 1 year ago

Thanks for clarifying, I see! If it doesn't have much negative impact on other crates and docs.rs, that sounds great to me (to clarify, we still can host some targets, e.g. tier 2 or below, on our Pages, but I guess it's easier to use for these docs to be available on docs.rs).

And I noticed #3279 doesn't contain any macOS targets, does it disable builds for macOS (i.e. x86_64-apple-darwin)?

jyn514 commented 1 year ago

I am not sure what order we build the targets in - which targets we select if there's too many over the limit is an implementation detail I've never tested.

Let me change the limits and rebuild 0.2.147 and we can go from there :)

GuillaumeGomez commented 1 year ago

Thanks @jyn514 !

jyn514 commented 1 year ago

most of the targets seem to be working. here are the failures i saw:

# mipsel-unknown-linux-gnu, mipsel-unknown-linux-musl, mips-unknown-linux-gnu
error: Undefined temporary symbol $BB161_17
error: could not compile `rustc-demangle` (lib) 

# aarch64-unknown-hermit
 error[E0609]: no field `tv_sec` on type `&Timespec` 
  --> /opt/rustwide/rustup-home/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/hermit/time.rs:43:29 

# x86_64-linux-android, aarch64-linux-android, thumbv7neon-linux-androideabi, arm-linux-androideabi, armv7-linux-androideabi, i686-linux-android
error: failed to run custom build command for `unwind v0.0.0 (/opt/rustwide/rustup-home/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/unwind)`
thread 'main' panicked at 'Unable to invoke compiler: Error { kind: IOError, message: "No such file or directory (os error 2)" }', /opt/rustwide/rustup-home/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/unwind/build.rs:19:62 

# powerpc-unknown-netbsd
error[E0277]: the trait bound `i32: core::convert::From<u32>` is not satisfied
 --> /opt/rustwide/rustup-home/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/unix/thread_parking/netbsd.rs:37:37

# aarch64-wrs-vxworks, i686-wrs-vxworks, powerpc64-wrs-vxworks, powerpc-wrs-vxworks
error[E0432]: unresolved imports `libc::fdopendir`, `libc::openat`, `libc::unlinkat`
 --> /opt/rustwide/rustup-home/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/unix/fs.rs:1936:16
error[E0425]: cannot find value `UTIME_OMIT` in crate `libc` 
error[E0425]: cannot find function `futimens` in crate `libc`
error[E0425]: cannot find function `lchown` in crate `libc`
# ... lots more errors for this target, 9 total ... 

# riscv32imc-unknown-none-elf, riscv32i-unknown-none-elf
error[E0432]: unresolved import `core::sync::atomic::AtomicUsize`
 --> /opt/rustwide/rustup-home/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/stdarch/crates/std_detect/src/detect/cache.rs:8:5
error[E0432]: unresolved import `alloc::sync`
 --> /opt/rustwide/cargo-home/registry/src/index.crates.io-6f17d22bba15001f/gimli-0.27.3/src/read/dwarf.rs:2:12

the build is still running so this list is not exhaustive.

jyn514 commented 1 year ago

at this point i think i would suggest running docs.rs locally so you can confirm you've properly fixed all the errors; it will be too painful to publish a release every time to test and i'm nearly out of time for rust for the day anyway. as a heuristic cargo doc -Zbuild-std --features ... on x86_64-unknown-linux-gnu will probably get you 99% percent of the way to replicating the build env.

jyn514 commented 1 year ago

i'm also a little worried about how long this takes to run ... i started the build 50 minutes ago and it shows no sign of stopping soon. maybe we can change the docs.rs configuration somehow so that build-std is only used for tier 3 targets? we'd have to add a new metadata field, i'd want to confirm first that actually makes it faster.

GuillaumeGomez commented 1 year ago

I'm surprised it takes this long. We need to check if we link libraries and in such case, not do it if a feature is passed. To be investigated.

jyn514 commented 1 year ago

@GuillaumeGomez the problem is that the standard library is built from source - if you could use -Zbuild-std=core or something, that would already be a big help

jyn514 commented 1 year ago

uh oops i appear to have broken this further 😅

Jul 05 18:39:37 docsrs cratesfyi[20099]: 2023-07-05T18:39:37.361596Z DEBUG rustdoc_html_server_handler: docs_rs::web::rustdoc: got error serving libc/index.html: bzip2: bz2 header missing
image
GuillaumeGomez commented 1 year ago

I opened #3292 for that. Quite curious to see the result.

roblabla commented 1 year ago

The microsoft targets now show up, but the macos (darwin) ones are still missing. This is a bit problematic because it results in broken links in our crate's documentation (here, clicking on stat results in a broken link for instance)

GuillaumeGomez commented 1 year ago

I added them in https://github.com/rust-lang/libc/pull/3309. So next release they should appear.