Boost logo

Boost-Build :

Subject: Re: [Boost-build] Configuring modular -boost develop for b2 / bjam for Clang 3.9.1 on Windows 10 VS 2015 Update 3
From: Edward Diener (eldiener_at_[hidden])
Date: 2017-02-27 14:24:51


On 2/27/2017 5:22 AM, Paul A. Bristow via Boost-build wrote:
> I've trying and failing to install the latest Clang 3.9.1 on Windows 10, Visual studio 2015 14.0.25402.00 update 3 RC Version
> 4.6.01586.
>
> modular-boost develop branch, currently up-to-date.
>
> I:\modular-boost\libs\hello_boost\example>b2 -v
> Boost.Jam Version 2015.07. OS=NT.
> Copyright 1993-2002 Christopher Seiwald and Perforce Software, Inc.
> Copyright 2001 David Turner.
> Copyright 2001-2004 David Abrahams.
> Copyright 2002-2015 Rene Rivera.
> Copyright 2003-2015 Vladimir Prus.
>
> I can run the compiler from the command line and using CodeBlocks, for example:
>
> clang++.exe -Wall -fexceptions -g -m64 -II:\modular-boost -I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.10586.0\ucrt" -c
> J:\Cpp\hellos\hello_boost\hello_boost.cpp -o obj\Debug\hellos\hello_boost\hello_boost.o
> b2 -v
>
> So I believe that the compiler is working OK.
>
> -I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.10586.0\ucrt" is needed to find corecrt.h
> (and also a library link).
>
> To try to match this my user-config contains
>
> using clang
> : # version
> 3.9.1
> : # location Clang compiler .exe location. # from http://llvm.org/releases/download.html
> # "C:\\Program Files\\LLVM\\bin\\clang++.exe"
> # "C:/Program Files/LLVM/bin/clang++.exe"
> : # options
> <cxxflags>-i"C:/Program Files (x86)/Windows Kits/10/Include/10.0.10586.0/ucrt"
> ;
>
> One puzzling feature is that neither of the clang++.exe file specifications commented-out are recognized???
>
> But these are OK.
>
> "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\cl.exe"
> "C:\\Program Files\\mingw-w64\\x86_64-4.9.1-win32-seh-rt_v3-rev1\\mingw64\\bin\\g++.exe"
>
> Nor are either of these where the spaces after Program and File etc are misparsed after Program, missing the space, despite the
> quotes around the whole file specification.
>
> # <cxxflags>-i"C:/Program Files (x86)/Windows Kits/10/Include/10.0.10586.0/ucrt"
> # <cxxflags>-i"C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.10586.0\\ucrt"
>
> What am I doing wrong here?

First of all I never install any version of clang to a directory with
spaces. So I am not sure about the space problem but it does seem as if
putting quotes around the full path to the clang executable should work
in Boost Build.

The default clang distribution for version 3.8 on up is targeting VC++
and not mingw(-64)/gcc. All previous versions defaulted to targeting
mingw(-64)/gcc. If you want to target mingw(-64)/gcc you need to add
'<compileflags>"-target i686-pc-windows-gnu"' for 32-bit clang or
"<compileflags>"-target x86_64-pc-windows-gnu"" for 64-bit clang. Also
of course the particular version of clang, as well as the version of
mingw(-64)/gcc must be in your PATH when you execute b2 ( bjam ). To use
clang targeting VC++ you need to have 'using clang-win" rather than
"using clang". However clang targeting VC++ has some serious problems
when using Boost. These are:

1) Clang targeting VC++ has a broken preprocessor emulation of the
non-standard VC++ preprocessor. This causes various Boost PP macro
errors when using clang-win, even thought they succeed when using VC++.
I have brought these up with the clang people and issued bug reports
about their broken preprocessor emulation of the non-standard VC++
preprocessor, but they are blithely unconcerned about it.

