[compiler-rt] [compiler-rt][MSVC][CMake] Wrap Linker flags for ICX (PR #118496)
via llvm-commits
llvm-commits at lists.llvm.org
Sat May 17 09:14:46 PDT 2025
BukeBeyond wrote:
These lines in compiler-rt/CMakeLists.txt:763, Break Windows build of compiler-rt with:
`llvm-ar.exe: error: -Xlinker; option not supported on non AIX OS`
CMAKE_STATIC_LINKER_FLAGS are for .lib archives given to llvm-ar , which does not accept "-Xlinker", and thus, terminate the build. CMAKE_CXX_LINKER_WRAPPER_FLAG contains -Xlinker which CMake provides from platform defaults.
The correct variables to set are:
```
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_CXX_LINKER_WRAPPER_FLAG}/IGNORE:4221")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_CXX_LINKER_WRAPPER_FLAG}/IGNORE:4221")
```
the first for exe files, and the second, for dll files. The first is probably not relevant for compiler-rt.
Another problem is:
`if (CMAKE_LINKER MATCHES "link.exe$")`
which matches both link.exe and lld-link.exe. In Windows, the case of file path does not matter.
Thus, this is more correct:
```
string(TOLOWER "${CMAKE_LINKER}" LinkerLowercase)
if (LinkerLowercase MATCHES [[(^|[/\\])link\.exe$]])
```
https://github.com/llvm/llvm-project/pull/118496
More information about the llvm-commits
mailing list