[LLVMdev] Host target triple on Windows

Hans Wennborg hans at chromium.org
Wed Jul 30 10:22:34 PDT 2014


On Tue, Jul 29, 2014 at 5:38 PM, Zachary Turner <zturner at google.com> wrote:
> I'm trying to figure out how to get, from CMake, the architecture of the
> platform that I'm compiling LLVM for.  If I'm building LLVM on x86, I want
> x86.  On x64 I want x86_64.  On arm arm.  etc.
>
> The best I can figure out so far is that I should use LLVM_HOST_TRIPLE, and
> extract the first component of this.  At least if my understanding is
> correct, I should have the following behavior:
>
> Compiling using 32-bit toolchain on Windows: LLVM_HOST_TRIPLE =
> i686-pc-win32
> Compiling using 64-bit toolchain on Windows: LLVM_HOST_TRIPLE =
> x86_64-pc-win32
>
> This doesn't currently seem to work.  See, for example, the following output
> from when I run CMake twice from the command line, once with an x86
> toolchain and once with an x64 toolchain:
>
> D:\src\llvm\build\ninja>"c:\Program Files (x86)\Microsoft Visual Studio
> 12.0\VC\vcvarsall.bat" x86
>
> D:\src\llvm\build\ninja>where cl
> C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cl.exe
> C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64\cl.exe
>
> D:\src\llvm\build\ninja>cmake ..\..
> -- Target triple: i686-pc-win32
> -- Native target architecture is X86
>
> D:\src\llvm\build\ninja>"c:\Program Files (x86)\Microsoft Visual Studio
> 12.0\VC\vcvarsall.bat" x86_amd64
>
> D:\src\llvm\build\ninja>where cl
> C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64\cl.exe
> C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cl.exe
>
> D:\src\llvm\build\ninja>cmake ..\..
> -- Target triple: i686-pc-win32
> -- Native target architecture is X86

Could this be due to CMake caching (and not updating that cache) the
compiler it uses? If I run cmake in an empty directory, it seems to
get the Target triple right:

D:\src>mkdir build.x86 && cd build.x86
D:\src\build.x86>"c:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\vcvarsall.bat" x86
D:\src\build.x86>cmake -GNinja ..\llvm
[...]
-- Target triple: i686-pc-win32
-- Native target architecture is X86

D:\src\build.x86>cd .. && mkdir build.amd64 && cd build.amd64
D:\src\build.amd64>"c:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\vcvarsall.bat" x86_amd64
D:\src\build.amd64>cmake -GNinja ..\llvm
[...]
-- Target triple: x86_64-pc-win32
-- Native target architecture is X86



More information about the llvm-dev mailing list