Clang for Windows and Boost

Thanks to the help I received I have been able to build clang for Windows both using MingW and VC++ 10. Are either, or both, of these builds stable, in that they can be used for building Boost and other 3rd party libraries ?

If so, I am going to try to get some of the Boost Build experts to supply a toolset for clang under Windows so it can be used to build and test Boost libraries under Windows. Currently the clang toolset support in Boost works only under Linux as I understand it.

Hi Edward,

I had problems with using move and clang on linux:

  http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-February/013216.html

I also tried a workaround using the libcxx; however, that also had
problems:

  http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-February/013246.html

Hence, I don't think clang is usable on linux yet.

-Larry

I should amend that last statement because, in this newsgroup,
Jeffrey Yasskin announced a patch for the gnu libstdc++ lib:

  http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-February/013310.html

which avoided some linux problems with clang. However, I've not
tried the patch.

-Larry

This is horribly misleading. Clang is a perfectly reasonable C++98/03 compiler on Linux.

The issues you ran into concern C++0x, where the world is much messier. The C++0x situation on Linux is admittedly frustrating because of library issues:
  - libstdc++ <= 4.4 doesn't work with a C++0x compiler that implements the current WP's formulation of rvalue references. Jeffrey Yasskin provided a patch for this.
  - libc++ hasn't been fully ported to Linux
  - libstdc++ >= 4.5 has an issue with generalized initializer lists; I worked around that problem in Clang, but I don't know if this is the last problem with these libraries or just the first.

  - Doug

I am not concerned about Linux.

Can clang built with MingW/MSYS ( or less probably VC++10 ) compile Boost under Windows ? If so, can we get a toolset in Boost Build to use clang under Windows so Boost libraries can be tested in Windows using clang ?

[snip]

Hence, I don't think clang is usable on linux yet.

This is horribly misleading. Clang is a perfectly reasonable C++98/03 compiler on Linux.

The issues you ran into concern C++0x, where the world is much messier. The C++0x situation on Linux is admittedly frustrating because of library issues:

Yes, you're right. I was too focused on C++0x.
Sorry for not being clear about how focused my
problems were using clang on linux.

-Larry

AMDG

Thanks to the help I received I have been able to build clang for
Windows both using MingW and VC++ 10. Are either, or both, of these
builds stable, in that they can be used for building Boost and other 3rd
party libraries ?

If so, I am going to try to get some of the Boost Build experts to
supply a toolset for clang under Windows so it can be used to build and
test Boost libraries under Windows. Currently the clang toolset support
in Boost works only under Linux as I understand it.

Hi Edward,

I had problems with using move and clang on linux:

http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-February/013216.html

I also tried a workaround using the libcxx; however, that also had
problems:

http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-February/013246.html

Hence, I don't think clang is usable on linux yet.

This is horribly misleading. Clang is a perfectly reasonable C++98/03 compiler on Linux.

The issues you ran into concern C++0x, where the world is much messier. The C++0x situation on Linux is admittedly frustrating because of library issues:
  - libstdc++<= 4.4 doesn't work with a C++0x compiler that implements the current WP's formulation of rvalue references. Jeffrey Yasskin provided a patch for this.
  - libc++ hasn't been fully ported to Linux
  - libstdc++>= 4.5 has an issue with generalized initializer lists; I worked around that problem in Clang, but I don't know if this is the last problem with these libraries or just the first.

I am not concerned about Linux.

Can clang built with MingW/MSYS ( or less probably VC++10 ) compile
Boost under Windows ?

I would expect it to be possible with MinGW/MSYS, but not with VC++10. The basic problem is the C++ library headers: MinGW/MSYS uses libstdc++, which Clang can handle; VC++ has a lot of non-standard C++ in its headers that Clang does not currently handle. [*]

If so, can we get a toolset in Boost Build to use
clang under Windows so Boost libraries can be tested in Windows using
clang ?

I think that would be great. I don't know if we have that expertise here in the Clang side of the world... there was work on Clang support in Boost.Build for Linux; perhaps that can be ported over to create a Boost.Build description for Clang on MinGW/MSYS.

  - Doug

[*] Francois Pichet is making exciting progress in this area, but we're not to the point where it will be generally usable for C++ code.

What about clang for MingW/MSYS ? Is there not a usable standard library there ? It seems like it should work very much like gcc with MingW under Windows, which I have used successfully to test my libraries.

Thanks to the help I received I have been able to build clang for
Windows both using MingW and VC++ 10. Are either, or both, of these
builds stable, in that they can be used for building Boost and other 3rd
party libraries ?

If so, I am going to try to get some of the Boost Build experts to
supply a toolset for clang under Windows so it can be used to build and
test Boost libraries under Windows. Currently the clang toolset support
in Boost works only under Linux as I understand it.

Hi Edward,

I had problems with using move and clang on linux:

  http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-February/013216.html

I also tried a workaround using the libcxx; however, that also had
problems:

  http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-February/013246.html

