[CMake] Problem using VS-compiled Clang as a C/C++ compiler.

Anton Yartsev anton.yartsev at gmail.com
Wed Mar 9 18:48:47 EST 2016


Oops, sorry, confused with different variants.

I've tried
$SET CC=D:\LLVM-3.7.1\bin\clang-cl.exe
$SET CXX=D:\LLVM-3.7.1\bin\clang-cl.exe
$cmake -G "Ninja" ..

Compilation succeeded, linkage has ended up with "clang-cl.exe: error: 
unable to execute command: program not executable".
The same result with clang-cl.exe renamed to cl.exe.

------------------------------------------- output:
-- The C compiler identification is Clang 3.7.1
-- The CXX compiler identification is Clang 3.7.1
-- Check for working C compiler using: Ninja
-- Check for working C compiler using: Ninja -- broken
CMake Error at C:/Program 
Files/CMake/share/cmake-3.5/Modules/CMakeTestCCompiler.cmake:61 (message):
   The C compiler "D:/LLVM-3.7.1/bin/clang-cl.exe" is not able to compile a
   simple test program.

   It fails with the following output:

    Change Dir: 
D:/-Work-/llvm-3.7.1.src/-CLANG-/ProjectDir/CMakeFiles/CMakeTmp
   Run Build Command:"C:/PROGRA~1/ninja/ninja.exe" "cmTC_b1a57"

   [1/2] Building C object CMakeFiles\cmTC_b1a57.dir\testCCompiler.c.obj

   [2/2] Linking C executable cmTC_b1a57.exe

   FAILED: cmd.exe /C "cd .  && "C:\Program Files\CMake\bin\cmake.exe" -E
   vs_link_exe --intdir=CMakeFiles\cmTC_b1a57.dir --manifests --
   CMAKE_LINKER-NOTFOUND /nologo 
CMakeFiles\cmTC_b1a57.dir\testCCompiler.c.obj
   /out:cmTC_b1a57.exe /implib:cmTC_b1a57.lib /pdb:cmTC_b1a57.pdb 
/version:0.0
   /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib 
user32.lib
   gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
   comdlg32.lib advapi32.lib && cd ."

   RC Pass 1 failed to run.

   ninja: build stopped: subcommand failed.

   CMake will not be able to correctly generate this project.

------------------------------------------------ CMakeError.log
Compiling the C compiler identification source file "CMakeCCompilerId.c" 
failed.
Compiler: D:/LLVM-3.7.1/bin/clang-cl.exe
Build flags:
Id flags:

The output was:
1
clang-cl.exe: error: unable to execute command: program not executable
clang-cl.exe: error: linker command failed with exit code 1 (use -v to 
see invocation)


Compiling the CXX compiler identification source file 
"CMakeCXXCompilerId.cpp" failed.
Compiler: D:/LLVM-3.7.1/bin/clang-cl.exe
Build flags:
Id flags:

The output was:
1
clang-cl.exe: error: unable to execute command: program not executable
clang-cl.exe: error: linker command failed with exit code 1 (use -v to 
see invocation)


Determining if the C compiler works failed with the following output:
Change Dir: D:/-Work-/llvm-3.7.1.src/-CLANG-/ProjectDir/CMakeFiles/CMakeTmp

Run Build Command:"C:/PROGRA~1/ninja/ninja.exe" "cmTC_2dff3"
[1/2] Building C object CMakeFiles\cmTC_2dff3.dir\testCCompiler.c.obj
[2/2] Linking C executable cmTC_2dff3.exe
FAILED: cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E 
vs_link_exe --intdir=CMakeFiles\cmTC_2dff3.dir --manifests  -- 
C:\PROGRA~1\MICROS~2.0\VC\bin\link.exe /nologo 
CMakeFiles\cmTC_2dff3.dir\testCCompiler.c.obj  /out:cmTC_2dff3.exe 
/implib:cmTC_2dff3.lib /pdb:cmTC_2dff3.pdb /version:0.0 /machine:x64  
/debug /INCREMENTAL /subsystem:console  kernel32.lib user32.lib 
gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib 
comdlg32.lib advapi32.lib && cd ."
RC Pass 1 failed to run.


ninja: build stopped: subcommand failed.


>> ------ check which cl.exe is used:
>> $which cl
>> D:\CL\cl.EXE
>>
>> ------ trying to build:
>> $cmake -G "Ninja" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang ..
> If your goal is use your renamed clang-cl (cl.exe) then why are you
> telling CMake to use to use clang.exe ?
>
> You can clearly see if your error message that ``clang.exe`` is being invoked.
>
> Shouldn't your command line be something like this?
>
> CC=cl.exe CXX=cl.exe cmake -G "Ninja" ..
>
> If you want to be really specific you could do
>
> CC=D:\LLVM-3.7.1\bin\clang-cl.exe CXX=D:\LLVM-3.7.1\bin\clang-cl.exe
> cmake -G "Ninja" ..


-- 
Anton



More information about the CMake mailing list