[PATCH] D41155: [cmake] Determine MSVC host triple correctly when cross-compiling

Shoaib Meenai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 13 00:38:42 PST 2017


smeenai created this revision.
smeenai added reviewers: compnerd, rnk, zturner.
Herald added subscribers: kristof.beyls, mgorny, aemerson.

CMAKE_CL_64 will never be set when cross-compiling with clang-cl, since
CMake relies on an actual VS environment in order to determine it.
Instead, use the size of a void pointer to determine the bit width of
the host compiler (and therefore the host triple), which works for both
native and cross compilation.

Note that, with the impending advent of Windows on AArch64, assuming
that a 64-bit host == x86_64 isn't correct either, but that's something
to be addressed in a follow-up.


https://reviews.llvm.org/D41155

Files:
  cmake/modules/GetHostTriple.cmake


Index: cmake/modules/GetHostTriple.cmake
===================================================================
--- cmake/modules/GetHostTriple.cmake
+++ cmake/modules/GetHostTriple.cmake
@@ -3,7 +3,7 @@
 
 function( get_host_triple var )
   if( MSVC )
-    if( CMAKE_CL_64 )
+    if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
       set( value "x86_64-pc-win32" )
     else()
       set( value "i686-pc-win32" )


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41155.126675.patch
Type: text/x-patch
Size: 398 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171213/c6c384c2/attachment.bin>


More information about the llvm-commits mailing list