[llvm] r361072 - build: use clang-cl for runtimes when targeting Windows
Saleem Abdulrasool via llvm-commits
llvm-commits at lists.llvm.org
Fri May 17 13:09:06 PDT 2019
Author: compnerd
Date: Fri May 17 13:09:06 2019
New Revision: 361072
URL: http://llvm.org/viewvc/llvm-project?rev=361072&view=rev
Log:
build: use clang-cl for runtimes when targeting Windows
When targeting Windows and building a runtime (subproject) prefer to use
`clang-cl` rather than the `clang` driver. This allows us to cross-compile
runtimes for the Windows environment from Linux.
Modified:
llvm/trunk/cmake/modules/LLVMExternalProjectUtils.cmake
Modified: llvm/trunk/cmake/modules/LLVMExternalProjectUtils.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/LLVMExternalProjectUtils.cmake?rev=361072&r1=361071&r2=361072&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/LLVMExternalProjectUtils.cmake (original)
+++ llvm/trunk/cmake/modules/LLVMExternalProjectUtils.cmake Fri May 17 13:09:06 2019
@@ -104,13 +104,28 @@ function(llvm_ExternalProject_Add name s
endforeach()
endforeach()
+ foreach(arg ${ARG_CMAKE_ARGS})
+ if(arg MATCHES "^-DCMAKE_SYSTEM_NAME=")
+ string(REGEX REPLACE "^-DCMAKE_SYSTEM_NAME=(.*)$" "\\1" _cmake_system_name "${arg}")
+ endif()
+ endforeach()
+
if(ARG_USE_TOOLCHAIN AND NOT CMAKE_CROSSCOMPILING)
if(CLANG_IN_TOOLCHAIN)
- set(compiler_args -DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
- -DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++)
+ if(_cmake_system_name STREQUAL Windows)
+ set(compiler_args -DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang-cl
+ -DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang-cl)
+ else()
+ set(compiler_args -DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
+ -DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++)
+ endif()
endif()
if(lld IN_LIST TOOLCHAIN_TOOLS)
- list(APPEND compiler_args -DCMAKE_LINKER=${LLVM_RUNTIME_OUTPUT_INTDIR}/ld.lld)
+ if(_cmake_system_name STREQUAL Windows)
+ list(APPEND compiler_args -DCMAKE_LINKER=${LLVM_RUNTIME_OUTPUT_INTDIR}/lld-link)
+ else()
+ list(APPEND compiler_args -DCMAKE_LINKER=${LLVM_RUNTIME_OUTPUT_INTDIR}/ld.lld)
+ endif()
endif()
if(llvm-ar IN_LIST TOOLCHAIN_TOOLS)
list(APPEND compiler_args -DCMAKE_AR=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ar)
More information about the llvm-commits
mailing list