How does the libc crate publish docs for platforms not supported by rustup

Per docs.rs:

Targets to build (default: see below)

Any target supported by rustup can be used.

However libc has targets that are not supported by rustup that appear at docs.rs. When I attempt to do the same, such platforms are not published. How does libc do this?

For example the following section in Cargo.toml does not publish documentation for x86_64-unknown-openbsd:

[package.metadata.docs.rs]
all-features = true
default-target = "x86_64-unknown-linux-gnu"
targets = [
  "aarch64-apple-darwin",
  "aarch64-unknown-linux-gnu",
  "i686-pc-windows-msvc",
  "i686-unknown-linux-gnu",
  "x86_64-pc-windows-gnu",
  "x86_64-pc-windows-msvc",
  "x86_64-unknown-openbsd"
]

You are missing cargo-args = ["-Zbuild-std=core"] in that section. (adjust to -Zbuild-std=std if you need libstd)

5 Likes

Indeed. I hastily added that line, and it broke the build on docs.rs, so I incorrectly thought it didn't matter. Using -Zbuild-std=std instead allowed it to build and have that target. Thanks!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.