Skip to content

Don't ask gcc for multiarch on Windows - #9718

Merged
mattgodbolt merged 3 commits into
mainfrom
claude/project-thread-v3sqcx
Nov 29, 2026
Merged

mattgodbolt merged 3 commits into
mainfrom
claude/project-thread-v3sqcx

Conversation

@mattgodbolt

Copy link
Copy Markdown
Member

Requested by Matt

Fixes #9709.

CompilationEnvironment's constructor runs gcc -print-multiarch synchronously, every time. On Windows the answer is always empty (multiarch is a Debian thing), but the first non-builtin spawn in a process is expensive there. A diagnostic run on windows-2022 (commit 6d890d9 on this branch, since removed) measured, in a fresh test worker:

echo hi (cmd builtin)      11ms
where gcc                 444ms   -> C:\mingw64\bin\gcc.exe
gcc -print-multiarch #1    22ms   -> (empty)
gcc -print-multiarch #2    20ms

So the first test in a file that builds an environment pays a few hundred ms. In recent green Windows runs that's 300-450ms on the cache-key test in build-systems-tests, against 15ms on Linux. In the failed run on #9669 that test took 5463ms, and the first env-building tests in compilation-cache-key-tests (2677ms) and base-compiler-tests were slow too. All three finished within a second of each other early in the run, while the runner was busiest. Nothing else in BaseCompiler or the environment touches the OS.

The fix skips the lookup on win32. multiarch was already null there, so getEnv behaves as before. New tests cover the Linux path (tuple found, gcc missing) and check that Windows never spawns.

I left one pre-existing issue alone: on Linux the call has no timeout, so a hung gcc would block startup. Happy to follow up with a timeout.

Separately, test/utils.ts's makeCompilationEnvironment passes options.doCache as the 4th argument, which is formattingService, so doCache is silently ignored. It's harmless today because test props have no cacheConfig. I can fix it in its own PR.


Generated by Claude Code

Every CompilationEnvironment ran `gcc -print-multiarch` synchronously in its
constructor. On Windows that answers nothing, but the first spawn in a process
costs a cold PATH search and process start: several hundred ms on the Windows
CI runner, and 5.4s on a loaded one, which timed out the first test in
build-systems-tests that made an environment.

Skip it on win32, and cover the multiarch lookup with tests.

Fixes #9709

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… the platform descriptor

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mattgodbolt mattgodbolt self-assigned this Nov 29, 2026
@github-actions github-actions Bot added the MS/Windows Microsoft or Windows specific issues label Nov 29, 2026
Comment thread lib/compilation-env.ts
type FindCompiler = (langId: LanguageKey, compilerId: string) => BaseCompiler | undefined;

function findMultiarch(): string | null {
// Multiarch is a Debian notion and Windows gcc prints nothing for it, so don't pay for a process start to ask.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you note a TODO issue (after checking for any existing) to look into doing this asynchronously and/or removing multiarch support if it's no longer needed (it's one of the earliest hacky things I put in to support the particular machine I started on; maybe still needed but we should check).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed as #9722. No existing issue covered it. It notes that prod nodes do have a host gcc, so multiarch is live there, and it cites earlier bugs it caused (#994, #7419).


Generated by Claude Code

@mattgodbolt
mattgodbolt merged commit 53b7fb7 into main Nov 29, 2026
19 checks passed
@mattgodbolt
mattgodbolt deleted the claude/project-thread-v3sqcx branch November 29, 2026 12:01
@compiler-explorer-bot compiler-explorer-bot Bot added the live This is now live label Nov 29, 2026
@compiler-explorer-bot

Copy link
Copy Markdown

This is now live

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

live This is now live MS/Windows Microsoft or Windows specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows CI: build-systems-tests cache-key test timed out at 5s

2 participants