Skip to content

Commit e9be217

Browse files
[CMake] Handle clang in MSVC mode in GetHostTriple (#116701)
When configuring CMake with Clang in MSVC mode, Clang can either be invoked with the MSVC style driver (clang-cl) or the GNU style driver (clang). When using the MSVC style driver, CMake sets the CMake variable MSVC (which indicates the kind of command line interface), but when using the GNU style driver, this variable isn't set, while Clang still operates in MSVC mode. Even though CMake doesn't set the variable MSVC, it still does set CMAKE_C_COMPILER_ARCHITECTURE_ID, which it does set for MSVC and Clang in MSVC mode, but not for Clang in MinGW mode. For this configuration, use the MSVC style, CMAKE_C_COMPILER_ARCHITECTURE_ID based GetHostTriple implementation.
1 parent 26baa00 commit e9be217

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

llvm/cmake/modules/GetHostTriple.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Invokes config.guess
33

44
function( get_host_triple var )
5-
if( MSVC )
5+
if( MSVC OR (CMAKE_SYSTEM_NAME STREQUAL "Windows" AND CMAKE_C_COMPILER_ID MATCHES "Clang" AND NOT MINGW AND NOT MSYS))
66
if( CMAKE_C_COMPILER_ARCHITECTURE_ID MATCHES "ARM64.*" )
77
set( value "aarch64-pc-windows-msvc" )
88
elseif( CMAKE_C_COMPILER_ARCHITECTURE_ID MATCHES "ARM.*" )
@@ -41,7 +41,7 @@ function( get_host_triple var )
4141
else()
4242
set( value "powerpc-ibm-aix" )
4343
endif()
44-
else( MSVC )
44+
else()
4545
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows AND NOT MSYS)
4646
message(WARNING "unable to determine host target triple")
4747
else()

0 commit comments

Comments
 (0)