Boost logo

Boost :

Subject: Re: [boost] Compiling with Clang 3.7.0 from windows
From: Edward Diener (eldiener_at_[hidden])
Date: 2015-09-04 16:22:10


On 9/4/2015 7:15 AM, Paul A. Bristow wrote:
>> -----Original Message-----
>> From: Boost [mailto:boost-bounces_at_[hidden]] On Behalf Of Edward Diener
>> Sent: 03 September 2015 16:23
>> To: boost_at_[hidden]
>> Subject: Re: [boost] Compiling with Clang 3.7.0 from windows
>>
>> On 9/3/2015 10:02 AM, Paul A. Bristow wrote:
>>> I've downloaded the shiny new Clang 3.7 and added this to my user-config
>>
>> This is my experience with clang built from source:
>>
>> If you are running clang as a 64-bit compiler you need to "use" a 64-bit version of mingw-64, and
> not
>> mingw which is only 32-bits. By "use" I mean one of two things. Either the 'bin' directory of the
> 64-bit
>> version should be prepended to your Windows PATH when invoking clang++ or you use the '--
>> sysroot=some_mingw' option on the command line when invoking
>> clang++, where 'some_mingw' is the path to the 64-bit mingw
>> implementation. I have not used the second method but have been told it should work.
>>
>> What I do, in a batch file before invoking clang++, is to prepend to the Windows PATH the clang++
> bin
>> directory followed by the bin directory of the mingw-64 implementation I want clang to use. Then
>> when clang++ is invoked it finds everything properly. If you are compiling clang++ for 32-bit code
> you
>> need to "use" a 32-bit version of mingw(-64)/gcc and if you are compiling clang++ for 64-bit code
> you
>> need to "use" a 64-bit version of mingw-64/gcc.
>>
>> As far as pre-built versions of clang I have used clang 3.6.2, 3.5.2, and clang 3.4.1. None of
> these
>> versions could "use" mingw-64 but only mingw. This means that none of these versions could be used
>> to compile 64-bit code since mingw only supports 32-bit code. I have not tried the new pre-build
> clang
>> 3.7 yet, which supposedly is capable of using
>> mingw-64 ( I know the latest clang built from source can "use" mingw-64 but I am not sure if this
>> capability got into the 3.7 release ).
>
> I'm a bit wary of working on a solution that requires a bat file to manipulate the PATH.

It may be possible to use the --sysroot option with clang++ to point to
the path of the underlying mingw(-64)/gcc implementation being used so
that you don't have to manipulate the PATH in a batch file. But I have
never used that option and like just about everything else with clang it
is barely documented. It may also be possible that the clang 'bin'
directory does not need to be in the PATH to compile/link with clang.
This would be as opposed to mingw(-64)/gcc where gcc can not
compile/link if it's 'bin' directory is not in the PATH.

>
> (It is also potentially inconvenient because it complicates other b2 code?)
>
> Surely Boost.Build user-config.jam should be able to do this? If only we knew what Clang needs?
>
> I've downloaded from mingw64
>
> C:\Program Files\mingw-w64\x86_64-5.1.0-win32-seh-rt_v4-rev0\mingw64\bin
>
> (Assuming that for Windows the SEH option is best? - but user-config.jam should also cater for Linux
> hosts? So there should be different setups for Windows?)
>
> I've also got this
>
> C:\MinGW\mingw32\bin
>
> But I'm not sure if I need this at all.

In my experience you shouldn't need c:\mingw\anything... with clang 3.7+
on up on Windows.

>
> I'm completely confused about exactly what the Clang compiler is using mingw for.

It uses he mingw/gcc header files, static libs, import libs and DLLs.
Essentially it is using the mingw/gcc RTL, which includes support for
the C++ standard library and the Windows API.

>
> Is it the loader ld.exe?

Yes.

>
> Is it libstdc++?

Yes, on Windows. On Linux I believe clang uses its own libc++. Evidently
the porting of libc++ to Windows is a work in progress.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk