Repository navigation
Normalize -f*-prefix-map args via SCCACHE_BASEDIRS - #2673
larseggert wants to merge 2 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2673 +/- ##
==========================================
+ Coverage 74.26% 74.28% +0.02%
==========================================
Files 70 70
Lines 39325 39366 +41
==========================================
+ Hits 29204 29244 +40
- Misses 10121 10122 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
These compound flags embed absolute paths that `strip_basedirs` cannot reach via preprocessor-output normalization, causing cache misses when the same sources are built from different directories. Extract the `OLD` path component and strip basedir prefixes from it before hashing.
0310045 to
e1ba867
Compare
|
@copilot resolve the merge conflicts in this pull request experimenting! |
| m.update(self.language.as_str().as_bytes()); | ||
| for arg in self.arguments { | ||
| arg.hash(&mut HashToDigest { digest: &mut m }); | ||
| normalize_prefix_map_arg(arg, self.basedirs).hash(&mut HashToDigest { digest: &mut m }); |
There was a problem hiding this comment.
preprocessor_cache_entry_hash_key() still hashes the raw args, so in preprocessor cache mode we keep missing. please handle both (and dedup).
| Cow::Owned(result) | ||
| } | ||
|
|
||
| const PREFIX_MAP_FLAGS: &[&[u8]] = &[ |
There was a problem hiding this comment.
what about -fcoverage-prefix-map= and -fprofile-prefix-map=?
| b"-ffile-prefix-map=", | ||
| ]; | ||
|
|
||
| /// Normalize a `-f{debug,macro,file}-prefix-map=OLD=NEW` compiler argument for cache key |
There was a problem hiding this comment.
nobody will read a 10 lines doc comment :) 2 lines is enough
| .iter() | ||
| .find_map(|&flag| Some((flag, bytes.strip_prefix(flag)?)))?; | ||
| // Format is OLD=NEW; split on the first '=' | ||
| let sep = rest.iter().position(|&b| b == b'=')?; |
There was a problem hiding this comment.
what if OLD contains a '='? gcc splits on the last one iirc
| // Strip the longest matching basedir prefix from OLD | ||
| let stripped_old = basedirs | ||
| .iter() | ||
| .filter(|dir| old.starts_with(dir.as_slice())) |
There was a problem hiding this comment.
on windows basedirs are lowercased and slash-normalized (config.rs) while the arg isn't, so this never matches - strip_basedirs normalizes the haystack first, could you do the same here?
| @@ -1670,6 +1710,41 @@ mod tests { | |||
| ); | |||
There was a problem hiding this comment.
please add a test in c.rs that two identical builds from different dirs give the same hash key — that's the actual bug here.
|
are you still interested in this one? if not, i will close it, thanks |
These compound flags embed absolute paths that
strip_basedirscannot reach via preprocessor-output normalization, causing cache misses when the same sources are built from different directories. Extract theOLDpath component and strip basedir prefixes from it before hashing.