[compiler-rt] 8ccde93 - [CMake][compiler-rt] Support clang-cl in CompilerRTMockLLVMCMakeConfig

Tobias Hieta via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 10 05:32:53 PST 2023


Author: Tobias Hieta
Date: 2023-02-10T14:32:46+01:00
New Revision: 8ccde9368f94f7402129e6e61a02d7863f2b6283

URL: https://github.com/llvm/llvm-project/commit/8ccde9368f94f7402129e6e61a02d7863f2b6283
DIFF: https://github.com/llvm/llvm-project/commit/8ccde9368f94f7402129e6e61a02d7863f2b6283.diff

LOG: [CMake][compiler-rt] Support clang-cl in CompilerRTMockLLVMCMakeConfig

clang-cl doesn't support -dumpmachine directly, so we need to
preface it with /clang: in order to get this probing function
to work.

This is needed in order to run cmake directly on the runtimes
directory.

Reviewed By: hans

Differential Revision: https://reviews.llvm.org/D143557

Added: 
    

Modified: 
    compiler-rt/cmake/Modules/CompilerRTMockLLVMCMakeConfig.cmake

Removed: 
    


################################################################################
diff  --git a/compiler-rt/cmake/Modules/CompilerRTMockLLVMCMakeConfig.cmake b/compiler-rt/cmake/Modules/CompilerRTMockLLVMCMakeConfig.cmake
index 4b71369642a26..2ab29878bc6a2 100644
--- a/compiler-rt/cmake/Modules/CompilerRTMockLLVMCMakeConfig.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTMockLLVMCMakeConfig.cmake
@@ -46,8 +46,14 @@ function(compiler_rt_mock_llvm_cmake_config_set_target_triple)
     if ("${CMAKE_C_COMPILER_ID}" MATCHES "Clang|GNU")
       # Note: Clang also supports `-print-target-triple` but gcc doesn't
       # support this flag.
+      set(DUMPMACHINE_ARG -dumpmachine)
+      if(MSVC)
+        # This means we are using clang-cl and it requires
+        # /clang: as prefix for dumpmachine argument.
+        set(DUMPMACHINE_ARG /clang:-dumpmachine)
+      endif()
       execute_process(
-        COMMAND "${CMAKE_C_COMPILER}" -dumpmachine
+        COMMAND "${CMAKE_C_COMPILER}" ${DUMPMACHINE_ARG}
         RESULT_VARIABLE HAD_ERROR
         OUTPUT_VARIABLE COMPILER_OUTPUT
         OUTPUT_STRIP_TRAILING_WHITESPACE)


        


More information about the llvm-commits mailing list