rustdoc: allow full set of compiler options to be specified

621b772
Opened by Jeremy Fitzhardinge at 2024-11-07 22:57:45

rustdoc doesn't accept the full set of compiler options (in particular -C), so it isn't possible to build doctests in the same way as crates, binaries and normal unit tests. The ideal would be to just allow the test source to be extracted (#43029), so that building the doctest is identical to other code.

Failing that, some systematic way of converting a rustc compiler command line to a rustdoc one for building doctests would be OK.

(Filed separately, the ability to just build a test without running it: #43030)

  1. Over at Tor, we want to test our Rust↔C FFI. For example, we want to check if our FFI leaks memory or passes dangling Rust pointers to C. We'd like to write those tests in Rust though, not C, and I think we should utilize as much standard Rust as possible, including doctests. So, if we want full test coverage, we need a way to enable sanitizers in rustdoc. I asked @steveklabnik on IRC and he said that this would probably be the best way to go about that. I'd like to do this myself, but I think the exact design will require solid knowledge of rustc internals, and so it would be more work for someone to explain that to me. I'm hoping that it's not too much work for someone in-the-know to implement this. If it helps, nightly-only options are fine for us. This would probably be really useful for all Rust projects that call into C code, not just Tor.

    Alex Xu at 2018-04-17 01:15:27

  2. Update: https://github.com/rust-lang/rust/pull/49956 ported the -C option. That's still nowhere near the full spread of rustc flags, but it's the one mentioned in the issue description.

    QuietMisdreavus at 2018-05-31 16:09:14

  3. Triage: I don't think there's been any movement on this issue.

    Steve Klabnik at 2019-09-13 03:41:33