[PATCH] D41158: [cmake] Support host architectures other than x64
Shoaib Meenai via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 13 14:23:07 PST 2017
smeenai updated this revision to Diff 126845.
smeenai added a comment.
Support alternate architecture spellings
https://reviews.llvm.org/D41158
Files:
cmake/platforms/WinMsvc.cmake
Index: cmake/platforms/WinMsvc.cmake
===================================================================
--- cmake/platforms/WinMsvc.cmake
+++ cmake/platforms/WinMsvc.cmake
@@ -5,6 +5,7 @@
# cmake -G Ninja
# -DCMAKE_TOOLCHAIN_FILE=/path/to/this/file
# -DLLVM_NATIVE_TOOLCHAIN=/path/to/llvm/installation
+# -DHOST_ARCH=[aarch64|arm64|armv7|arm|i686|x86|x86_64|x64]
# -DMSVC_BASE=/path/to/MSVC/system/libraries/and/includes
# -DWINSDK_BASE=/path/to/windows-sdk
# -DWINSDK_VER=windows sdk version folder name
@@ -15,6 +16,9 @@
# copy of clang-cl, clang, clang++, and lld-link, as well as a lib directory
# containing clang's system resource directory.
#
+# HOST_ARCH:
+# The architecture to build for.
+#
# MSVC_BASE:
# *Absolute path* to the folder containing MSVC headers and system libraries.
# The layout of the folder matches that which is intalled by MSVC 2017 on
@@ -106,16 +110,35 @@
endif()
endfunction()
-# FIXME: We should support target architectures other than x64
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_VERSION 10.0)
set(CMAKE_SYSTEM_PROCESSOR AMD64)
init_user_prop(LLVM_NATIVE_TOOLCHAIN)
+init_user_prop(HOST_ARCH)
init_user_prop(MSVC_BASE)
init_user_prop(WINSDK_BASE)
init_user_prop(WINSDK_VER)
+if(NOT HOST_ARCH)
+ set(HOST_ARCH x86_64)
+endif()
+if(HOST_ARCH STREQUAL "aarch64" OR HOST_ARCH STREQUAL "arm64")
+ set(TRIPLE_ARCH "aarch64")
+ set(WINSDK_ARCH "arm64")
+elseif(HOST_ARCH STREQUAL "armv7" OR HOST_ARCH STREQUAL "arm")
+ set(TRIPLE_ARCH "armv7")
+ set(WINSDK_ARCH "arm")
+elseif(HOST_ARCH STREQUAL "i686" OR HOST_ARCH STREQUAL "x86")
+ set(TRIPLE_ARCH "i686")
+ set(WINSDK_ARCH "x86")
+elseif(HOST_ARCH STREQUAL "x86_64" OR HOST_ARCH STREQUAL "x64")
+ set(TRIPLE_ARCH "x86_64")
+ set(WINSDK_ARCH "x64")
+else()
+ message(SEND_ERROR "Unknown host architecture ${HOST_ARCH}. Must be aarch64 (or arm64), armv7 (or arm), i686 (or x86), or x86_64 (or x64).")
+endif()
+
set(MSVC_INCLUDE "${MSVC_BASE}/include")
set(MSVC_LIB "${MSVC_BASE}/lib")
set(WINSDK_INCLUDE "${WINSDK_BASE}/Include/${WINSDK_VER}")
@@ -164,6 +187,7 @@
set(COMPILE_FLAGS
-D_CRT_SECURE_NO_WARNINGS
+ -Xclang -triple -Xclang ${TRIPLE_ARCH}-pc-windows-msvc19.11.0
-fms-compatibility-version=19.11
-imsvc "${MSVC_INCLUDE}"
-imsvc "${WINSDK_INCLUDE}/ucrt"
@@ -189,10 +213,9 @@
# Prevent CMake from attempting to invoke mt.exe. It only recognizes the slashed form and not the dashed form.
/manifest:no
- # FIXME: We should support target architectures other than x64.
- -libpath:"${MSVC_LIB}/x64"
- -libpath:"${WINSDK_LIB}/ucrt/x64"
- -libpath:"${WINSDK_LIB}/um/x64")
+ -libpath:"${MSVC_LIB}/${WINSDK_ARCH}"
+ -libpath:"${WINSDK_LIB}/ucrt/${WINSDK_ARCH}"
+ -libpath:"${WINSDK_LIB}/um/${WINSDK_ARCH}")
string(REPLACE ";" " " LINK_FLAGS "${LINK_FLAGS}")
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41158.126845.patch
Type: text/x-patch
Size: 2880 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171213/352d3acf/attachment.bin>
More information about the llvm-commits
mailing list