Hence, I don't think clang is usable on linux yet.

This is horribly misleading. Clang is a perfectly reasonable C++98/03 compiler on Linux.

The issues you ran into concern C++0x, where the world is much messier. The C++0x situation on Linux is admittedly frustrating because of library issues:
  - libstdc++<= 4.4 doesn't work with a C++0x compiler that implements the current WP's formulation of rvalue references. Jeffrey Yasskin provided a patch for this.
  - libc++ hasn't been fully ported to Linux
  - libstdc++>= 4.5 has an issue with generalized initializer lists; I worked around that problem in Clang, but I don't know if this is the last problem with these libraries or just the first.

I am not concerned about Linux.

Can clang built with MingW/MSYS ( or less probably VC++10 ) compile
Boost under Windows ?

I would expect it to be possible with MinGW/MSYS, but not with VC++10. The basic problem is the C++ library headers: MinGW/MSYS uses libstdc++, which Clang can handle; VC++ has a lot of non-standard C++ in its headers that Clang does not currently handle. [*]

Then lets forget about clang with VC++10 headers. What about clang with MingW ? It should be very similar to gcc with MingW, but provide clang testing wjhen gcc does not work.

If so, can we get a toolset in Boost Build to use
clang under Windows so Boost libraries can be tested in Windows using
clang ?

I think that would be great. I don't know if we have that expertise here in the Clang side of the world... there was work on Clang support in Boost.Build for Linux; perhaps that can be ported over to create a Boost.Build description for Clang on MinGW/MSYS.

I hope so. It would be great to use clang, along with gcc and msvc, to test Boost libaries on Windows. I was impressed that clang worked, whereas gcc and VC++ did not, on that code I posted in the Boost devel list and you verified with clang that the code is valid.

I admit I could go to a Linux distro on my multi-boot computer and try to build and use clang there but I like Windows much better, and avoid Linux development whenever I can. I always run into headaches in Linux, but each to their own.

Sorry, I was unclear: MinGW uses libstdc++ (GCC’s C++ standard library), which Clang should work with.

  • Doug

Please note that mingw uses MSVCRT-compatible C headers and libstdc++.

FYI I have not tried building and testing boost.

...Takumi

Please note that mingw uses MSVCRT-compatible C headers and libstdc++.

So are you saying that clang can not work with those same header files and libstdC++ ?

If that is the case then clang on Windows can not be run except if no headers are required.

I was able to just test compilation code using clang as long as no headers were involved. But that is a pretty limited use of clang under Windows.

FYI I have not tried building and testing boost.

Using gcc and MingW it is possible to use gcc under Windows with Boost successfully. I tried dropping the output of the clang build, which I did in a separate directory structure as clang recommends, into my mingW structure on top of the gcc 4.5.2 files there and then build my Boost library using the clang toolset in Boost, which is setup for clang in Linux, but it did not work with many errors.

Edward, thank you to inform me something!

What do you mean that clang on mingw lacks support ?

Edward Diener <eldlistmailingz@tropicsoft.com>
writes:

In theory, clang should build boost with mingw's headers and mingw's libstdc++,
though, I am dubious clang on mingw lacks eh support.

What do you mean that clang on mingw lacks support ?

"lacks *eh* support".

eh = exception handling.

I don't work with clang internally so I do not know why this would be the case. Is this a current limitation of clang on all platforms, or just with MingW under Windows ?

Trying out clang with the Boost clang toolset, which is setup for Linux, I did not get the impression that the errors had anything to do with exception support. But I do not think the Boost Build clang toolset for Linux is setup correctly to work with MingW under Windows in the first place given that the errors were so immediate.

I truly think that a clang toolset for MingW on Windows needs to be created by a Boost Build developer based on the gcc MingW toolset, with whatever changes clang needs, but I know very little about doing this for Boost Build or about clang itself, so I hope someone else takes up the challenge. I know that Steve Watanable mentioned he might do it and I also got a response from Rene Rivera on the Boost Build mailing list. I would understand if it is not possible to get clang with MingW to work as a replacement for gcc with MingW, but I would still be curious to know why. I do realize that the goal of clang is to be ideally 100% conformant with the C++ standard whereas gcc may settle for less and a more practical implementation which lets it work with MingW under Windows.

Out of curiosity, what's the mingw exception model?

John.

John McCall <rjmccall@apple.com> writes:

What do you mean that clang on mingw lacks support ?

"lacks *eh* support".

eh = exception handling.

Out of curiosity, what's the mingw exception model?

Last time I checked, official MinGW was configured with setjump/longjump
while other distributions used DWARF2. The latter offers better
performance but fails to work when it has to unwind a stack frame that
belongs to a Windows function (that's the case when you throw an
exception from a callback.)

I am stilling searching for the answer whether or not clang, built with MingW/MSYS under Windows, is currently a workable version under Windows with the header files and libraries MingW and gcc supplies. Do you or anybody know this ? Or should I still be waiting on future clang development for this to become a reality ?