bazel icon indicating copy to clipboard operation
bazel copied to clipboard

Bazel 0.27+ does not support VS 2017 anymore?

Open blasnier opened this issue 7 years ago • 1 comments

Description of the problem / feature request:

On Windows, when using Visual Studio 2017 with Bazel 0.27+, an error occurs when configuring the cc toolchain. Here is the error for Bazel 0.27.x:

ERROR: C:/users/xxx/_bazel_xxx/tx5zfai7/external/local_config_cc/BUILD:173:1: in cc_toolchain_config rule @local_config_cc//:msvc_x64:
Traceback (most recent call last):
        File "C:/users/xxx/_bazel_xxx/tx5zfai7/external/local_config_cc/BUILD", line 173
                cc_toolchain_config(name = 'msvc_x64')
        File "C:/users/xxx/_bazel_xxx/tx5zfai7/external/local_config_cc/windows_cc_toolchain_config.bzl", line 265, in _impl
                feature(name = "msvc_link_env", env_sets =...)])])
        File "C:/users/xxx/_bazel_xxx/tx5zfai7/external/local_config_cc/windows_cc_toolchain_config.bzl", line 268, in feature
                env_set(actions = (all_link_actions + [A...]), ...)])
        File "C:/users/xxx/_bazel_xxx/tx5zfai7/external/local_config_cc/windows_cc_toolchain_config.bzl", line 271, in env_set
                env_entry(key = "LIB", value = ctx.attr.msvc...)
        File "C:/users/xxx/_bazel_xxx/tx5zfai7/external/bazel_tools/tools/cpp/cc_toolchain_config_lib.bzl", line 57, in env_entry
                _check_is_nonempty_string(value, "value", "env_entry")
        File "C:/users/xxx/_bazel_xxx/tx5zfai7/external/bazel_tools/tools/cpp/cc_toolchain_config_lib.bzl", line 29, in _check_is_nonempty_string
                fail("{} parameter of {} must be a no...))
value parameter of env_entry must be a nonempty string.

On Bazel 0.28 the error is:

ERROR: An error occurred during the fetch of repository 'local_config_cc':
   Traceback (most recent call last):
        File "C:/users/xxx/_bazel_xxx/tx5zfai7/external/bazel_tools/tools/cpp/cc_configure.bzl", line 114
                configure_windows_toolchain(repository_ctx)
        File "C:/users/xxx/_bazel_xxx/tx5zfai7/external/bazel_tools/tools/cpp/windows_cc_configure.bzl", line 521, in configure_windows_toolchain
                setup_vc_env_vars(repository_ctx, vc_path)
        File "C:/users/xxx/_bazel_xxx/tx5zfai7/external/bazel_tools/tools/cpp/windows_cc_configure.bzl", line 296, in setup_vc_env_vars
                _check_env_vars(env_map, cmd)
        File "C:/users/xxx/_bazel_xxx/tx5zfai7/external/bazel_tools/tools/cpp/windows_cc_configure.bzl", line 303, in _check_env_vars
                auto_configure_fail(("Setting up VC environment vari...)))
        File "C:/users/xxx/_bazel_xxx/tx5zfai7/external/bazel_tools/tools/cpp/lib_cc_configure.bzl", line 112, in auto_configure_fail
                fail(("\n%sAuto-Configuration Error:%...)))

Auto-Configuration Error: Setting up VC environment variables failed, INCLUDE is not set by the following command:
    "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\VCVARSALL.BAT" amd64  -vcvars_ver=14.10.25017

which leads to an internal error.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Set BAZEL_VC to target Visual Studio 2017 and attempt to build a simple hello-world in C++.

What operating system are you running Bazel on?

Windows 10

What's the output of bazel info release?

release 0.28

Any other information, logs, or outputs that you want to share?

Setting BAZEL_VC_FULL_VERSION did not change anything. The exact version of VS I am running is 15.0.0+26228.57. I checked the vcvarsall.bat on my computer and it does not seem to support the vcvars_ver parameter. I will try to find co-workers with a more recent VS 2017 installation to compare. BAZEL_VC = C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC

Edit: a co-worker uses a more recent version of VS 2017 (15.9.6) which supports the vcvars_ver parameter. It seems this feature was introduced with version 15.3.

blasnier avatar Jul 15 '19 15:07 blasnier

@baslas Thanks for reporting this issue!

Looks like we have wrongly assumed -vcvars_ver flag is supported in all VC version since VS 2017. https://github.com/bazelbuild/bazel/blob/4a1380fed159f09b29df461b85e0469f8cd81d34/tools/cpp/windows_cc_configure.bzl#L288-L292

We'll fix it soon!

meteorcloudy avatar Jul 16 '19 15:07 meteorcloudy