Toolset for clang in Windows under Boost

I was able to build clang successfully under Windows. It is in the PATH. What is the bjam command for running a jamfile and using clang as my compiler ? I tried 'bjam toolset=clang' but that returned many errors, so it must be something different.

I don't believe that anyone has written a Clang toolset for bjam that works on Windows. Linux and Mac OS do work.

You do provide a means of building clang on Windows through the VS Studio solution. There is also a clang.hpp in boost.config which suggests that it should support any OS.

Is there any functional difference between clang on Windows and clang on Linux/MacOS ? What would it take to provide a toolset for clang on Windows that can compile Boost libraries ?

You do provide a means of building clang on Windows through the VS
Studio solution.

yes see: http://clang.llvm.org/get_started.html

Is there any functional difference between clang on Windows and clang on
Linux/MacOS ? What would it take to provide a toolset for clang on
Windows that can compile Boost libraries ?

clang can compile boost. On windows, it should theoretically work but
you may need to tweak the compiler command line options to make it
work. For example, if you compile clang with VS, clang will search the
msvc include directories to find #include path. But clang cannot
currently parse the msvc header files.

If you want to build boost on Windows using clang, I suggest you build
clang using MinGW.

You do provide a means of building clang on Windows through the VS
Studio solution.

yes see: http://clang.llvm.org/get_started.html

Is there any functional difference between clang on Windows and clang on
Linux/MacOS ? What would it take to provide a toolset for clang on
Windows that can compile Boost libraries ?

clang can compile boost. On windows, it should theoretically work but
you may need to tweak the compiler command line options to make it
work. For example, if you compile clang with VS, clang will search the
msvc include directories to find #include path.

I do not understand this. I am not talking about building clang, but using clang to compile Boost. What does VS have to do with that ?

But clang cannot
currently parse the msvc header files.

Are you saying that clang needs the msvc header files under Windows ?

If you want to build boost on Windows using clang, I suggest you build
clang using MinGW.

It sounds like you are saying that when clang is built with VS it automatically uses the msvc header files awhen it is used to compile source files but if it is built with MingW it automatically uses the MingW header files when it is used to compile source files. Can that really be so ? I would have assumed that however it is built it would use its own header files and standard library.

As far as the Windows SDK header files I would guess that some Boost libraries do use them, but I do not know why they would not be able to be used by clang.

clang can compile boost. On windows, it should theoretically work but
you may need to tweak the compiler command line options to make it
work. For example, if you compile clang with VS, clang will search the
msvc include directories to find #include path.

I do not understand this. I am not talking about building clang, but
using clang to compile Boost. What does VS have to do with that ?

Because you asked about building clang using Visual Studio in your
first question. So I thought you wanted to build clang using visual
studio and then using the resulting clang to build boost. It is not
going to work because when you build clang using visual studio the
default configuration is to search in the msvc include directories for
standard headers. clang cannot parse these headers.

But clang cannot
currently parse the msvc header files.

Are you saying that clang needs the msvc header files under Windows ?

Not, if you build using MinGW.
If you build with MSVC clang will try to include from msvc by default.
To get around that use option -nostdinc++ and -nostdinc.

It sounds like you are saying that when clang is built with VS it
automatically uses the msvc header files awhen it is used to compile
source files but if it is built with MingW it automatically uses the
MingW header files when it is used to compile source files. Can that
really be so ? I would have assumed that however it is built it would
use its own header files and standard library.

That's the way clang works as I understand. clang doesn't currently
ship with its own complete standard library. One is currently in
development ( libc++) but doesn't work on windows.

As far as the Windows SDK header files I would guess that some Boost
libraries do use them, but I do not know why they would not be able to
be used by clang.

clang cannot currently compile the Windows SDK as provided by Microsoft.
clang can compile the Windows headers shipped with MinGW.

Anyway that's the way I understand it... I am not a clang expert yet.
I am still learning about it.

It sounds like you are saying that when clang is built with VS it
automatically uses the msvc header files awhen it is used to compile
source files but if it is built with MingW it automatically uses the
MingW header files when it is used to compile source files. Can that
really be so ? I would have assumed that however it is built it would
use its own header files and standard library.

Clang does not have its own headers or standard library. It's only a compiler. The only headers it has are some very compiler-specific things like stdint.h and *mmintrin.h.

