bazel: --workspace_status_command option doesn't work on Windows

With Bazel 0.3.2, on Windows, it’s failing to compile this particular target:

https://github.com/GerritCodeReview/gerrit/blob/master/gerrit-patch-jgit/BUILD#L27-L37

With this outcome:

davido@DESKTOP-VDNCUPU MSYS ~/projects/gerrit
$ bazel build gerrit-patch-jgit:edit.srcjar --verbose_failures --subcommands
WARNING: C:/tools/msys64/var/tmp/Bazel/Vne9nLyn/external/bazel_tools/tools/cpp/cc_configure.bzl:57:3:
Auto-Configuration Warning: 'BAZEL_VS' is not set, start looking for the latest Visual Studio installed.
.
WARNING: C:/tools/msys64/var/tmp/Bazel/Vne9nLyn/external/bazel_tools/tools/cpp/cc_configure.bzl:57:3:
Auto-Configuration Warning: Visual Studio found at C:\Program Files (x86)/Microsoft Visual Studio 15.0
.
INFO: Found 1 target...
>>>>> # //gerrit-patch-jgit:jgit_edit_src [action 'Executing genrule //gerrit-patch-jgit:jgit_edit_src']
cd C:/tools/msys64/var/tmp/Bazel/Vne9nLyn/execroot/gerrit
  SET PATH=C:\tools\msys64\usr\local\bin;C:\tools\msys64\usr\bin;C:\tools\msys64\usr\bin;C:\tools\msys64\opt\bin;C:\Windows\System32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\ProgramData\chocolatey\bin;C:\ProgramData\chocolatey\bin;C:\tools\python2;C:\ProgramData\chocolatey\bin;C:\tools\python2;C:\ProgramData\chocolatey\bin;C:\tools\python2;C:\ProgramData\chocolatey\bin;C:\tools\python2;C:\ProgramData\chocolatey\bin;C:\tools\python2;C:\ProgramData\chocolatey\bin;C:\tools\python2;C:\ProgramData\chocolatey\bin;C:\tools\python2
  C:/tools/msys64/usr/bin/bash.exe -c source external/bazel_tools/tools/genrule/genrule-setup.sh; ROOT=$PWD && TMP=$(mktemp -d || mktemp -d -t bazel-tmp) && (unzip -qd $TMP external/jgit_src/file/org.eclipse.jgit-4.5.0.201609210915-r-sources.jar org/eclipse/jgit/diff/Edit.java && cd $TMP && zip -Dq $ROOT/bazel-out/local-fastbuild/genfiles/gerrit-patch-jgit/edit.srcjar org/eclipse/jgit/diff/Edit.java)
ERROR: Process exited with status 1.
ERROR: C:/tools/msys64/home/davido/projects/gerrit/gerrit-patch-jgit/BUILD:27:1: declared output 'gerrit-patch-jgit/edit.srcjar' was not created by genrule. This is probably because the genrule actually didn't create this output, or because the output was a directory and the genrule was run remotely (note that only the contents of declared file outputs are copied from genrules run remotely).
Target //gerrit-patch-jgit:edit.srcjar failed to build
INFO: Elapsed time: 1,032s, Critical Path: 0,04s

It seems that there is an issue with creating output artifacts here, e.g. here is similar failure for different target [1].

Environment: Bazel 0.3.2, bundled install with Chocolatey.

[1] http://paste.openstack.org/show/587839/

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 61 (45 by maintainers)

Commits related to this issue

Most upvoted comments

Which version did you install exactly?

If for example it’s Visual Studio 2015, you’d have the VS140COMNTOOLS envvar set, e.g.:

VS140COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\

When you install VS, it usually adds these envvars to your environment. Bazel is looking for VSversionCOMNTOOLS envvars to find where VS is installed and which version is it. Your build is failing because Bazel cannot find these.

To fix it, you can set the BAZEL_VS environment variable to point to the VS installation location, e.g.:

set BAZEL_VS=C:\Program Files (x86)\Microsoft Visual Studio 14.0

