Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RUSTFLAGS / RUSTDOCFLAGS are not being passed to rustdoc when target-applies-to-host nightly feature is used #10744

Closed
jplatte opened this issue Jun 10, 2022 · 6 comments · Fixed by #13900
Labels
C-bug Category: bug Z-target-applies-to-host Nightly: target-applies-to-host

Comments

@jplatte
Copy link
Contributor

jplatte commented Jun 10, 2022

Problem

For two project I maintain, the docs generated by CI no longer includes an index file despite the appropriate nightly flags being used. I initially opened rust-lang/rust#97881 for this, but now found out that it's actually a bug in Cargo that doesn't pass RUSTDOCFLAGS on to rustdoc in the affected workspaces (though it doesn't seem to affect all workspaces).

Steps

  • Clone https://github.com/ruma/ruma/tree/rustdoc-bug
  • With the environment variable RUSTDOCFLAGS set to --cfg compile_error, run cargo +nightly doc -p ruma
  • Observe no errors despite this in crates/ruma/src/lib.rs
    #[cfg(compile_error)]
    compile_error!("!!!");

Notes

  • Reproducible with a recent version of cargo (1.63.0-nightly (85e457e15 2022-06-07))
  • Reproducible with cargo 1.61.0-nightly (3d6970d 2022-02-28) (rustup nightly-2022-03-02)
  • Not reproducible with cargo 1.61.0-nightly (d6cdde5 2022-02-22) (rustup nightly-2022-03-01).

Version

cargo 1.63.0-nightly (85e457e15 2022-06-07)
release: 1.63.0-nightly
commit-hash: 85e457e158db216a2938d51bc3b617a5a7fe6015
commit-date: 2022-06-07
host: x86_64-unknown-linux-gnu
libgit2: 1.4.2 (sys:0.14.2 vendored)
libcurl: 7.83.1-DEV (sys:0.4.55+curl-7.83.1 vendored ssl:OpenSSL/1.1.1n)
os: Arch Linux Rolling Release [64-bit]
@jplatte jplatte added the C-bug Category: bug label Jun 10, 2022
@jplatte
Copy link
Contributor Author

jplatte commented Jun 10, 2022

I just verified that this is definitely cargo not passing the flags, by looking at the --verbose output, and also trying to set RUSTFLAGS and RUSTDOCFLAGS to nonsensical values.

@jplatte
Copy link
Contributor Author

jplatte commented Jun 10, 2022

I found out what is causing this / why we only saw it recently despite the bug being reproducible back to start of March: This only happens with

target-applies-to-host = false

[unstable]
target-applies-to-host = true

in the cargo configuration. Based on that and its timing, I suspect this bug was introduced in #10395; cc @jonhoo.

@jplatte jplatte changed the title RUSTDOCFLAGS are sometimes not being passed to rustdoc RUSTDOCFLAGS are not being passed to rustdoc when target-applies-to-host is configured Jun 10, 2022
@jplatte jplatte changed the title RUSTDOCFLAGS are not being passed to rustdoc when target-applies-to-host is configured RUSTDOCFLAGS are not being passed to rustdoc when target-applies-to-host nightly feature is used Jun 10, 2022
@weihanglo weihanglo added the Z-target-applies-to-host Nightly: target-applies-to-host label Jun 20, 2022
@jplatte jplatte changed the title RUSTDOCFLAGS are not being passed to rustdoc when target-applies-to-host nightly feature is used RUSTFLAGS / RUSTDOCFLAGS are not being passed to rustdoc when target-applies-to-host nightly feature is used Jun 28, 2022
jplatte added a commit to ruma/ruma that referenced this issue Jun 29, 2022
…ation"

This reverts commit 3d65c1e.
This was breaking our clippy lint configuration in .cargo/config.toml:
rust-lang/cargo#10744
@jplatte
Copy link
Contributor Author

jplatte commented Jun 30, 2022

Minimized reproduction: https://github.com/jplatte/rustflags-bug

@jplatte
Copy link
Contributor Author

jplatte commented Jun 30, 2022

Okay, so this is definitely from #10395, had I read the comments there I would have known that this is expected behavior: #10395 (comment)

The way forward seems to be this: #10395 (comment)

@jonhoo
Copy link
Contributor

jonhoo commented Jun 30, 2022

See also #10462 for follow up in that direction.

@jplatte
Copy link
Contributor Author

jplatte commented Jun 30, 2022

I'm not really clear on whether that would help for our main use case, which is

  • we want to configure clippy through rustflags in .cargo/config.toml, because that's currently the best workaround to otherwise having no workspace-wide lint configuration
  • we don't want changing rustflags for host dependencies to cause constant rebuilding when switching between non---target and --target builds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug Z-target-applies-to-host Nightly: target-applies-to-host
Projects
None yet
3 participants