[llvm] Build clang with the latest released clang on Windows on Arm. (PR #116701)

Daniel Kiss via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 18 14:23:18 PST 2024


https://github.com/DanielKristofKiss created https://github.com/llvm/llvm-project/pull/116701

With this[1] build of clang out of the box cmake fails.
On a Windows on Arm with just cmake, ninja, git, python and clang[1] can be built with[2] this change. 
`check-clang` doesn't work yet due to link issue with the unit tests.

[1] https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.2/LLVM-19.1.2-woa64.exe
[2] `cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;lld" -DLLVM_ENABLE_RUNTIMES="compiler-rt" -DLLVM_TARGETS_TO_BUILD="AArch64"  -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF ../llvm && ninja clang compiler-rt`


>From 38d6e3f5e2a0fc930f12450d3a78d0705c72bb83 Mon Sep 17 00:00:00 2001
From: Daniel Kiss <daniel.kiss at arm.com>
Date: Mon, 18 Nov 2024 19:58:31 +0000
Subject: [PATCH] Build clang with the latest released clang on Windows on Arm.

With this[1] build of clang out of the box cmake fails.
On a Windows on Arm with just cmake, ninja, git, python and clang[1] can be built with[2] this change.
check-clang doesn't work yet.

[1] https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.2/LLVM-19.1.2-woa64.exe
[2] cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;lld" -DLLVM_ENABLE_RUNTIMES="compiler-rt" -DLLVM_TARGETS_TO_BUILD="AArch64"  -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF ../llvm && ninja clang compiler-rt

Change-Id: I8849489fc043e63efa57d2d45fb596d422d6baaf
---
 llvm/cmake/modules/GetHostTriple.cmake | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/llvm/cmake/modules/GetHostTriple.cmake b/llvm/cmake/modules/GetHostTriple.cmake
index 1be13bc01ab9b2..2a10b1d256c7a0 100644
--- a/llvm/cmake/modules/GetHostTriple.cmake
+++ b/llvm/cmake/modules/GetHostTriple.cmake
@@ -42,7 +42,21 @@ function( get_host_triple var )
       set( value "powerpc-ibm-aix" )
     endif()
   else( MSVC )
-    if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows AND NOT MSYS)
+    if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows AND NOT MSYS AND CMAKE_C_COMPILER_ID MATCHES "Clang" )
+      if( CMAKE_C_COMPILER_ARCHITECTURE_ID MATCHES "ARM64.*" )
+        set( value "aarch64-pc-windows-msvc" )
+      elseif( CMAKE_C_COMPILER_ARCHITECTURE_ID MATCHES "ARM.*" )
+        set( value "armv7-pc-windows-msvc" )
+      elseif( CMAKE_C_COMPILER_ARCHITECTURE_ID STREQUAL "x64" )
+        set( value "x86_64-pc-windows-msvc" )
+      elseif( CMAKE_C_COMPILER_ARCHITECTURE_ID STREQUAL "X86" )
+        set( value "i686-pc-windows-msvc" )
+      elseif( CMAKE_SIZEOF_VOID_P EQUAL 8 )
+        set( value "x86_64-pc-windows-msvc" )
+      else()
+        set( value "i686-pc-windows-msvc" )
+      endif()
+    elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows AND NOT MSYS)
       message(WARNING "unable to determine host target triple")
     else()
       set(config_guess ${LLVM_MAIN_SRC_DIR}/cmake/config.guess)



More information about the llvm-commits mailing list