forked from OSchip/llvm-project
[CMake][Fuchsia] Support for building with MSVC
This change adds the necessary flags for building the full Fuchsia toolchain on Windows with MSVC. Differential Revision: https://reviews.llvm.org/D73810
This commit is contained in:
parent
c92a8c0a0f
commit
53e38c85a8
|
@ -5,7 +5,6 @@ set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64;RISCV CACHE STRING "")
|
|||
set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
|
||||
|
||||
set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;lld;llvm" CACHE STRING "")
|
||||
set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
|
||||
|
||||
set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
|
||||
if(NOT APPLE)
|
||||
|
@ -22,6 +21,10 @@ set(LLVM_INCLUDE_GO_TESTS OFF CACHE BOOL "")
|
|||
set(LLVM_USE_RELATIVE_PATHS_IN_FILES ON CACHE BOOL "")
|
||||
set(LLVM_ENABLE_Z3_SOLVER OFF CACHE BOOL "")
|
||||
|
||||
if(MSVC)
|
||||
set(LLVM_USE_CRT_RELEASE "MT" CACHE STRING "")
|
||||
endif()
|
||||
|
||||
set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
|
||||
if(NOT APPLE)
|
||||
set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
|
||||
|
@ -39,6 +42,8 @@ set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL "")
|
|||
set(CMAKE_BUILD_TYPE Release CACHE STRING "")
|
||||
if (APPLE)
|
||||
set(MACOSX_DEPLOYMENT_TARGET 10.7 CACHE STRING "")
|
||||
elseif(MSVC)
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded" CACHE STRING "")
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
|
@ -65,6 +70,26 @@ if(APPLE)
|
|||
set(DARWIN_iossim_ARCHS i386;x86_64 CACHE STRING "")
|
||||
set(DARWIN_osx_ARCHS x86_64 CACHE STRING "")
|
||||
set(SANITIZER_MIN_OSX_VERSION 10.7 CACHE STRING "")
|
||||
set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
set(target "x86_64-pc-windows-msvc")
|
||||
|
||||
list(APPEND BUILTIN_TARGETS "${target}")
|
||||
set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
|
||||
set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
|
||||
|
||||
list(APPEND RUNTIME_TARGETS "${target}")
|
||||
set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
|
||||
set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
|
||||
set(RUNTIMES_${target}_LIBCXX_ABI_VERSION 2 CACHE STRING "")
|
||||
set(RUNTIMES_${target}_LIBCXX_HAS_WIN32_THREAD_API ON CACHE BOOL "")
|
||||
set(RUNTIMES_${target}_LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "")
|
||||
set(RUNTIMES_${target}_LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
|
||||
set(RUNTIMES_${target}_LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "")
|
||||
set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
|
||||
set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE STRING "")
|
||||
endif()
|
||||
|
||||
foreach(target aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unknown-linux-gnu;x86_64-unknown-linux-gnu)
|
||||
|
@ -73,6 +98,9 @@ foreach(target aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
|
|||
list(APPEND BUILTIN_TARGETS "${target}")
|
||||
set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
|
||||
set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
|
||||
set(BUILTINS_${target}_CMAKE_C_FLAGS "--target=${target}" CACHE STRING "")
|
||||
set(BUILTINS_${target}_CMAKE_CXX_FLAGS "--target=${target}" CACHE STRING "")
|
||||
set(BUILTINS_${target}_CMAKE_ASM_FLAGS "--target=${target}" CACHE STRING "")
|
||||
set(BUILTINS_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE STRING "")
|
||||
set(BUILTINS_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
|
||||
set(BUILTINS_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
|
||||
|
@ -82,6 +110,9 @@ foreach(target aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
|
|||
list(APPEND RUNTIME_TARGETS "${target}")
|
||||
set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
|
||||
set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
|
||||
set(RUNTIMES_${target}_CMAKE_C_FLAGS "--target=${target}" CACHE STRING "")
|
||||
set(RUNTIMES_${target}_CMAKE_CXX_FLAGS "--target=${target}" CACHE STRING "")
|
||||
set(RUNTIMES_${target}_CMAKE_ASM_FLAGS "--target=${target}" CACHE STRING "")
|
||||
set(RUNTIMES_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE STRING "")
|
||||
set(RUNTIMES_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
|
||||
set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
|
||||
|
@ -100,9 +131,9 @@ foreach(target aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
|
|||
set(RUNTIMES_${target}_LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
|
||||
set(RUNTIMES_${target}_LIBCXX_ABI_VERSION 2 CACHE STRING "")
|
||||
set(RUNTIMES_${target}_LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
|
||||
set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
|
||||
set(RUNTIMES_${target}_SANITIZER_CXX_ABI "libc++" CACHE STRING "")
|
||||
set(RUNTIMES_${target}_SANITIZER_CXX_ABI_INTREE ON CACHE BOOL "")
|
||||
set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
|
||||
|
||||
# Use .build-id link.
|
||||
list(APPEND RUNTIME_BUILD_ID_LINK "${target}")
|
||||
|
@ -115,7 +146,7 @@ if(FUCHSIA_SDK)
|
|||
set(FUCHSIA_x86_64_NAME x64)
|
||||
set(FUCHSIA_riscv64_NAME riscv64)
|
||||
foreach(target i386;x86_64;aarch64;riscv64)
|
||||
set(FUCHSIA_${target}_COMPILER_FLAGS "-I${FUCHSIA_SDK}/pkg/fdio/include")
|
||||
set(FUCHSIA_${target}_COMPILER_FLAGS "--target=${target}-unknown-fuchsia -I${FUCHSIA_SDK}/pkg/fdio/include")
|
||||
set(FUCHSIA_${target}_LINKER_FLAGS "-L${FUCHSIA_SDK}/arch/${FUCHSIA_${target}_NAME}/lib")
|
||||
set(FUCHSIA_${target}_SYSROOT "${FUCHSIA_SDK}/arch/${FUCHSIA_${target}_NAME}/sysroot")
|
||||
endforeach()
|
||||
|
|
|
@ -5,7 +5,6 @@ set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64;RISCV CACHE STRING "")
|
|||
set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
|
||||
|
||||
set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;lld;llvm" CACHE STRING "")
|
||||
set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
|
||||
|
||||
set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
|
||||
set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR ON CACHE BOOL "")
|
||||
|
@ -16,6 +15,10 @@ set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
|
|||
set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
|
||||
set(LLVM_INCLUDE_GO_TESTS OFF CACHE BOOL "")
|
||||
|
||||
if(MSVC)
|
||||
set(LLVM_USE_CRT_RELEASE "MT" CACHE STRING "")
|
||||
endif()
|
||||
|
||||
set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
|
||||
if(NOT APPLE)
|
||||
set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
|
||||
|
@ -32,8 +35,10 @@ set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL "")
|
|||
|
||||
set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
|
||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "")
|
||||
if (APPLE)
|
||||
if(APPLE)
|
||||
set(MACOSX_DEPLOYMENT_TARGET 10.7 CACHE STRING "")
|
||||
elseif(MSVC)
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded" CACHE STRING "")
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
|
@ -52,8 +57,19 @@ set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
|
|||
set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
|
||||
set(LIBCXX_ABI_VERSION 2 CACHE STRING "")
|
||||
set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
|
||||
set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
|
||||
set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
|
||||
if(WIN32)
|
||||
set(LIBCXX_HAS_WIN32_THREAD_API ON CACHE BOOL "")
|
||||
set(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "")
|
||||
set(LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
|
||||
set(LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "")
|
||||
set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY OFF CACHE BOOL "")
|
||||
set(BUILTINS_CMAKE_ARGS -DCMAKE_SYSTEM_NAME=Windows CACHE STRING "")
|
||||
set(RUNTIMES_CMAKE_ARGS -DCMAKE_SYSTEM_NAME=Windows CACHE STRING "")
|
||||
set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE STRING "")
|
||||
else()
|
||||
set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
|
||||
set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
|
||||
endif()
|
||||
|
||||
if(BOOTSTRAP_CMAKE_SYSTEM_NAME)
|
||||
set(target "${BOOTSTRAP_CMAKE_CXX_COMPILER_TARGET}")
|
||||
|
|
Loading…
Reference in New Issue