Skip to content

gcc, clang: make the assembler part of the cache key - #2843

Merged
sylvestre merged 1 commit into
mozilla:mainfrom
glandium:assembler
Sep 10, 2026
Merged

sylvestre merged 1 commit into
mozilla:mainfrom
glandium:assembler

Conversation

@glandium

Copy link
Copy Markdown
Collaborator

GCC always assembles by spawning as, and clang does too when its integrated assembler is turned off, so the object file depends on a program that nothing in the cache key accounted for: two invocations with different binutils could hand each other the wrong object.

Compiler detection now asks the compiler which assembler it would run and identifies it the way the compiler itself is identified, by the contents of the binary plus the version it reports. It only reaches the key when a compilation really runs an external assembler, so clang keys don't move unless -fno-integrated-as is passed, and neither do MSVC's. Keys where no assembler could be identified don't move either, which keeps existing cache entries usable and is why CACHE_VERSION stays put.

A hit on a preprocessor cache entry hands back the object cache key stored in it rather than computing one, so the assembler has to be part of that key as well.

Full background in https://bugzilla.mozilla.org/show_bug.cgi?id=2070810.

GCC always assembles by spawning `as`, and clang does too when its
integrated assembler is turned off, so the object file depends on a
program that nothing in the cache key accounted for: two invocations with
different binutils could hand each other the wrong object.

Compiler detection now asks the compiler which assembler it would run and
identifies it the way the compiler itself is identified, by the contents
of the binary plus the version it reports. It only reaches the key when a
compilation really runs an external assembler, so clang keys don't move
unless -fno-integrated-as is passed, and neither do MSVC's. Keys where no
assembler could be identified don't move either, which keeps existing
cache entries usable and is why CACHE_VERSION stays put.

A hit on a preprocessor cache entry hands back the object cache key stored
in it rather than computing one, so the assembler has to be part of that
key as well.

Full background in https://bugzilla.mozilla.org/show_bug.cgi?id=2070810.
@glandium
glandium requested a review from sylvestre September 10, 2026 07:30
@codecov-commenter

codecov-commenter commented Sep 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.90476% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.14%. Comparing base (05aafc8) to head (c75018d).

Files with missing lines Patch % Lines
src/compiler/compiler.rs 97.07% 7 Missing ⚠️
tests/system.rs 94.02% 4 Missing ⚠️
src/compiler/gcc.rs 93.75% 1 Missing ⚠️
src/test/utils.rs 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2843      +/-   ##
==========================================
+ Coverage   73.84%   76.14%   +2.29%     
==========================================
  Files          72       72              
  Lines       38178    39807    +1629     
==========================================
+ Hits        28194    30311    +2117     
+ Misses       9984     9496     -488     

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

@sylvestre
sylvestre merged commit 4ffa89b into mozilla:main Sep 10, 2026
51 checks passed
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