fix: strip SCCACHE_BASEDIRS from escaped-backslash paths on Windows#2736
Merged
sylvestre merged 2 commits intoJun 19, 2026
Merged
Conversation
On Windows, paths in preprocessor output are emitted as C string
literals: MSVC `#line` directives and clang GNU linemarkers quote them
with escaped backslash separators, e.g.
#line 1 "C:\\Users\\me\\project\\src\\main.c"
`normalize_win_path` converts every backslash to a forward slash, so
each escaped separator `\\` becomes a DOUBLE forward slash:
c://users//me//project//src//main.c
The normalized basedir, however, uses single slashes
(`c:/users/me/project/`), so `strip_basedirs` never finds a match and
SCCACHE_BASEDIRS silently has no effect on Windows. Cache entries stay
tied to absolute source paths and are not shared across checkout
directories.
Fix: in `strip_basedirs`, also search for a doubled-separator variant of
each basedir (new `double_path_separators` helper), so escaped paths are
stripped as well. Both the escaped and plain forms are handled, including
UNC basedirs. The extra needle and helper are gated behind
`cfg(target_os = "windows")` so non-Windows builds are unchanged.
Adds unit tests covering MSVC `#line`, clang linemarkers, mixed
escaped/plain occurrences, UNC paths, and a hash-key test asserting the
same source compiled from two different basedir roots hashes equally.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2736 +/- ##
==========================================
+ Coverage 74.51% 74.57% +0.05%
==========================================
Files 70 70
Lines 39652 39737 +85
==========================================
+ Hits 29546 29632 +86
+ Misses 10106 10105 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The custom failure messages in the Windows escaped-backslash strip_basedirs tests sat on their own wrapped lines (rustfmt splits the call past fn_call_width). Those message arguments only execute on the panic path, so grcov/Codecov counted them as 4 uncovered patch lines. The case-by-case comments already document each assertion, and assert_eq! prints the byte diff on failure, so the messages added nothing. Removing them yields single-line asserts whose branch grcov already excludes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Collaborator
|
in the future, please keep only the most important information in comment #0 |
eleboucher
pushed a commit
to eleboucher/towonel
that referenced
this pull request
Jun 19, 2026
….0) (#36) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [mozilla/sccache](https://github.com/mozilla/sccache) | minor | `0.15.0` → `0.16.0` | --- ### Release Notes <details> <summary>mozilla/sccache (mozilla/sccache)</summary> ### [`v0.16.0`](https://github.com/mozilla/sccache/releases/tag/v0.16.0) [Compare Source](mozilla/sccache@v0.15.0...v0.16.0) ##### sccache 0.16.0 ##### Summary sccache 0.16.0 is a smaller, stabilizing release on top of 0.15.0's multi-tier caching work, with a few new capabilities: - **Read-only backends**: Any storage backend can now be marked read-only, not just a select few ([#​2705](mozilla/sccache#2705)). - **Remote execution on aarch64**: Distributed/remote execution now works on Linux aarch64, including fixes for `ldd` output parsing and toolchain packaging on non-x86\_64 Linux ([#​2668](mozilla/sccache#2668)). - **CUDA**: `nvcc`'s `--dependency-output` argument is now handled ([#​2708](mozilla/sccache#2708)). - **Resilience**: Fall back to a direct cache write when tempfile creation on the same filesystem fails ([#​2369](mozilla/sccache#2369)), and give a meaningful error when a multi-level chain references a backend that wasn't compiled in ([#​2695](mozilla/sccache#2695)). - **Client efficiency**: The client and dist-client now use a single-threaded tokio runtime, avoiding a thread explosion when many short-lived clients run on many-core hosts ([#​2704](mozilla/sccache#2704)). - **Correctness**: Strip `SCCACHE_BASEDIRS` from escaped-backslash paths on Windows ([#​2736](mozilla/sccache#2736)), ignore empty-set environment values in config ([#​2639](mozilla/sccache#2639)), and avoid the sccache wrapper when resolving the real compiler ([#​2720](mozilla/sccache#2720)). - **Security/logging**: JWT keys and cert digests are now base64-encoded in logs ([#​2712](mozilla/sccache#2712)), plus general logging improvements ([#​2734](mozilla/sccache#2734)). Welcome to 4 new contributors! ##### Features - feat: all backends support making them as read-only by [@​AJIOB](https://github.com/AJIOB) in [#​2705](mozilla/sccache#2705) - Enable RE on Linux-aarch64 by [@​malfet](https://github.com/malfet) in [#​2668](mozilla/sccache#2668) - feat(nvcc): support argument: `--dependency-output` by [@​ZRHann](https://github.com/ZRHann) in [#​2708](mozilla/sccache#2708) - feat: avoid sccache wrapper when resolving compiler by [@​iTrooz](https://github.com/iTrooz) in [#​2720](mozilla/sccache#2720) - Fall back to direct cache write if tempfile creation on the same fs fails by [@​myzhang1029](https://github.com/myzhang1029) in [#​2369](mozilla/sccache#2369) - Don't wait depfiles for gcc/clang preprocessed inputs by [@​AJIOB](https://github.com/AJIOB) in [#​2665](mozilla/sccache#2665) ##### Fixes - fix: strip SCCACHE\_BASEDIRS from escaped-backslash paths on Windows by [@​rconde01](https://github.com/rconde01) in [#​2736](mozilla/sccache#2736) - fix: ignore empty-set environment values for config by [@​AJIOB](https://github.com/AJIOB) in [#​2639](mozilla/sccache#2639) - fix: handle disabled cache backend features in multilevel chain by [@​cryptomilk](https://github.com/cryptomilk) in [#​2695](mozilla/sccache#2695) - fix: use single-threaded tokio runtime in sccache (dist-)client by [@​AJIOB](https://github.com/AJIOB) in [#​2704](mozilla/sccache#2704) - fix: add newline when printing dist-status to stdout by [@​iTrooz](https://github.com/iTrooz) in [#​2710](mozilla/sccache#2710) ##### Logging - chore: encode jwt key and cert digest with base64 in logs by [@​iTrooz](https://github.com/iTrooz) in [#​2712](mozilla/sccache#2712) - Slightly improve logging by [@​glandium](https://github.com/glandium) in [#​2734](mozilla/sccache#2734) ##### Cleanup - chore: make clippy happy by [@​AJIOB](https://github.com/AJIOB) in [#​2727](mozilla/sccache#2727) - Extract new\_client\_runtime() helper to DRY up client runtime creation by [@​sylvestre](https://github.com/sylvestre) in [#​2744](mozilla/sccache#2744) ##### New Contributors - [@​ZRHann](https://github.com/ZRHann) made their first contribution in [#​2708](mozilla/sccache#2708) - [@​myzhang1029](https://github.com/myzhang1029) made their first contribution in [#​2369](mozilla/sccache#2369) - [@​malfet](https://github.com/malfet) made their first contribution in [#​2668](mozilla/sccache#2668) - [@​rconde01](https://github.com/rconde01) made their first contribution in [#​2736](mozilla/sccache#2736) **Full Changelog**: <mozilla/sccache@v0.15.0...v0.16.0> </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xMDEuMSIsInVwZGF0ZWRJblZlciI6IjQzLjEwMS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9naXRodWItcmVsZWFzZSIsInR5cGUvbWlub3IiXX0=--> Reviewed-on: https://codeberg.org/towonel/towonel/pulls/36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: strip
SCCACHE_BASEDIRSfrom escaped-backslash paths on WindowsFixes #2737.
Problem
SCCACHE_BASEDIRShas no effect on Windows. The same source compiledfrom two different checkout directories produces different cache keys, so
nothing is shared across roots — the feature silently does nothing.
Root cause
On Windows, paths inside preprocessor output are emitted as C string
literals. MSVC
#linedirectives and clang GNU linemarkers quote themwith escaped backslash separators:
normalize_win_pathconverts every backslash to a forward slash, so eachescaped separator
\\becomes a double forward slash:But the normalized basedir uses single slashes (
c:/users/me/project/),so
strip_basedirsnever finds a boundary match, and the absolute path isleft in the preprocessed output that feeds the hash.
Fix
In
strip_basedirs, also search for a doubled-separator variant of eachbasedir, produced by a new
double_path_separatorshelper. Escaped pathsare now stripped in addition to the existing plain form; mixed
escaped/plain occurrences and UNC basedirs are handled too.
The extra needle and the helper are gated behind
cfg(target_os = "windows"), so non-Windows builds and behavior areunchanged.
Tests
New unit tests (Windows-only):
util::tests::test_strip_basedir_windows_escaped_backslashes— MSVC#line, clang linemarker, and mixed escaped/plain occurrences.util::tests::test_strip_basedir_windows_escaped_unc— escaped UNCbasedir.
compiler::c::test::test_hash_key_basedirs_windows_escaped_backslashes— the same source under two different basedir roots hashes equally, and
differs without basedirs.
All three fail before the change and pass after.
cargo test --lib,cargo fmt --check, andcargo clippy --libare clean on the changedcode (the single pre-existing clippy warning in
msvc.rsis untouched).Manual end-to-end verification
Reproduced with real toolchains on Windows: building the same source from
two distinct absolute directories with
SCCACHE_BASEDIRSset goes from0/2 cache hits (unpatched) to 1/2 (patched) for both clang and
MSVC.