Skip to content

commands: use the configured cache dir in --debug-preprocessor-cache - #2881

Merged
sylvestre merged 6 commits into
mozilla:mainfrom
devtechedge:fix-debug-preprocessor-cache-dir
Oct 18, 2026
Merged

sylvestre merged 6 commits into
mozilla:mainfrom
devtechedge:fix-debug-preprocessor-cache-dir

Conversation

@devtechedge

Copy link
Copy Markdown
Contributor

sccache --debug-preprocessor-cache always built its path from default_disk_cache_dir(), so with the cache moved through SCCACHE_DIR or [cache.disk] dir it failed with "No such file or directory".

It now reads preprocessor/ under config.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, and test_sccache_command now dumps the real entries after the compile run in preprocessor cache mode.

The two rmeta_notification_delivery_on_rustc_miss lib tests fail here the same way they do on main.

Fixes #2880

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
Comment thread tests/sccache_args.rs Outdated
fs::write(&entry, b"")?;
Ok(format!(
"Showing preprocessor entry file {}",
entry.display()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should fit on one line, please run cargo fmt

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tests/system.rs Outdated
let wrote_preprocessor_entries = preprocessor_cache_mode
&& compilers
.iter()
.any(|c| matches!(c.name, "gcc" | "clang" | "clang++"));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, that list would have drifted.

It now just checks whether client-cache/preprocessor exists and dumps the entries when it does.

@codecov-commenter

codecov-commenter commented Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.75%. Comparing base (eb55704) to head (f0c2996).
⚠️ Report is 37 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

devtechedge and others added 2 commits October 8, 2026 03:24
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.
@devtechedge

Copy link
Copy Markdown
Contributor Author

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.

@sylvestre
sylvestre merged commit 78c418b into mozilla:main Oct 18, 2026
51 checks passed
@sylvestre

Copy link
Copy Markdown
Collaborator

Thanks for your PR

@devtechedge

Copy link
Copy Markdown
Contributor Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--debug-preprocessor-cache ignores SCCACHE_DIR and [cache.disk] dir

3 participants