[compiler-rt] [compiler-rt][MSVC][CMake] Wrap Linker flags for ICX (PR #118496)

Mészáros Gergely via llvm-commits llvm-commits at lists.llvm.org
Mon May 19 01:47:44 PDT 2025


Maetveis wrote:

> I tested with Cmake 3.29.4 and the latest 4.0.2. I also tested with clang and clang-cl as the compiler. Here is the [CMakeCache.txt](https://github.com/user-attachments/files/20273985/CMakeCache.txt) with the build settings.

**Where is `LLVM_HOST_TRIPLE=x86_64-pc-win32` coming from**? Are you setting that explicitly during configure? I would expect it to be `x86_64-pc-windows-msvc`.
Normally the runtimes sub-build of compiler-rt would use the newly built clang-cl on windows, and not clang as I suspect what's happening in your case.

> However for Static libraries (.lib / .a), CMake directly calls llvm-ar or lib.exe, bypassing the Compiler. Therefore, CMAKE_STATIC_LINKER_FLAGS are passed as-is — and should not include CMAKE_CXX_LINKER_WRAPPER_FLAG, which only makes sense when going through the Compiler.

That differs between compiler to compiler. For clang-cl, MSVC and clang you're correct, but for the Intel Compiler icx, linking static libraries also goes through the compiler.

That said I'm aware that `CMAKE_CXX_LINKER_WRAPPER_FLAG` is not the correct variable to use in `CMAKE_STATIC_LINKER_FLAGS`. From CMake 4.0 onwards there is [`CMAKE_CXX_ARCHIVER_WRAPPER_FLAG`](https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_ARCHIVER_WRAPPER_FLAG.html#variable:CMAKE_%3CLANG%3E_ARCHIVER_WRAPPER_FLAG), but LLVM's minimum supported version is 3.20.

So this PR I probably broke building compiler-rt with clang (not clang-cl) on Windows, which is not something I was aware of anyone using. I'll see if I can reproduce and fix that.

https://github.com/llvm/llvm-project/pull/118496


More information about the llvm-commits mailing list