(See https://bazel.build/versions/master/docs/windows.html#build-c)

@laszlocsomor correct, we only support Android bazel tf builds with Linux-based OS’s. You can see https://github.com/tensorflow/tensorflow/issues/6385 for more details and workarounds.

@ajaysaini-sgvu : I think Windows is not yet fully supported by all the tools involved in this build.

Here’s the command you ran:

bazel --output_user_root=D:/tmp1 --host_jvm_args=-Dbazel.windows_unix_root=C:/tools/msys64 build -c opt //tensorflow/contrib/android:libtensorflow_inference.so --crosstool_top=//external:android/crosstool --host_crosstool_top=@bazel_tools//tools/cpp:toolchain --cpu=armeabi-v7a --verbose_failures

I ran a slightly modified version, with bazel 0.5.2:

C:\work\tensorflow>c:\work\bazel-msvc-0.5.2-windows-msvc-x86_64\bazel.exe --bazelrc=NUL --nomaster_bazelrc --output_user_root=c:/tmp1 --host_jvm_args=-Dbazel.windows_unix_root=C:/tools/msys64 build -c opt //tensorflow/contrib/android:libtensorflow_inference.so --crosstool_top=//external:android/crosstool --host_crosstool_top=@bazel_tools//tools/cpp:toolchain --cpu=armeabi-v7a --verbose_failures --copt=-w --host_copt=-w

And I also get a build error, though it’s different than yours:

ERROR: C:/tmp1/cfyq7gze/external/protobuf/BUILD:113:1: C++ compilation of rule '@protobuf//:protobuf' failed: false failed: error executing command
  cd C:/tmp1/cfyq7gze/execroot/org_tensorflow
  SET PATH=C:\tools\msys64\usr\bin;C:\tools\msys64\bin;c:\tools\msys64\usr\bin;C:\Python27\;C:\Python27\Scripts;C:\ProgramData\Oracle\Java\javapath;C:\Windows\CCM\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\corpam;C:\Program Files (x86)\Google\Cert Installer\;C:\Windows\mrmagoo;C:\gnubby\bin\;C:\python_27_amd64\files;C:\Windows\ccmsetup;C:\Program Files (x86)\Google\gWindows-Updater;C:\Program Files\Puppet Labs\Puppet\bin;C:\Program Files (x86)\Bit9\Parity Agent;C:\Program Files\Git\cmd;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files (x86)\Google\gWindowsInformation;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\ProgramData\GooGet;C:\Program Files\Java\jdk1.8.0_112\bin;C:\Program Files\Google\gWindows-Updater;C:\Program Files (x86)\Corp SSH Helper;C:\Program Files\gWindows-Updater;C:\gnubby\bin;C:\Program Files (x86)\Google\Cert Installer;C:\Windows\system32\WindowsPowerShell\v1.0;C:\Program Files\CMake\bin;C:\Program Files\dotnet\;;C:\ProgramData\Diagnose_me;C:\Program Files (x86)\PuTTY\;
    SET PWD=/proc/self/cwd
  /bin/false -w -MD -MF bazel-out/stub_armeabi-v7a-opt/bin/external/protobuf/_objs/protobuf/external/protobuf/src/google/protobuf/util/internal/default_value_objectwriter.pic.d -frandom-seed=bazel-out/stub_armeabi-v7a-opt/bin/external/protobuf/_objs/protobuf/external/protobuf/src/google/protobuf/util/internal/default_value_objectwriter.pic.o -fPIC -iquote external/protobuf -iquote bazel-out/stub_armeabi-v7a-opt/genfiles/external/protobuf -iquote external/bazel_tools -iquote bazel-out/stub_armeabi-v7a-opt/genfiles/external/bazel_tools -isystem external/protobuf/src -isystem bazel-out/stub_armeabi-v7a-opt/genfiles/external/protobuf/src -isystem external/bazel_tools/tools/cpp/gcc3 -DHAVE_PTHREAD -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare -Wno-unused-function -c external/protobuf/src/google/protobuf/util/internal/default_value_objectwriter.cc -o bazel-out/stub_armeabi-v7a-opt/bin/external/protobuf/_objs/protobuf/external/protobuf/src/google/protobuf/util/internal/default_value_objectwriter.pic.o: java.io.IOException: CreateProcess(): The system cannot find the file specified.
.
Target //tensorflow/contrib/android:libtensorflow_inference.so failed to build
INFO: Elapsed time: 79.805s, Critical Path: 11.58s

The --bazelrc=NUL and --nomaster_bazelrc flags ensure that bazel won’t pick up any of my bazelrc files, and use flags from there. This way the flags I passed in this command are the only ones that are actually used.

The --output_user_root and --host_jvm_args flags are the same I recommended to you earlier.

The --cpu, --crosstool_top, and --host_crosstool_top flags come from your command, and I believe you copied those from //tensorflow/contrib/android/BUILD file. Those were added by @andrewharp, and I believe he intended those to be used on Linux or MacOS.

The --copt=-w and --host_copt=-w flags just reduce compiler noise on stdout; MSVC likes to print zillions of warnings and notices.

I believe the specified crosstool and host-crosstool don’t yet work on Windows. The reason I believe that is that the command Bazel tried to run was /bin/false, which of course always fails, so it looks like the crosstool isn’t supported on this platform. @andrewharp, @mhlopko : can you confirm?