Skip to content

Commit

Permalink
[CMake][compiler-rt] Support clang-cl in CompilerRTMockLLVMCMakeConfig
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tru committed Feb 10, 2023
1 parent b3477f5 commit 8ccde93
Showing 1 changed file with 7 additions and 1 deletion.
Expand Up @@ -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)
Expand Down

0 comments on commit 8ccde93

Please sign in to comment.