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

Different RUSTFLAGS between cargo build and cargo clippy invalidate "core" crate when using build-std #14551

Open
schultetwin1 opened this issue Sep 17, 2024 · 1 comment
Labels
A-rebuild-detection Area: rebuild detection and fingerprinting A-rustflags Area: rustflags C-bug Category: bug Command-clippy S-triage Status: This issue is waiting on initial triage. Z-build-std Nightly: build-std

Comments

@schultetwin1
Copy link

Problem

Normally, I pass the flag -W missing_docs to cargo clippy but not cargo build this does not affect the other's build. However, when using -Z build-std, I've noticed that adding -W missing_docs to my cargo clippy command will cause my the cargo build command to re-build the core crate, which in turn re-builds most dependent crates.

Steps

This was reproduced on with the following environment:

rustc --version --verbose
rustc 1.81.0 (eeb90cda1 2024-09-04)
binary: rustc
commit-hash: eeb90cda1969383f56a2637cbd3037bdf598841c
commit-date: 2024-09-04
host: x86_64-unknown-linux-gnu
release: 1.81.0
LLVM version: 18.1.7
  1. cargo new --bin buildstdtest
  2. cd buildstdtest
  3. cargo clippy with -Z build-std and set RUSTFLAGS="-W missing_docs"
    RUSTFLAGS="-W missing_docs" cargo +nightly clippy -Z build-std --target x86_64-unknown-linux-gnu
    
  4. cargo build with -Z build-stdand noRUSTFLAGS` set
    cargo +nightly build -Z build-std --target x86_64-unknown-linux-gnu
    
  5. Run cargo clippy again. I expect nothing rebuilds since no inputs have changed.
    RUSTFLAGS="-W missing_docs" cargo +nightly clippy -Z build-std --target x86_64-unknown-linux-gnu
    
    However, the core crate re-builds due to a change in rustflags.
    cargo +nightly build -vv -Z build-std --target x86_64-unknown-linux-gnu
       Dirty compiler_builtins v0.1.125: the rustflags changed
    Compiling compiler_builtins v0.1.125
       Dirty core v0.0.0 (/home/matsch/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core): the rustflags changed
    ...
    

Possible Solution(s)

No response

Notes

I enabled tracing on fingerprinting via the following command:

CARGO_LOG=cargo::core::compiler::fingerprint=trace cargo +nightly build -vv -Z build-std --target x86_64-unknown-linux-gnu

The output shows that the core crate did have a change in rustflags.

   0.066914712s  INFO prepare_target{force=false package_id=core v0.0.0 (/home/matsch/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core) target="core"}: cargo::core::compiler::fingerprint:     dirty: RustflagsChanged { old: ["-W", "missing_docs"], new: [] }

So the question to figure out is, why do the build-std crates pick up on the RUSTFLAGS change, but when I remove -Z build-std cargo build and cargo clippy can run side by side without affecting eachother's build fingerprints.

Version

cargo version --verbose
cargo 1.81.0 (2dbb1af80 2024-08-20)
release: 1.81.0
commit-hash: 2dbb1af80a2914475ba76827a312e29cedfa6b2f
commit-date: 2024-08-20
host: x86_64-unknown-linux-gnu
libgit2: 1.8.1 (sys:0.19.0 vendored)
libcurl: 8.8.0-DEV (sys:0.4.73+curl-8.8.0 vendored ssl:OpenSSL/1.1.1w)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Debian n/a (rodete) [64-bit]
@schultetwin1 schultetwin1 added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Sep 17, 2024
@weihanglo weihanglo added Command-clippy Z-build-std Nightly: build-std A-rustflags Area: rustflags A-rebuild-detection Area: rebuild detection and fingerprinting labels Sep 17, 2024
@weihanglo
Copy link
Member

This is probably similar to #9280, and essentially #8716. Doesn't need -Zbuild-std to be involved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rebuild-detection Area: rebuild detection and fingerprinting A-rustflags Area: rustflags C-bug Category: bug Command-clippy S-triage Status: This issue is waiting on initial triage. Z-build-std Nightly: build-std
Projects
None yet
Development

No branches or pull requests

2 participants