Skip to content

Don't cache dep file#2322

Merged
sylvestre merged 1 commit intomozilla:mainfrom
glandium:depfile
Jan 30, 2025
Merged

Don't cache dep file#2322
sylvestre merged 1 commit intomozilla:mainfrom
glandium:depfile

Conversation

@glandium
Copy link
Copy Markdown
Collaborator

sccache has two modes:

  • normal mode
  • preprocessor cache mode (aka direct mode in ccache)

In the former case, the preprocessor is invoked and creates the dep file itself. Whatever sccache does after that is going to overwrite a fresh file with potentially wrong information, since the cache key is not indexed on the elements that would affect the contents of the dep file, resulting in issue #2321.

In the latter case, sccache currently doesn't handle the situation appropriately (issue #2194), which is why preprocessor cache mode is automatically disabled when the dependency flags are on the command line (#2195). Which also means we fallback to the case above.

@glandium glandium requested a review from sylvestre January 28, 2025 01:53
sccache has two modes:
- normal mode
- preprocessor cache mode (aka direct mode in ccache)

In the former case, the preprocessor is invoked and creates the dep file
itself. Whatever sccache does after that is going to overwrite a fresh
file with potentially wrong information, since the cache key is not
indexed on the elements that would affect the contents of the dep file,
resulting in issue mozilla#2321.

