[llvm] e9be217 - [CMake] Handle clang in MSVC mode in GetHostTriple (#116701)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 29 01:31:35 PST 2024
Author: Daniel Kiss
Date: 2024-11-29T10:31:31+01:00
New Revision: e9be21786c972de93206599d4e06b79c2ca8f772
URL: https://github.com/llvm/llvm-project/commit/e9be21786c972de93206599d4e06b79c2ca8f772
DIFF: https://github.com/llvm/llvm-project/commit/e9be21786c972de93206599d4e06b79c2ca8f772.diff
LOG: [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.
Added:
Modified:
llvm/cmake/modules/GetHostTriple.cmake
Removed:
################################################################################
diff --git a/llvm/cmake/modules/GetHostTriple.cmake b/llvm/cmake/modules/GetHostTriple.cmake
index 1be13bc01ab9b2..d3b26d445c9962 100644
--- a/llvm/cmake/modules/GetHostTriple.cmake
+++ b/llvm/cmake/modules/GetHostTriple.cmake
@@ -2,7 +2,7 @@
# Invokes config.guess
function( get_host_triple var )
- if( MSVC )
+ if( MSVC OR (CMAKE_SYSTEM_NAME STREQUAL "Windows" AND CMAKE_C_COMPILER_ID MATCHES "Clang" AND NOT MINGW AND NOT MSYS))
if( CMAKE_C_COMPILER_ARCHITECTURE_ID MATCHES "ARM64.*" )
set( value "aarch64-pc-windows-msvc" )
elseif( CMAKE_C_COMPILER_ARCHITECTURE_ID MATCHES "ARM.*" )
@@ -41,7 +41,7 @@ function( get_host_triple var )
else()
set( value "powerpc-ibm-aix" )
endif()
- else( MSVC )
+ else()
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows AND NOT MSYS)
message(WARNING "unable to determine host target triple")
else()
More information about the llvm-commits
mailing list