64-bit Tool set linker error on windows

hi all,

http://clang.llvm.org/get_started.html

I am followed the instruction given in above article for compiling 64-bit toolset on windows using Visual studio 15.

Command used for visual studio project generation:- cmake -Thost=x64 -G “Visual Studio 14” …\llvm

it successfully generates LLVM.sln.
Now, open LLVM.sln and change the platform target to “debug-x64”.
start building clang.exe project.

I am seeing below errors.

  1. x64\Debug\ItaniumDemangle.obj : fatal error LNK1112: module machine type ‘x64’ conflicts with target machine type ‘X86’
  2. x64\Debug\ClangASTNodesEmitter.obj : fatal error LNK1112: module machine type ‘x64’ conflicts with target machine type ‘X86’
  3. x64\Debug\AsmLexer.obj : fatal error LNK1112: module machine type ‘x64’ conflicts with target machine type ‘X86’

And many more such error.

so, what to know solution for such errors or am i missing any steps?

Thanks in advance.!!

If you had to change the default platform target to debug-x64, it sounds like CMake did not generate x64 project files. I believe our CMake scripts do not support generating projects that allow changing from x86 to x64.

I am only familiar with the old way to generate x64 project files, which is to use the “Visual Studio 14 Win64” generator or something like that. The documentation (https://cmake.org/cmake/help/v3.9/generator/Visual%20Studio%2015%202017.html) suggests that the new way is to pass “-DCMAKE_GENERATOR_PLATFORM=x64”.

Hi Reid,

First of all, Thank you very much for reply.

I tried your suggestions.

1. cmake -G “Visual Studio 14 Win64” …\llvm
2. cmake -DCMAKE_GENERATOR_PLATFORM=x64 -G “Visual Studio 14” …\llvm

In both the cases, it generates project successfully with default configuration to “Debug X64”.
But cmake Generates below warning.

CMake Warning at CMakeLists.txt:39 (message):
Visual Studio generators use the x86 host compiler by default, even for
64-bit targets. This can result in linker instability and out of memory
errors. To use the 64-bit host compiler, pass -Thost=x64 on the CMake
command line.

And it took cl.exe from below paths.

Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin**/x86_amd64**/cl.exe – works

Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe – works

Due to warning, I passed “-Thost=x64” arguments to cmake.

3. cmake -DCMAKE_GENERATOR_PLATFORM=x64 -Thost=x64 -G “Visual Studio 14” …\llvm

Now, No warning message.

And it took cl.exe from below paths.

Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe – works

Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe – works

clang.exe also got built successfully.

Thanks & Regards,
Apoorva