In the latter case, sccache currently doesn't handle the situation
appropriately (issue mozilla#2194), which is why preprocessor cache mode is
automatically disabled when the dependency flags are on the command line
(mozilla#2195). Which also means we fallback to the case above.
@sylvestre sylvestre merged commit c0a0b6e into mozilla:main Jan 30, 2025
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (0cc0c62) to head (b4b5263).
Report is 135 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #2322       +/-   ##
==========================================
- Coverage   30.91%       0   -30.92%     
==========================================
  Files          53       0       -53     
  Lines       20112       0    -20112     
  Branches     9755       0     -9755     
==========================================
- Hits         6217       0     -6217     
+ Misses       7922       0     -7922     
+ Partials     5973       0     -5973     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

ahartmetz added a commit to ahartmetz/sccache that referenced this pull request May 18, 2025
This reverts the "main" code changes of commit
c0a0b6e but keeps the added test.

A better fix will work as follows:
- Always store the dep file in the cache
- In non-preprocessor cache mode, which doesn't consider things
  like file name and included file names, so it can confuse cache
  entries with same preprocessed content but different dep files:
  do not restore the dep file. It is not necessary anyway because
  local preprocessing will produce the file.
- In preprocessor cache mode, which uses input file names and
  hashes to distinguish cache entries, but does not run the
  preprocessor:
  *do* restore the dep file.
ahartmetz added a commit to ahartmetz/sccache that referenced this pull request May 24, 2025
This reverts the "main" code changes of commit
c0a0b6e but keeps the added test.

A better fix will work as follows:
- Always store the dep file in the cache
- In non-preprocessor cache mode, which doesn't consider things
  like file name and included file names, so it can confuse cache
  entries with same preprocessed content but different dep files:
  do not restore the dep file. It is not necessary anyway because
  local preprocessing will produce the file.
- In preprocessor cache mode, which uses input file names and
  hashes to distinguish cache entries, but does not run the
  preprocessor:
  *do* restore the dep file. It is both safe and necessary.
ahartmetz added a commit to ahartmetz/sccache that referenced this pull request Jun 1, 2025
This reverts the "main" code changes of commit
c0a0b6e but keeps the added test.

A fix that is better than disabling preprocessor cache mode
whenever the compiler generates a dep file seems possible.
ahartmetz added a commit to ahartmetz/sccache that referenced this pull request Jun 11, 2025
This reverts the "main" code changes of commit
c0a0b6e but keeps the added test.

A fix that is better than disabling preprocessor cache mode
whenever the compiler generates a dep file seems possible.
ahartmetz added a commit to ahartmetz/sccache that referenced this pull request Jun 21, 2025
This reverts the "main" code changes of commit
c0a0b6e but keeps the added test.

A fix that is better than disabling preprocessor cache mode
whenever the compiler generates a dep file seems possible.
sylvestre pushed a commit to ahartmetz/sccache that referenced this pull request Jun 23, 2025
This reverts the "main" code changes of commit
c0a0b6e but keeps the added test.

A fix that is better than disabling preprocessor cache mode
whenever the compiler generates a dep file seems possible.
ahartmetz added a commit to ahartmetz/sccache that referenced this pull request Jul 7, 2025
This reverts the "main" code changes of commit
c0a0b6e but keeps the added test.

A fix that is better than disabling preprocessor cache mode
whenever the compiler generates a dep file seems possible.
ahartmetz added a commit to ahartmetz/sccache that referenced this pull request Jul 7, 2025
This reverts the "main" code changes of commit
c0a0b6e but keeps the added test.

A fix that is better than disabling preprocessor cache mode
whenever the compiler generates a dep file seems possible.
ahartmetz added a commit to ahartmetz/sccache that referenced this pull request Jul 7, 2025
This reverts the "main" code changes of commit
c0a0b6e but keeps the added test.

That commit fixed getting wrong dep files from cache in non
preprocessor cache mode, but made it impossible to support dep
files in preprocessor cache mode. We can do better.
ahartmetz added a commit to ahartmetz/sccache that referenced this pull request Jul 7, 2025
This reverts the "main" code changes of commit
c0a0b6e but keeps the added test.

That commit fixed getting wrong dep files from cache in non
preprocessor cache mode, but made it impossible to support dep
files in preprocessor cache mode. We can do better.
ahartmetz added a commit to ahartmetz/sccache that referenced this pull request Jul 7, 2025
This reverts the "main" code changes of commit
c0a0b6e but keeps the added test.

That commit fixed getting wrong dep files from cache in non
preprocessor cache mode, but made it impossible to support dep
files in preprocessor cache mode. We can do better.
ahartmetz added a commit to ahartmetz/sccache that referenced this pull request Jul 8, 2025
This reverts the "main" code changes of commit
c0a0b6e but keeps the added test.

That commit fixed getting wrong dep files from cache in non
preprocessor cache mode, but made it impossible to support dep
files in preprocessor cache mode. We can do better.
ahartmetz added a commit to ahartmetz/sccache that referenced this pull request Jul 8, 2025
This reverts the "main" code changes of commit
c0a0b6e but keeps the added test.

That commit fixed getting wrong dep files from cache in non
preprocessor cache mode, but made it impossible to support dep
files in preprocessor cache mode. We can do better.
ahartmetz added a commit to ahartmetz/sccache that referenced this pull request Jul 9, 2025
This reverts the "main" code changes of commit
c0a0b6e but keeps the added test.

That commit fixed getting wrong dep files from cache in non
preprocessor cache mode, but made it impossible to support dep
files in preprocessor cache mode. We can do better.
ahartmetz added a commit to ahartmetz/sccache that referenced this pull request Jul 9, 2025
This reverts the "main" code changes of commit
c0a0b6e but keeps the added test.

That commit fixed getting wrong dep files from cache in non
preprocessor cache mode, but made it impossible to support dep
files in preprocessor cache mode. We can do better.
ahartmetz added a commit to ahartmetz/sccache that referenced this pull request Jul 9, 2025
This reverts the "main" code changes of commit
c0a0b6e but keeps the added test.

That commit fixed getting wrong dep files from cache in non
preprocessor cache mode, but made it impossible to support dep
files in preprocessor cache mode. We can do better.
ahartmetz added a commit to ahartmetz/sccache that referenced this pull request Jul 9, 2025
This reverts the "main" code changes of commit
c0a0b6e but keeps the added test.

That commit fixed getting wrong dep files from cache in non
preprocessor cache mode, but made it impossible to support dep
files in preprocessor cache mode. We can do better.
ahartmetz added a commit to ahartmetz/sccache that referenced this pull request Jul 11, 2025
This reverts the "main" code changes of commit
c0a0b6e but keeps the added test.

That commit fixed getting wrong dep files from cache in non
preprocessor cache mode, but made it impossible to support dep
files in preprocessor cache mode. We can do better.
ahartmetz added a commit to ahartmetz/sccache that referenced this pull request Aug 4, 2025
This reverts the "main" code changes of commit
c0a0b6e but keeps the added test.

That commit fixed getting wrong dep files from cache in non
preprocessor cache mode, but made it impossible to support dep
files in preprocessor cache mode. We can do better.
sylvestre pushed a commit that referenced this pull request Aug 4, 2025
This reverts the "main" code changes of commit
c0a0b6e but keeps the added test.

That commit fixed getting wrong dep files from cache in non
preprocessor cache mode, but made it impossible to support dep
files in preprocessor cache mode. We can do better.
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.

3 participants