-
-
Notifications
You must be signed in to change notification settings - Fork 234
Description
Make sure you completed the following tasks
- I searched the discussions
- I searched the closed and open issues
- I read the contribution guidelines
Environment and version details
- Operating System+version: Windows 11
- Compiler+version: Visual Studio 2022 17.13.6
- Shell: PowerShell
- B2 Version: 5.2.0
- B2 Configuration: Output of
b2 --debug-configurationin your project.
Brief problem description
When having multiple versions of the Visual C++ Build Tools installed, B2 uses the first one it can find (typically the oldest one), instead of the one matching the msvc toolset version.
This can lead to linker issues later on when other object files are built using a different Build Tools version, and linked togehter. In my case, I am running into this issue with the Boost package for Conan. When Boost is built through Conan, B2 uses an older Build Tools version for compiling Boost than my application is built with.
Steps to reproduce the issue
- Install Visual Studio 2022. In the Visual Studio installer, install VC++ Build Tools for the current version and for at least one older version, e.g. MSVC "v143 - VS 2022 C++-x64/x86-Buildtools" and "MSVC v141 - VS 2017 C++-x64/x86-Buildtools (v14.16)".
- Run B2 with a user-config.jam file containing the "msvc" toolset with version 14.3.
Actual behavior summary
When B2 tries to resolve msvc toolset version 14.3, it searches for "cl.exe" under "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools". When multiple build tools versions are installed, B2 typically finds the oldest one first and uses that. In my case, there are:
C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.16.27023/bin/..../cl.exe
and
C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.43.34808/bin/..../cl.exe
Because the first one is enumerated and found first, it is used for resolving the toolset msvc 14.3. But this path is actually for toolset 14.1, and the second one would be the proper match for 14.3.
(I am using B2 through Conan but this shouldn't matter.)
user-config.jam:
using zlib : 1.3.1 : <include>"E:/Packages/conan/zlib0e715158c1dfd/p/include" <search>"E:/Packages/conan/zlib0e715158c1dfd/p/lib" <name>zlib ;
using bzip2 : 1.0.8 : <include>"E:/Packages/conan/bzip25d2dbaf142a52/p/include" <search>"E:/Packages/conan/bzip25d2dbaf142a52/p/lib" <name>bz2 ;
using "msvc" : 14.3 : :
;
B2 command:
b2 -q numa=on target-os=windows architecture=x86 address-model=64 binary-format=pe abi=ms --layout=system --user-config=E:\Packages\conan\boostf1ac9db4a1011\s\src\tools\build\user-config.jam -sNO_ZLIB=0 -sNO_BZIP2=0 -sNO_LZMA=1 -sNO_ZSTD=1 boost.locale.icu=off --disable-icu boost.locale.iconv=off --disable-iconv runtime-link=shared runtime-debugging=off threading=multi visibility=hidden link=static variant=release --with-atomic --with-chrono --with-container --with-context --with-contract --with-coroutine --with-date_time --with-exception --with-fiber --with-filesystem --with-graph --with-iostreams --with-json --with-locale --with-log --with-math --with-nowide --with-program_options --with-random --with-regex --with-serialization --with-stacktrace --with-system --with-test --with-thread --with-timer --with-type_erasure --with-url --with-wave toolset=msvc cxxstd=20 pch=on linkflags="" cxxflags="-fPIC" install --prefix=E:\Packages\conan\b\boost5b75ab377ea9b\p -j12 --abbreviate-paths -d0 --debug-configuration --build-dir="E:\Packages\conan\b\boost5b75ab377ea9b\b\build-release"
B2 output:
notice: found boost-build.jam at E:/Packages/conan/boostf1ac9db4a1011/s/src/boost-build.jam
notice: loading B2 from E:/Packages/conan/b2e4855d9acaafa/p/bin/.b2/build-system.jam
notice: Searching 'C:\WINDOWS' 'C:\Users\chris' 'C:\Users\chris' 'E:\Packages\conan\b2e4855d9acaafa\p\bin\.b2\build' 'E:\Packages\conan\b2e4855d9acaafa\p\bin\.b2\contrib' 'E:\Packages\conan\b2e4855d9acaafa\p\bin\.b2\options' 'E:\Packages\conan\b2e4855d9acaafa\p\bin\.b2\tools' 'E:\Packages\conan\b2e4855d9acaafa\p\bin\.b2\util' 'E:/Packages/conan/b2e4855d9acaafa/p/bin/.b2' for site-config configuration file 'site-config.jam'.
notice: Configuration file 'site-config.jam' not found in 'C:\WINDOWS' 'C:\Users\chris' 'C:\Users\chris' 'E:\Packages\conan\b2e4855d9acaafa\p\bin\.b2\build' 'E:\Packages\conan\b2e4855d9acaafa\p\bin\.b2\contrib' 'E:\Packages\conan\b2e4855d9acaafa\p\bin\.b2\options' 'E:\Packages\conan\b2e4855d9acaafa\p\bin\.b2\tools' 'E:\Packages\conan\b2e4855d9acaafa\p\bin\.b2\util' 'E:/Packages/conan/b2e4855d9acaafa/p/bin/.b2'.
notice: Loading explicitly specified user configuration file:
E:\Packages\conan\boostf1ac9db4a1011\s\src\tools\build\user-config.jam
notice: Searching 'E:\Packages\conan\boostf1ac9db4a1011\s\src\tools\build' for user-config configuration file 'user-config.jam'.
notice: Loading user-config configuration file 'user-config.jam' from 'E:/Packages/conan/boostf1ac9db4a1011/s/src/tools/build'.
notice: [zlib] Using pre-installed library
notice: [zlib] Condition
notice: [bzip2] Using pre-installed library
notice: [bzip2] Condition
notice: [msvc-cfg] msvc-14.3 detecting with path: 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64'
notice: [msvc-cfg] msvc-14.3 detected, command: 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\cl.exe'
notice: will use 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\cl.exe' for msvc, condition <toolset>msvc-14.3
notice: [generate-setup-cmd] 14.16.27023 is 14.1
notice: [generate-setup-cmd] 14.16.27023 is 14.1
notice: [generate-setup-cmd] 14.16.27023 is 14.1
notice: [generate-setup-cmd] 14.16.27023 is 14.1
notice: [generate-setup-cmd] 14.16.27023 is 14.1
notice: [msvc-cfg] condition: '<toolset>msvc-14.3/<architecture>x86/<address-model>32', setup: 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars32.bat'
notice: [msvc-cfg] condition: '<toolset>msvc-14.3/<architecture>/<address-model>32', setup: 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars32.bat'
notice: [msvc-cfg] condition: '<toolset>msvc-14.3/<architecture>x86/<address-model>64', setup: 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat'
notice: [msvc-cfg] condition: '<toolset>msvc-14.3/<architecture>/<address-model>64', setup: 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat'
notice: [msvc-cfg] condition: '<toolset>msvc-14.3/<architecture>x86/<address-model>', setup: 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat'
notice: [msvc-cfg] condition: '<toolset>msvc-14.3/<architecture>/<address-model>', setup: 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat'
notice: [msvc-cfg] condition: '<toolset>msvc-14.3/<architecture>ia64/<address-model>64', setup: 'C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvarsall.bat'
notice: [msvc-cfg] condition: '<toolset>msvc-14.3/<architecture>ia64/<address-model>', setup: 'C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvarsall.bat'
notice: [msvc-cfg] condition: '<toolset>msvc-14.3/<architecture>arm/<address-model>32', setup: 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsx86_arm.bat'
notice: [msvc-cfg] condition: '<toolset>msvc-14.3/<architecture>arm/<address-model>64', setup: 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsx86_arm64.bat'
Expected behavior summary
B2 should determine the best (most recent?) matching path to cl.exe based on the msvc toolset version request.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status