Dmitry
Dmitry

Reputation: 1319

Specify MSVC version for bazel

I'm looking for a way to tell bazel which version of VC++ it should use. I have already set BAZEL_VC=\VS2017Community\VC\ but the problem is my directory \VS2017Community\VC\Tools\MSVC has a number of different VC++ compilers. In particular the following versions are there

14.11.25503
14.13.26020
14.15.26726
14.16.27023

It is possible to force bazel to use specific version? By default it uses the first one(in alphabetic order) which is incorrect for me.

Upvotes: 2

Views: 1830

Answers (2)

angerson
angerson

Reputation: 7402

Bazel now reads BAZEL_VC_FULL_VERSION, set in addition to BAZEL_VC.

set BAZEL_VC=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC
set BAZEL_VC_FULL_VERSION=14.16.27023

This was added for Visual Studio 2017 and 2019. Older VS versions don't support it.

Source: Bazel Windows documentation

Upvotes: 2

Dmitry
Dmitry

Reputation: 1319

Currently there is no official way to do it. This is how bazel search for MSVC compiler (from Visual Studio 2017)

# Normally there should be only one child directory under %VC_PATH%\TOOLS\MSVC,
# but iterate every directory to be more robust.
for path in dirs:
    tool_path = str(path) + "\\bin\\HostX64\\x64\\" + tool
    if repository_ctx.path(tool_path).exists:
        break

Basically, it will get first found directory with cl.exe

One workaround could be just to rename/move all subdirs you don't need and left necessary one untouched. The true way is to change source code and recompile bazel :)

Upvotes: 0

Related Questions