[PATCH] D141738: Add initial support for cross compile Windows runtimes under Linux when building Fuchsia clang toolchain
Haowei Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 23 14:10:01 PST 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG20bb7658f53b: [Fuchsia] Build windows runtimes using cross compilation on Linux (authored by haowei).
Changed prior to commit:
https://reviews.llvm.org/D141738?vs=490994&id=491508#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D141738/new/
https://reviews.llvm.org/D141738
Files:
clang/cmake/caches/Fuchsia-stage2.cmake
llvm/cmake/modules/LLVMExternalProjectUtils.cmake
Index: llvm/cmake/modules/LLVMExternalProjectUtils.cmake
===================================================================
--- llvm/cmake/modules/LLVMExternalProjectUtils.cmake
+++ llvm/cmake/modules/LLVMExternalProjectUtils.cmake
@@ -93,7 +93,7 @@
if(_cmake_system_name STREQUAL Darwin)
list(APPEND ARG_TOOLCHAIN_TOOLS llvm-libtool-darwin llvm-lipo)
elseif(is_msvc_target)
- list(APPEND ARG_TOOLCHAIN_TOOLS llvm-lib)
+ list(APPEND ARG_TOOLCHAIN_TOOLS llvm-lib llvm-rc llvm-mt)
else()
# TODO: These tools don't fully support Mach-O format yet.
list(APPEND ARG_TOOLCHAIN_TOOLS llvm-objcopy llvm-strip llvm-readelf)
@@ -213,6 +213,12 @@
if(llvm-readelf IN_LIST TOOLCHAIN_TOOLS)
list(APPEND compiler_args -DCMAKE_READELF=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-readelf${CMAKE_EXECUTABLE_SUFFIX})
endif()
+ if(llvm-mt IN_LIST TOOLCHAIN_TOOLS AND is_msvc_target)
+ list(APPEND compiler_args -DCMAKE_MT=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-mt${CMAKE_EXECUTABLE_SUFFIX})
+ endif()
+ if(llvm-rc IN_LIST TOOLCHAIN_TOOLS AND is_msvc_target)
+ list(APPEND compiler_args -DCMAKE_RC_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-rc${CMAKE_EXECUTABLE_SUFFIX})
+ endif()
list(APPEND ARG_DEPENDS ${TOOLCHAIN_TOOLS})
endif()
Index: clang/cmake/caches/Fuchsia-stage2.cmake
===================================================================
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -69,12 +69,44 @@
set(RUNTIMES_CMAKE_ARGS "-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13;-DCMAKE_OSX_ARCHITECTURES=arm64|x86_64" CACHE STRING "")
endif()
-if(WIN32)
+if(WIN32 OR LLVM_WINSYSROOT)
+ if((NOT WIN32) AND (NOT LLVM_VFSOVERLAY))
+ message(FATAL_ERROR "LLVM_VFSOVERLAY should be defined.")
+ endif()
set(target "x86_64-pc-windows-msvc")
+ if (LLVM_WINSYSROOT)
+ set(WINDOWS_COMPILER_FLAGS
+ -Xclang
+ -ivfsoverlay
+ -Xclang
+ ${LLVM_VFSOVERLAY}
+ # TODO: /winsysroot should be set by HandleLLVMOptions.cmake automatically
+ # but it current has a bug that prevents it from working under cross
+ # compilation. Set this flag manually for now.
+ /winsysroot
+ ${LLVM_WINSYSROOT})
+ string(REPLACE ";" " " WINDOWS_COMPILER_FLAGS "${WINDOWS_COMPILER_FLAGS}")
+ set(WINDOWS_LINK_FLAGS
+ /vfsoverlay:${LLVM_VFSOVERLAY}
+ # TODO: On Windows, linker is invoked by cmake instead of the clang-cl driver,
+ # so we have to manually set the libpath. We use clang-cl driver if we can
+ # and remove these libpath flags.
+ -libpath:"${LLVM_WINSYSROOT}/VC/Tools/MSVC/14.34.31933/lib/x64"
+ -libpath:"${LLVM_WINSYSROOT}/VC/Tools/MSVC/14.34.31933/atlmfc/lib/x64"
+ -libpath:"${LLVM_WINSYSROOT}/Windows Kits/10/Lib/10.0.19041.0/ucrt/x64"
+ -libpath:"${LLVM_WINSYSROOT}/Windows Kits/10/Lib/10.0.19041.0/um/x64")
+ string(REPLACE ";" " " WINDOWS_LINK_FLAGS "${WINDOWS_LINK_FLAGS}")
+ endif()
+
list(APPEND BUILTIN_TARGETS "${target}")
set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+ set(BUILTINS_${target}_CMAKE_C_FLAGS ${WINDOWS_COMPILER_FLAGS} CACHE STRING "")
+ set(BUILTINS_${target}_CMAKE_CXX_FLAGS ${WINDOWS_COMPILER_FLAGS} CACHE STRING "")
+ set(BUILTINS_${target}_CMAKE_EXE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE STRING "")
+ set(BUILTINS_${target}_CMAKE_SHARED_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE STRING "")
+ set(BUILTINS_${target}_CMAKE_MODULE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE STRING "")
list(APPEND RUNTIME_TARGETS "${target}")
set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
@@ -84,6 +116,11 @@
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 "")
+ set(RUNTIMES_${target}_CMAKE_C_FLAGS ${WINDOWS_COMPILER_FLAGS} CACHE STRING "")
+ set(RUNTIMES_${target}_CMAKE_CXX_FLAGS ${WINDOWS_COMPILER_FLAGS} CACHE STRING "")
+ set(RUNTIMES_${target}_CMAKE_EXE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE STRING "")
+ set(RUNTIMES_${target}_CMAKE_SHARED_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE STRING "")
+ set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE STRING "")
endif()
foreach(target aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unknown-linux-gnu;x86_64-unknown-linux-gnu)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141738.491508.patch
Type: text/x-patch
Size: 4580 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230123/7704063b/attachment.bin>
More information about the cfe-commits
mailing list