Repository navigation
commands: use the configured cache dir in --debug-preprocessor-cache - #2881
Conversation
The debug command always reads the platform default cache dir, so it fails when the cache is moved with SCCACHE_DIR or [cache.disk] dir.
The server stores preprocessor cache entries under the disk cache dir from the config, which honours SCCACHE_DIR and [cache.disk] dir. The debug command now reads them from the same place instead of the platform default. Fixes #2880
| fs::write(&entry, b"")?; | ||
| Ok(format!( | ||
| "Showing preprocessor entry file {}", | ||
| entry.display() |
There was a problem hiding this comment.
this should fit on one line, please run cargo fmt
There was a problem hiding this comment.
cargo fmt kept splitting that line back up because of the call width limit.
I moved the format! into a local first, so it fits on one line now and fmt is happy.
| let wrote_preprocessor_entries = preprocessor_cache_mode | ||
| && compilers | ||
| .iter() | ||
| .any(|c| matches!(c.name, "gcc" | "clang" | "clang++")); |
There was a problem hiding this comment.
this duplicates the compiler list from run_sccache_command_tests
it will get out of sync, could we just check that client-cache/preprocessor exists instead?
There was a problem hiding this comment.
Good call, that list would have drifted.
It now just checks whether client-cache/preprocessor exists and dumps the entries when it does.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2881 +/- ##
==========================================
+ Coverage 77.58% 77.75% +0.17%
==========================================
Files 72 72
Lines 41409 41631 +222
==========================================
+ Hits 32126 32370 +244
+ Misses 9283 9261 -22 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
MSVC does not write preprocessor cache entries, but the preprocessor directory is still created by the disk cache, so the check failed on Windows with empty output.
|
Hi Sylvestre, hope you are doing well. Thank you for the quick inline notes back on 6 October, and for keeping sccache's test suite tidy enough that both points were easy to act on. I have addressed the cargo fmt point in tests/sccache_args.rs by moving the format call into a local so it fits on one line, and tests/system.rs now just checks that client-cache/preprocessor exists instead of duplicating the compiler list. The fix itself is in src/commands.rs, where --debug-preprocessor-cache now builds its path from config.fallback_cache.dir rather than default_disk_cache_dir(), which is the same resolved directory the disk cache writes to when SCCACHE_DIR or the disk cache dir setting moves it. That is what was behind issue #2880, where the command failed with No such file or directory even though the cache was happily living somewhere else. The two new cases in tests/sccache_args.rs cover the env var and the config file routes, and they failed on main with exactly that error before this change. I can see the workflow runs on the latest head are still waiting for approval to run, so there is nothing green to point at yet on my side. Whenever you have a moment, I would love another look, and I am very happy to adjust anything at all to match how you would prefer this done. |
|
Thanks for your PR |
|
Hi Sylvestre, thank you for merging this. The note about not copying the compiler list was the right call. Checking that client-cache/preprocessor exists will stay correct when that list changes. I also appreciated the cargo fmt catch. Moving the format into a local kept the expected line on one line without fighting the width limit. Glad the debug command now reads preprocessor entries from the same configured cache dir the disk cache writes to! |
sccache --debug-preprocessor-cachealways built its path fromdefault_disk_cache_dir(), so with the cache moved throughSCCACHE_DIRor[cache.disk] dirit failed with "No such file or directory".It now reads
preprocessor/underconfig.fallback_cache.dir, the same resolved directory the disk cache writes those entries to.Two new cases in
tests/sccache_args.rs(env var and config file) fail on main with the error from the issue, andtest_sccache_commandnow dumps the real entries after the compile run in preprocessor cache mode.The two
rmeta_notification_delivery_on_rustc_misslib tests fail here the same way they do on main.Fixes #2880