Skip to content

Don't cache dep file #2322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 30, 2025
Merged

Don't cache dep file #2322

merged 1 commit into from
Jan 30, 2025

Conversation

glandium
Copy link
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
57 of 59 checks passed
@codecov-commenter
Copy link

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.
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