[compiler-rt] [compiler-rt] Fix CMake configure on Windows (PR #90843)

Omair Javaid via llvm-commits llvm-commits at lists.llvm.org
Thu May 2 03:30:38 PDT 2024


https://github.com/omjavaid created https://github.com/llvm/llvm-project/pull/90843

CMake configure compiler-rt got broken as a result of following commit: d3925e65a7ab88eb0ba68d3ab79cd95db5629951

This patch fixes the break by porting the above commit for clang-cl.

This problem was not caught on Windows buildbots beacuase it appeared when compiler-rt was included via LLVM_ENABLE_PROJECTS while buildbots include compiler-rt project using LLVM_ENABLE_RUNTIMES flag.

>From b1ef7187e31d6e7b8fc17bec0d8c852f9486a709 Mon Sep 17 00:00:00 2001
From: Muhammad Omair Javaid <omair.javaid at linaro.org>
Date: Thu, 2 May 2024 13:27:48 +0500
Subject: [PATCH] [compiler-rt] Fix CMake configure on Windows

CMake configure compiler-rt got broken as a result of following commit:
d3925e65a7ab88eb0ba68d3ab79cd95db5629951

This patch fixes the break by porting the above commit for clang-cl.

This problem was not caught on Windows buildbots beacuase it appeared
when compiler-rt was included via LLVM_ENABLE_PROJECTS while buildbots
include compiler-rt project using LLVM_ENABLE_RUNTIMES flag.
---
 compiler-rt/cmake/Modules/CompilerRTUtils.cmake | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
index a6c6ef93500d53..240c9837b2d201 100644
--- a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
@@ -369,7 +369,11 @@ macro(construct_compiler_rt_default_triple)
   endif()
 
   if ("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
-    execute_process(COMMAND ${CMAKE_C_COMPILER} --target=${COMPILER_RT_DEFAULT_TARGET_TRIPLE} -print-target-triple
+    set(cmd_prefix "")
+    if (CMAKE_C_SIMULATE_ID MATCHES "MSVC")
+      set(cmd_prefix "/clang:")
+    endif()
+    execute_process(COMMAND ${CMAKE_C_COMPILER} ${cmd_prefix}--target=${COMPILER_RT_DEFAULT_TARGET_TRIPLE} ${cmd_prefix}-print-target-triple
                     OUTPUT_VARIABLE COMPILER_RT_DEFAULT_TARGET_TRIPLE
                     OUTPUT_STRIP_TRAILING_WHITESPACE)
   endif()



More information about the llvm-commits mailing list