Skip to content

Set matching CC alongside CXX in Linux CI matrix#4863

Open
hexonal wants to merge 1 commit into
fmtlib:mainfrom
hexonal:fix-linux-ci-cc-cxx-mismatch
Open

Set matching CC alongside CXX in Linux CI matrix#4863
hexonal wants to merge 1 commit into
fmtlib:mainfrom
hexonal:fix-linux-ci-cc-cxx-mismatch

Conversation

@hexonal

@hexonal hexonal commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Fixes #4858

Problem

The Linux CI matrix deliberately varies matrix.cxx across old and new compilers (g++-4.9, clang++-3.6, clang++-20, etc.) to test compatibility, but the Configure step only sets CXX. With no CC, CMake's C compiler detection falls back to whatever default happens to be on the runner (as reported: clang++-3.6 for C++, but GNU 11.4.0 detected for C) — completely unrelated to the compiler version the job is actually meant to be testing.

Fix

Add a small step before Configure that derives CC from the same matrix.cxx value each job already installs a matching compiler for (clang++-Nclang-N, g++-Ngcc-N):

cc=${{matrix.cxx}}
cc=${cc/clang++/clang}
cc=${cc/g++/gcc}
echo "CC=$cc" >> "$GITHUB_ENV"

Testing

This is a CI-config-only change, so the real test is the workflow run itself — I checked every distinct matrix.cxx value used in this file (g++-4.9, g++-11, g++-13, g++-14, clang++-3.6, clang++-11, clang++-14, clang++-20) against the corresponding install/package steps in the same file to confirm a matching gcc-N/clang-N binary is actually installed for each before relying on it (e.g. the "Install GCC 4.9" step explicitly dpkg -is a gcc-4.9 package, "Install Clang 3.6" explicitly installs clang-3.6, etc.) — the two entries without an explicit install step (g++-13/g++-14 on ubuntu-24.04, one clang++-14 variant) rely on the runner image's default toolchain, where the C and C++ drivers for the same version are always installed together. I also verified the string-substitution logic locally in bash against all 8 values (clang++-3.6 correctly does not get double-substituted by the g++gcc replacement, since the clang++clang substitution runs first and already consumes the trailing g++ substring), and validated the YAML with ruby -ryaml. I can't run the actual matrix locally, so I'll be watching this PR's own CI run closely.

The Configure step only set CXX, so CMake's C compiler detection
fell back to whatever the default happened to be on the runner,
independent of which C++ compiler the matrix entry was actually
testing (e.g. CXX=clang++-3.6 but CC left to detect GCC 11).

Derive CC from the same matrix.cxx value the job already installs
a matching compiler for.
@hexonal
hexonal requested a review from vitaut as a code owner July 21, 2026 01:17
@hexonal

hexonal commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

The clang++-3.6/g++-4.9 jobs failed on this run, but not because of this PR's change. The actual error in the clang++-3.6 jobs is wget failing to download the old compiler .debs from launchpadlibrarian.net with repeated ERROR 503: Service Unavailable — an external package-mirror outage, unrelated to the CC/CXX selection logic this PR touches (the new "Select matching C compiler" step itself ran fine, correctly resolving CC=gcc-4.9/CC=clang-3.6). The g++-4.9 jobs show as cancelled rather than failed, which is the matrix's default fail-fast behavior kicking in once the clang++-3.6 jobs errored.

I don't have permission to re-run just the failed jobs (not a repo admin) — happy to push an empty commit to retrigger if useful, or this should resolve on its own next time CI runs against this branch.

@vitaut

vitaut commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

I triggered a re-run.

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.

The Linux CI jobs use a different C compile than for C++

2 participants