As far as the Windows SDK header files I would guess that some Boost
libraries do use them, but I do not know why they would not be able to
be used by clang.

Because the Windows SDK contains a lot of code that depends on Microsoft's language extensions.

Sebastian

clang can compile boost. On windows, it should theoretically work but
you may need to tweak the compiler command line options to make it
work. For example, if you compile clang with VS, clang will search the
msvc include directories to find #include path.

I do not understand this. I am not talking about building clang, but
using clang to compile Boost. What does VS have to do with that ?

Because you asked about building clang using Visual Studio in your
first question.

I have already successfully built clang using VS 2008 and VC9.

So I thought you wanted to build clang using visual
studio and then using the resulting clang to build boost. It is not
going to work because when you build clang using visual studio the
default configuration is to search in the msvc include directories for
standard headers. clang cannot parse these headers.

But clang cannot
currently parse the msvc header files.

Are you saying that clang needs the msvc header files under Windows ?

Not, if you build using MinGW.
If you build with MSVC clang will try to include from msvc by default.
To get around that use option -nostdinc++ and -nostdinc.

It sounds like you are saying that when clang is built with VS it
automatically uses the msvc header files awhen it is used to compile
source files but if it is built with MingW it automatically uses the
MingW header files when it is used to compile source files. Can that
really be so ? I would have assumed that however it is built it would
use its own header files and standard library.

That's the way clang works as I understand.

That does not make sense to me. However clang is built should be irrelevant when one uses it. If clang really operates the way you describe in Windows I would consider that a major flaw of the implementation.

clang doesn't currently
ship with its own complete standard library. One is currently in
development ( libc++) but doesn't work on windows.

OK, that I can believe.

As far as the Windows SDK header files I would guess that some Boost
libraries do use them, but I do not know why they would not be able to
be used by clang.

clang cannot currently compile the Windows SDK as provided by Microsoft.
clang can compile the Windows headers shipped with MinGW.

Then I will use the MingW headers when compiling clang. But I can not believe that I would have had to build clang with MingW to do that.

You don’t have to. But it sets its default header search paths depending on the compiler you use to compile it, so if you want to use the MinGW headers with a VS-built Clang, you always have to specify the search path yourself. Or you can probably change a configuration option somewhere when building it.

Sebastian

Edward Diener wrote:

Then I will use the MingW headers when compiling clang. But I can not believe that I would have had to build clang with MingW to do that.
  

This is a build time configuration issue which most likely is just defaulting to whatever the compiler was built with. In another project we had a similar problem and the way it around it is to make a configuration option that will change the driver defaults. If you're familiar with c++ code and makefile/cmake it shouldn't be too difficult to do..

Then I will use the MingW headers when compiling clang. But I can not
believe that I would have had to build clang with MingW to do that.

You don't have to. But it sets its default header search paths depending
on the compiler you use to compile it,

That is a real surprise. I guess it was done to make things easier for the end-user. I found nothing about this in the documentation.

so if you want to use the MinGW
headers with a VS-built Clang, you always have to specify the search
path yourself. Or you can probably change a configuration option
somewhere when building it.

If I can figure out where I can find documentation on the command line options of clang, I will. I am guessing the command-line options are the same as gcc 4.5 along with whatever is in the clang User's Manual under Command Line Options.

If I can figure out where I can find documentation on the command line
options of clang, I will. I am guessing the command-line options are the
same as gcc 4.5 along with whatever is in the clang User's Manual under
Command Line Options.

Another gotcha is that clang cannot parse some header files bundled
with gcc 4.5 because of C++0X features not implemented by clang.

You need gcc 4.2.

It wouldn't be a surprise if Clang "just worked" on Visual Studio's headers. Clang would emulate the compiler you use, as a drop-in replacement.

However, Windows support in general is a work-in-progress, requiring a number of Microsoft-specific extensions and emulating a number of Microsoft bugs and quirks. People are working on it, but it's not going to work seamlessly on Windows for quite a while.

  - Doug

OK, I will wait to try out clang on Windows but will use it on Linux instead. I do understand that VC++'s header files have lots of Microsoft extensions and it is unreasonable to assume that clang should easily support those extensions since its primary focus is in supporting the C and C++ standards. Thanks !