[cfe-dev] Question on usage of clang on windows with cmake and ninja

Reid Kleckner via cfe-dev cfe-dev at lists.llvm.org
Tue Feb 9 09:20:04 PST 2016


The version of clang you have is configured to target the MSVC runtime, so
I mistakenly assumed that's what you wanted. :)

If you want to use mingw, you can either pass
--target=i686-w64-windows-gnu to every compile step, or reconfigure and
rebuild clang with -DLLVM_DEFAULT_TARGET_TRIPLE=i686-w64-windows-gnu.

I think passing '-DCMAKE_C_FLAGS=--target=i686-w64-windows-gnu
-DCMAKE_CXX_FLAGS=--target=i686-w64-windows-gnu' to the second stage build
is enough, but I could be wrong, I don't have experience building mingw64
clang.

On Tue, Feb 9, 2016 at 2:47 AM, Victor Leschuk <vleschuk at gmail.com> wrote:

> Hello Reid,
>
> thanks a lot for your answer, it helped. As far as I understood from the
> documentation: one needs to use clang-cl if he wants to use visual studio
> runtime. The clang.exe and clang++.exe binaries are intended to be used
> only with mingw runtime (and libc++ is not yet available for windows). Am I
> correct?
>
>
> On 02/09/2016 01:15 AM, Reid Kleckner wrote:
>
> Try clang-cl instead, like this:
> $ cmake .. -GNinja -DCMAKE_C_COMPILER=clang-cl
> -DCMAKE_CXX_COMPILER=clang-cl
>
> If you use the other command line syntax, it looks like CMake has
> mingw-ish assumptions about what linker flags are valid.
>
> On Sun, Feb 7, 2016 at 3:49 AM, Victor Leschuk via cfe-dev <
> <cfe-dev at lists.llvm.org>cfe-dev at lists.llvm.org> wrote:
>
>> Hello all,
>>
>> I am currently trying to use clang compiler on Windows 7 (64bit), I have
>> built LLVM and clang from sources (master branch) using VS 2015.
>>
>> Now I am trying to rebuild the LLVM and clang using clang itself.
>>
>> So I am stuck setting correct configuration for cmake.
>>
>> I am running the following command:
>>
>>  $ cmake .. -G "Ninja" -DCMAKE_C_COMPILER=clang
>> -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER_ID=Clang
>> -DCMAKE_CXX_COMPILER_ID=Clang
>>
>> And after that the first test fails with linkage error:
>>
>>   CMakeFiles\cmTC_8f103.dir\testCCompiler.c.obj -o cmTC_8f103.exe
>>   -Wl,--out-implib,libcmTC_8f103.dll.a
>>   -Wl,--major-image-version,0,--minor-image-version,0 && cd ."
>>
>>   LINK : warning LNK4044: unrecognized option '/-out-implib'; ignored
>>
>>   LINK : warning LNK4044: unrecognized option '/-major-image-version';
>>   ignored
>>
>>   LINK : warning LNK4044: unrecognized option '/-minor-image-version';
>>   ignored
>>
>>   LINK : fatal error LNK1181: cannot open input file 'libcmTC_8f103.dll.a'
>>
>>   clang.exe: error: linker command failed with exit code 1181 (use -v to
>> see
>>
>> I have found similar bug:
>>
>> https://llvm.org/bugs/show_bug.cgi?id=20868
>>
>> However it is for WinXP and is marked as already fixed.
>>
>> Also here is similar unsolved discussion SO:
>> <http://stackoverflow.com/questions/22585874/building-c-project-on-windows-with-cmake-clang-and-ninja>
>> http://stackoverflow.com/questions/22585874/building-c-project-on-windows-with-cmake-clang-and-ninja
>>
>> Here is clang version which I am trying to use:
>>
>> $ clang --version
>> clang version 3.9.0
>> Target: i686-pc-windows-msvc
>> Thread model: posix
>> InstalledDir: C:\Users\del\work\llvm\bin
>>
>> It would be great is somebody could point me on what am I doing wrong?
>>
>> Thanks in advance!
>>
>> --
>> Victor
>>
>>
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160209/40adf59d/attachment.html>


More information about the cfe-dev mailing list