Boost logo

Boost-Build :

From: Shintaro Sakahara (phork_at_[hidden])
Date: 2020-07-23 11:12:55


Hi, I'm trying to build Boost 1.73.0 with clang-cl compiler and MSVC2017
toolchain/libraries on Windows. I chose msvc toolset rather than
clang-win because recent clang-cl supports PDB and clang-win.jam does
not.

I wrote user-config.jam like below

using msvc
    : clang9.0
    :
    : <compiler>"\"C:/Program Files/LLVM/bin/clang-cl.exe\""
      <compileflags>-m32
    ;

and hit

b2 toolset=msvc-clang9.0 address-model=32 variant=debug link=static
runtime-link=shared --without-python --layout=tagged stage

It worked fine. Now, I want to build release variant and 64bit versions.
For release variant, I have to specify -flto compile flag, and for 64bit,
I have to specify -m64 instead of -m32. But I don't want to change
user-config.jam each time I change the options to pass to b2. Is there a
way to switch flags based on the whole build configuration? I tried

toolset.flags msvc.compile OPTIONS
<version>msvc-clang9.0/<address-model>64 : -m64 ;

which I thought used to work with some old situations but now it
complained

D:/Libraries/boost_1_73_0/tools/build/src/build\toolset.jam:170: in toolset.flags from module toolset
error: Module user-config attempted to set flags for module msvc
C:\Users\skhrshin\user-config.jam:12: in modules.load from module user-config
D:/Libraries/boost_1_73_0/tools/build/src\build-system.jam:255: in load-config from module build-system
D:/Libraries/boost_1_73_0/tools/build/src\build-system.jam:453: in load-configuration-files from module build-system
D:/Libraries/boost_1_73_0/tools/build/src\build-system.jam:607: in load from module build-system
D:\Libraries\boost_1_73_0\tools\build\src/kernel\modules.jam:295: in import from module modules
D:\Libraries\boost_1_73_0\tools\build\src/kernel/bootstrap.jam:139: in boost-build from module
D:\Libraries\boost_1_73_0\boost-build.jam:17: in module scope from module

A workaround is doing like below

using msvc
    : clang9.0debug32
    :
    : <compiler>"\"C:/Program Files/LLVM/bin/clang-cl.exe\""
      <compileflags>-m32
    ;
using msvc
    : clang9.0release32
    :
    : <compiler>"\"C:/Program Files/LLVM/bin/clang-cl.exe\""
      <compileflags>-m32
      <compileflags>-flto
    ;
using msvc
    : clang9.0debug64
    :
    : <compiler>"\"C:/Program Files/LLVM/bin/clang-cl.exe\""
      <compileflags>-m64
    ;
...

but you know, it's ugly. I would appreciate if someone tells me a better
solution.

Shintaro Sakahara <phork_at_[hidden]>


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