2) The clang-win.jam file, which was created by someone else originally
but contributed to Boost Build by myself, has some slight problems which
I am not enough of a Boost Build programmer to figure out or fix. I have
never gotten an iota of help with those problems from any of the really
knowledgeable Boost Build programmers and they have largely ignored
clang-win.

My user-config.jam entries for clang and clang-win for clang 3.9.1 are:

32-bit:

using clang : 3.9 : C:/Utilities/LLVM/391/x32/bin/clang++
  :
  <warnings>on
  <cxxflags>-D__MINGW_FORCE_SYS_INTRINS
  <cxxflags>-Wno-unused-local-typedef
  <cxxflags>-Wno-dll-attribute-on-redeclaration
  <compileflags>"-target i686-pc-windows-gnu"
  ;

using clang-win : 3.9 : C:/Utilities/LLVM/391/x32/bin/clang-cl
  :
  <cxxflags>-fmacro-backtrace-limit=0
  <cxxflags>-Wno-invalid-token-paste
  <compatibility>vc14
  ;

64-bit

using clang : 3.9x64 : C:/Utilities/LLVM/391/x64/bin/clang++
  :
  <warnings>on
  <cxxflags>-D__MINGW_FORCE_SYS_INTRINS
  <cxxflags>-Wno-unused-local-typedef
  <cxxflags>-Wno-dll-attribute-on-redeclaration
  <compileflags>"-target x86_64-pc-windows-gnu"
  ;

using clang-win : 3.9x64 : C:/Utilities/LLVM/391/x64/bin/clang-cl
  :
  <cxxflags>-fmacro-backtrace-limit=0
  <cxxflags>-Wno-invalid-token-paste
  <compatibility>vc14
  ;

If you do use clang targeting mingw(-64)/gcc, which to me is the only
real clang possibility when testing Boost extensively, you have to
decide what version of mingw(-64)/gcc to use as the backend. I once
endeavored to ask about this on the clang developer mailing list,
generalizing the question for every version of clang 3.4 on up, but
never received an answer. Also I should warn that while clang 3.9.1
targeting mingw(-64)/gcc works well when compiling Boost, there are
occasional problems it has when linking exes and dlls, which using an
equivalent version of gcc does not have.

I hope this helps you.

>
> However, clang++.exe is found automatically by b2 configuration, so after commenting both file specifications out, it finds the
> Clang compiler OK (but I want to have more than one version so I need to be able to differentiate them in future).
>
> But when I let it proceed, the configuration fails to find cstddefs.h
>
> clang-linux.compile.c++.without-pth
> ..\..\..\bin.v2\libs\hello_boost\example\hello_boost.test\clang-linux-3.9.1\debug\hello_boost.obj
> In file included from hello_boost.cpp:15:
> In file included from ..\..\..\boost/config.hpp:44:
> ..\..\..\boost/config/select_stdlib_config.hpp:18:12: fatal error: 'cstddef' file not found
> # include <cstddef>
> ^
> 1 error generated.
>
> "clang++" -c -x c++ -O0 -g -fno-inline -Wall -g -m64 -DBOOST_ALL_NO_LIB=1 -I"..\..\.." -o
> "..\..\..\bin.v2\libs\hello_boost\example\hello_boost.test\clang-linux-3.9.1\debug\hello_boost.obj" "hello_boost.cpp"
>
> It is correct that it says "clang-linux-3.9.1" when the OK is Windows (MSYS2 also installed)?
>
> Should I be using clang-cl.exe
> "C:\\Program Files\\LLVM\\bin\\clang-cl.exe" ? Or ?
>
> Do I need any
>
> <cxxflags>-fms-compatibility-version=19.00 items?
>
> <cxxflags>-i"C:\\Program Files (x86)\\Windows Kits\\10\\Include\\0.0.10586.0\\ucrt"
>
> (debug-configuration log attached in case that helps).
>
> Suggestions please.
>
> Thanks.
>
> Paul
>
> ---
> Paul A. Bristow
> Prizet Farmhouse
> Kendal UK LA8 8AB
> +44 (0) 1539 561830


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk