Subject: Re: [boost] Using clang on Windows with mingw-64
From: Edward Diener (eldiener_at_[hidden])
Date: 2015-07-11 07:23:14


On 7/11/2015 5:34 AM, Paul A. Bristow wrote:
>
>
>> -----Original Message-----
>> From: Boost [mailto:boost-bounces_at_[hidden]] On Behalf Of Edward Diener
>> Sent: 10 July 2015 17:06
>> To: boost_at_[hidden]
>> Subject: [boost] Using clang on Windows with mingw-64
>>
>> This is just a heads up about testing with clang on Windows.
>>
>> The latest clang, when built from the latest source, is now capable on Windows of using the mingw-
>> 64/gcc RTL. Furthermore it is no longer necessary to have the mingw/mingw-64 implementation
>> hardcoded or linked from c:\mingw. With the latest clang the executable will look for a
>> mingw/mingw-64 implementation on the PATH, meaning that the if the implementation's 'bin'
>> directory is on the PATH clang will find it and use its RTL.
>>
>> The ability of the latest clang to use mingw-64 means that clang can use the latest gcc-5.1 RTL on
>> Windows. The mingw-64 implementation offers more up to date and better implementations of gcc
>> than mingw.
>>
>> There is one "gotcha" I have found with this setup on Windows when using clang on Windows with
>> gcc-4.9 on up. The gcc intrin.h implementation of
>> mingw-64 for gcc-4.9 on up has a bug where if the gcc version is less than 4.9 a compiler error
> will
>> occur. I have reported this to mingw-64 on their developer's mailing list but it has been ignored.
>>
>> Unfortunately clang still sets itself to gcc version 4.2.1. But a workaround solves the problem
> and that
>> workaround is that when using clang you define '__MINGW_FORCE_SYS_INTRINS', which causes the
>> bug in the mingw-64 intrin.h header file to not trigger.
>>
>> Previous versions of clang on Windows ( 3.4, 3.5, 3.6 ) of course still have the limitation of
> only
>> working with mingw and needing the mingw implementation hardcoded at c:\mingw. But at least with
>> the latest clang built from source this has changed as explained above.
>>
>> The Boost build clang toolset, which on Windows is really clang-linux, should continue to work
> with
>> this latest change of clang.
>
> Thanks for banging your head against this issue!
>
> I look forward to being able to use this in future, preferably without all your complicated
> workarounds.

You should be fine with:

using clang : : path/to/clang++.exe
  :
  <cxxflags>-D__MINGW_FORCE_SYS_INTRINS
  ;

in your user-config.jam. Just make sure that the mingw-64
implementation's 'bin' directory, which you want clang to use is, in
your PATH when you are invoking 'b2'. You can then just specify:

b2 toolset=clang etc.

and everything should work properly as far as Boost build is concerned
and clang using mingw-64 on Windows.

The more major irritation is dealing with the clang developers and the
mingw-64 developers on their respective mailing lists and realizing that
having clang/mingw-64/gcc working on Windows is not very important to
either. So that any issues you bring up regarding clang/mingw-64 on
either mailing list tends to be ignored and you end up trying to
communicate and no one is listening.