[libcxx-commits] [libcxx] [llvm] [libcxx][llvm]: Fix misidentification of GNU-style clang as clang-cl (PR #225124)
Jacob Abel via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Oct 13 08:53:03 PDT 2026
OneDeuxTriSeiGo wrote:
> Can you clarify the different cmake variables here - they're not immediately obvious as they're all named similar-ish.
>
> `CMAKE_CXX_COMPILER_FRONTEND_VARIANT` - is this about whether using `clang-cl` command line syntax, as opposed to `clang` with the GNU style command line? Is there a reason for using this specifically here? The `MSVC` variable in cmake is also set for both actual MSVC `cl.exe` and with `clang-cl`.
>
> `CMAKE_CXX_SIMULATE_ID` is set to `MSVC` for both `clang-cl`, and `clang` with an MSVC target, right?
Yes. yes, and yes.
`CMAKE_<LANG>_COMPILER_FRONTEND_VARIANT` is set based on what frontend interface it emulates [1], i.e. whether it has MSVC style flags or GNU style flags (or some other arcane compiler CLI variant).
`CMAKE_<LANG>_SIMULATE_ID` on the other hand is determined by which compiler it is a drop in replacement for in terms of compilation, implementation defined behavior, and language specific details [2]. This also pairs with `CMAKE_<LANG>_SIMULATE_VERSION` which determines the equivalent compiler version it is targeting [3]. i.e. `CMAKE_<LANG>_COMPILER_VERSION` for the compiler it is targeting [4].
i.e. `CMAKE_<LANG>_COMPILER_FRONTEND_VARIANT` determines compiler API and `CMAKE_<LANG>_SIMULATE_ID` + `CMAKE_<LANG>_SIMULATE_VERSION` determine the ABI of the generated code.
And according to the cmake docs any compiler with a `CMAKE_<LANG>_SIMULATE_ID` of `MSVC` will define the `MSVC` cmake variable and the corresponding #defines in c/c++ code [5]. Likewise for `MSVC_VERSION` [6] and `MSVC_TOOLSET_VERSION` [7].
-------------------
> Can you also briefly confirm that both `LIBCXX_TARGETING_CLANG_CL` and `CLANG_CL` only affect options specifically relating to the `cl.exe` style of command line options, not anything else?
I just took a quick look and it'll require some further modifications to fully decouple those two and likely some other parts of the CMake that depend on them. I didn't notice those bits when I initially wrote up the PR so I'll have to make those changes this week and I'll @ you when I finish redrafting the PR. Would you like me to convert the PR back to a draft in the meantime?
-------------------
> It would be good to briefly rehash these details in the commit message (i.e. the PR description) to make it clear to both current and future readers.
Will do. When I reroll this PR I'll add all these details into the commit messages and an overall summary for the PR at the head.
-------------------
1. https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_FRONTEND_VARIANT.html
2. https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_SIMULATE_ID.html
3. https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_SIMULATE_VERSION.html
4. https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_VERSION.html
5. https://cmake.org/cmake/help/latest/variable/MSVC.html
6. https://cmake.org/cmake/help/latest/variable/MSVC_VERSION.html
7. https://cmake.org/cmake/help/latest/variable/MSVC_TOOLSET_VERSION.html
https://github.com/llvm/llvm-project/pull/225124
More information about the libcxx-commits
mailing list