Open loynoir opened 2 weeks ago
very common
This is not common. Something is changing about your build settings which is not obvious here. The usual cause of this is your editor running cargo check
in the background with a different set of flags than your builds done at the CLI. If you add --verbose
to your builds you should see messages like this:
Dirty zerocopy v0.7.35: the rustflags changed
which should contain some explanation about what is changing between builds that is causing the cache to be evicted.
The usual cause of this is your editor running
cargo check
in the background with a different set of flags than your builds done at the CLI.
I'm using vscode with RA using seperated profile, so seems not editor extension problem.
"rust-analyzer.cargo.extraArgs": [
"--profile",
"x-rust-analyzer"
],
Currently, I workaround with cargo build
and cargo test
with different profiles.
Maybe debug what happen with --verbose
when later. :)
Long story short:
Unfortunately, I have deleted the prev profile.
Cannot again reproduce this ALWAYS bug, cargo test
expire cargo build
and cargo build
expire cargo test
I deleted old profile with cargo clean, nothing else changed.
[profile.release]
debug = false
strip = true
opt-level = 3
lto = true
codegen-units = 1
panic = "abort"
[profile.x-reproduce]
inherits = "release"
cargo build --profile x-reproduce
stable at 0.09s, 136 deps, 136 fresh, 0 dirty, 0 compiling.
cargo test --profile x-reproduce
use 14:28.60 total, 154 deps, 19 fresh, 0 dirty, 135 compiling.
cargo test --profile x-reproduce
use 0.286 total, 154 deps, 154 fresh, 0 dirty, 0 compiling.
cargo build --profile x-reproduce
use 0.130 total, 136 deps, 136 fresh, 0 dirty, 0 compiling.
Cannot reproduce build cache problem again.
Before I delete old profile, I was able to 100% reproduce that multiple times.
Speak of why I let RA use seperate profile, background problem is https://github.com/rust-lang/rust-analyzer/issues/15057
"rust-analyzer.cargo.extraArgs": [
"--profile",
"x-rust-analyzer"
],
Not sure why build cache problem happen again here.
Maybe a rust build cache sometime drop into always happen bug?
Maybe a sccache bug?
I have no idea.
Aside: I don't think it explains repeated from-scratch rebuilds, but cargo test
and panic = "abort"
is a bad combination because the libtest harness needs unwinding, so Cargo will build all your crates and all dependencies twice: once with panic=abort for cargo {build,run}
and once with panic=unwind for cargo test
. After that's done and if nothing else causes a full rebuild, cargo will happily keep both versions in the target directory and reuse them, but it will make any spurious or legitimate rebuilds even more annoying, so you might want to fix it regardless.
bug
very common scenario let build cache expired
version
1.80.0
edit
was able to always reproduce this, before I
cargo clean
after
cargo clean
, cannot reproduce this againactual
N th build is expected.
N+1 th build are also expected.
BUT unexpectedly,
cargo test
seems expire all cache.Below
cargo test
are expected.Unexpectedly,
cargo build
expirecargo test
cache.expected
cargo test
should not expirecargo build
cache.cargo build
should not expirecargo test
cache.should have rust docs on how to improve compile speed beside
sccache
additional
I always see compiling all the dep tree again and again and again and again and again.