mirror of
https://github.com/fmtlib/fmt.git
synced 2026-08-03 20:14:20 +02:00
Set matching CC alongside CXX in Linux CI matrix (#4863)
* Set matching CC alongside CXX in Linux CI matrix 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. * Skip c-test when the C compiler is Clang < 3.8 Setting CC from matrix.cxx means the clang++-3.6 job now configures with real clang 3.6 instead of falling back to the runner's default GCC, which exposes a compile failure in test/c-test.c: clang predates the LLVM PR16340 fix (landed in 3.8) that applies array-to-pointer decay to the controlling expression of _Generic, so fmt-c.h's FMT_MAKE_ARG dispatch never matches a string literal (char[4]) against its char*/const char* associations. It falls through to the zero-argument default association, which is then called with one argument. The guard is at configure time rather than in the CI Test step. c-test is part of the default target, so `cmake --build` compiles it before ctest ever runs -- excluding it with `ctest -E` cannot help, because the job has already failed in the Build step. Guarding the add_executable also means anyone building fmt's tests with an old clang benefits, not just this one CI job. enable_language(C) stays first and unconditional, since CMAKE_C_COMPILER_VERSION is not set before it. fmt-c itself (src/fmt-c.cc, C++) still builds on that job; only the C-consumer smoke test is skipped.
This commit is contained in:
@@ -179,6 +179,13 @@ jobs:
|
||||
sudo apt install locales-all
|
||||
cmake -E make_directory ${{runner.workspace}}/build
|
||||
|
||||
- name: Select matching C compiler
|
||||
run: |
|
||||
cc=${{matrix.cxx}}
|
||||
cc=${cc/clang++/clang}
|
||||
cc=${cc/g++/gcc}
|
||||
echo "CC=$cc" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Configure
|
||||
working-directory: ${{runner.workspace}}/build
|
||||
env:
|
||||
|
||||
Reference in New Issue
Block a user