Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to execute Bazel binary built on Windows #6053

Closed
jin opened this issue Aug 31, 2018 · 14 comments
Closed

Unable to execute Bazel binary built on Windows #6053

jin opened this issue Aug 31, 2018 · 14 comments
Assignees
Labels
area-Windows Windows-specific issues and feature requests platform: windows team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website untriaged

Comments

@jin
Copy link
Member

jin commented Aug 31, 2018

Description of the problem / feature request:

I built a devbazel on Windows with Bazel 0.17.1rc1, but the resulting binary cannot be executed.

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

Building at 4d1d0b5

PS C:\Users\jingwen\Code\bazel> bazel build //src:bazel.exe
Starting local Bazel server and connecting to it...
WARNING: C:/users/jingwen/code/bazel/src/main/cpp/BUILD:71:12: in srcs attribute of cc_binary rule //src/main/cpp:client: please do not import '//src/main/native/windows:resources.o' directly. You should either move the file to this package or depend on an appropriate rule there
INFO: Analysed target //src:bazel.exe (219 packages loaded).
INFO: Found 1 target...
INFO: From Linking src/main/tools/linux-sandbox.exe:
LINK : warning LNK4044: unrecognized option '/lm'; ignored
INFO: From Compiling src/main/cpp/util/path_windows.cc:
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.15.26726\include\algorithm(1443): warning C4244: '=': conversion from 'wint_t' to 'char', possible loss of data
src/main/cpp/util/path_windows.cc(73): note: see reference to function template instantiation '_OutIt std::transform<std::_String_iterator<std::_String_val<std::_Simple_types<_Ty>>>,std::_String_iterator<std::_String_val<std::_Simple_types<_Ty>>>,wint_t(__cdecl *)(wint_t)>(const _InIt,const _InIt,_OutIt,_Fn)' being compiled
        with
        [
            _OutIt=std::_String_iterator<std::_String_val<std::_Simple_types<char>>>,
            _Ty=char,
            _InIt=std::_String_iterator<std::_String_val<std::_Simple_types<char>>>,
            _Fn=wint_t (__cdecl *)(wint_t)
        ]
INFO: From Executing genrule @bazel_tools//tools/jdk:platformclasspath [for host]:
warning: [options] bootstrap class path not set in conjunction with -source 8
1 warning
INFO: From Linking src/main/native/windows/windows_jni.dll:
   Creating library bazel-out/x64_windows-fastbuild/bin/src/main/native/windows/windows_jni.dll.if.lib and object bazel-out/x64_windows-fastbuild/bin/src/main/native/windows/windows_jni.dll.if.exp
INFO: From Linking third_party/grpc/cpp_plugin.exe [for host]:
LINK : warning LNK4044: unrecognized option '/lm'; ignored
INFO: From Generating Java (Immutable) proto_library //src/main/protobuf:desugar_deps_proto:
[libprotobuf WARNING external/com_google_protobuf/src/google/protobuf/compiler/java/java_file.cc:228] The optimize_for = LITE_RUNTIME option is no longer supported by protobuf Java code generator and may generate broken code. It will be ignored by protoc in the future and protoc will always generate full runtime code for Java. To use Java Lite runtime, users should use the Java Lite plugin instead. See:
  https://github.com/google/protobuf/blob/master/java/lite.md
INFO: From Generating Java (Immutable) proto_library //src/tools/android/java/com/google/devtools/build/android/proto:resources_proto:
[libprotobuf WARNING external/com_google_protobuf/src/google/protobuf/compiler/java/java_file.cc:228] The optimize_for = LITE_RUNTIME option is no longer supported by protobuf Java code generator and may generate broken code. It will be ignored by protoc in the future and protoc will always generate full runtime code for Java. To use Java Lite runtime, users should use the Java Lite plugin instead. See:
  https://github.com/google/protobuf/blob/master/java/lite.md
[libprotobuf WARNING external/com_google_protobuf/src/google/protobuf/compiler/java/java_file.cc:228] The optimize_for = LITE_RUNTIME option is no longer supported by protobuf Java code generator and may generate broken code. It will be ignored by protoc in the future and protoc will always generate full runtime code for Java. To use Java Lite runtime, users should use the Java Lite plugin instead. See:
  https://github.com/google/protobuf/blob/master/java/lite.md
[libprotobuf WARNING external/com_google_protobuf/src/google/protobuf/compiler/java/java_file.cc:228] The optimize_for = LITE_RUNTIME option is no longer supported by protobuf Java code generator and may generate broken code. It will be ignored by protoc in the future and protoc will always generate full runtime code for Java. To use Java Lite runtime, users should use the Java Lite plugin instead. See:
  https://github.com/google/protobuf/blob/master/java/lite.md
INFO: From SkylarkAction external/googleapis/google_bytestream_bytestream_java_grpc_srcs.jar:
google/bytestream/bytestream.proto: warning: Import google/protobuf/wrappers.proto but not used.
INFO: From Generating Java (Immutable) proto_library @googleapis//:google_devtools_build_v1_build_events_proto:
google/devtools/build/v1/build_events.proto: warning: Import google/rpc/status.proto but not used.
INFO: From Generating Java (Immutable) proto_library @googleapis//:google_bytestream_bytestream_proto:
google/bytestream/bytestream.proto: warning: Import google/protobuf/wrappers.proto but not used.
INFO: From Compiling Java headers src/main/java/com/google/devtools/build/lib/libbuild-base-hjar.jar (473 files):
Action failed to execute: java.io.IOException: ERROR: src/main/native/windows/processes-jni.cc(161): CreateProcessWithExplicitHandles("C:\users\jingwen\_bazel_jingwen\wqlyjfgb\execroot\io_bazel\external\embedded_jdk\bin\java.exe" -Xverify:none -XX:+UseParallelOldGC -XX:-CompactStrings --add-exports=jdk.compiler/com.sun.tools.javac.a(...)): command is longer than CreateProcessW's limit (32768 characters)
Target //src:bazel.exe up-to-date:
  C:/users/jingwen/_bazel_jingwen/wqlyjfgb/execroot/io_bazel/bazel-out/x64_windows-fastbuild/bin/src/bazel.exe
INFO: Elapsed time: 337.407s, Critical Path: 92.09s
INFO: 1699 processes: 1392 local, 307 worker.
INFO: Build completed successfully, 1825 total actions
PS C:\Users\jingwen\Code\bazel> .\bazel-bin\src\bazel.exe
Extracting Bazel installation...
[libprotobuf FATAL third_party/protobuf/3.6.0/src/google/protobuf/generated_message_reflection.cc:2372] CHECK failed: file != NULL:

What operating system are you running Bazel on?

Windows 10.

What's the output of bazel info release?

PS C:\Users\jingwen\Code\bazel> bazel info release
release 0.17.1rc1

What's the output of git remote get-url origin ; git rev-parse master ; git rev-parse HEAD ?

git remote get-url origin ; git rev-parse master ; git rev-parse HEAD
https://github.com/bazelbuild/bazel
4d1d0b5
4d1d0b5

@jin
Copy link
Member Author

jin commented Aug 31, 2018

@laszlocsomor @meteorcloudy did I miss a setup step somewhere?

@jin jin added area-Windows Windows-specific issues and feature requests untriaged labels Aug 31, 2018
@jin
Copy link
Member Author

jin commented Aug 31, 2018

Ah.. maybe this line has something to do with it?

Action failed to execute: java.io.IOException: ERROR: src/main/native/windows/processes-jni.cc(161): CreateProcessWithExplicitHandles("C:\users\jingwen\_bazel_jingwen\wqlyjfgb\execroot\io_bazel\external\embedded_jdk\bin\java.exe" -Xverify:none -XX:+UseParallelOldGC -XX:-CompactStrings --add-exports=jdk.compiler/com.sun.tools.javac.a(...)): command is longer than CreateProcessW's limit (32768 characters)

@cushon
Copy link
Contributor

cushon commented Sep 1, 2018

I think this is the same issue as #4096.

It looks like the build recovered from that and still succeeded, which is consistent with the other bug:

INFO: From Compiling Java headers src/main/java/com/google/devtools/build/lib/libbuild-base-hjar.jar (473 files):
Action failed to execute: java.io.IOException: ERROR: src/main/native/windows/processes-jni.cc(161): CreateProcessWithExplicitHandles("C:\users\jingwen\_bazel_jingwen\wqlyjfgb\execroot\io_bazel\external\embedded_jdk\bin\java.exe" -Xverify:none -XX:+UseParallelOldGC -XX:-CompactStrings --add-exports=jdk.compiler/com.sun.tools.javac.a(...)): command is longer than CreateProcessW's limit (32768 characters)
Target //src:bazel.exe up-to-date:

The principled solution to this was blocked on deferred param files, which are now available, so we can make sure header compilation actions are always using params files for command lines that exceed platform-specific limits.

@meteorcloudy
Copy link
Member

@jin I think this is a protobuf bug with Visual Studio 2017
See protocolbuffers/protobuf#4773

@meteorcloudy
Copy link
Member

meteorcloudy commented Sep 3, 2018

We should update protobuf version to 3.6.1 to fix this issue
https://github.com/protocolbuffers/protobuf/releases/tag/v3.6.1

@jin
Copy link
Member Author

jin commented Sep 4, 2018

Thanks for the quick fix! Now I'm running into this issue:

PS C:\Users\jingwen\Code\bazel> bazel build //src:bazel
WARNING: C:/users/jingwen/code/bazel/src/main/cpp/BUILD:71:12: in srcs attribute of cc_binary rule //src/main/cpp:client: please do not import '//src/main/native/windows:resources.o' directly. You should either move the file to this package or depend on an appropriate rule there
INFO: Analysed target //src:bazel (226 packages loaded).
INFO: Found 1 target...
ERROR: C:/users/jingwen/code/bazel/tools/test/BUILD:41:1: undeclared inclusion(s) in rule '//tools/test:test_wrapper_bin':
this rule is missing dependency declarations for the following files included by 'tools/test/windows/test_wrapper.cc':
  'bazel-out/x64_windows-fastbuild/genfiles/tools/cpp/runfiles/runfiles.h'
Target //src:bazel failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 13.454s, Critical Path: 2.32s
INFO: 21 processes: 21 local.
FAILED: Build did NOT complete successfully

@laszlocsomor
Copy link
Contributor

Protobuf is not yet updated in upstream Bazel. Did you patch in #6065 and #6068 ?

The problem you just described was fixed upstream by ea642d6

@laszlocsomor
Copy link
Contributor

(FYI, ea642d6 depends on 131e31c.)

@jin
Copy link
Member Author

jin commented Sep 4, 2018 via email

@filipesilva
Copy link

@laszlocsomor I just tried building master on windows (HEAD at 5939235) and got the same error as @jin:

ERROR: D:/sandbox/bazel/tools/test/BUILD:41:1: undeclared inclusion(s) in rule '//tools/test:test_wrapper_bin':
this rule is missing dependency declarations for the following files included by 'tools/test/windows/test_wrapper.cc':
  'bazel-out/x64_windows-fastbuild/genfiles/tools/cpp/runfiles/runfiles.h'
Target //src:bazel failed to build
INFO: Elapsed time: 240.434s, Critical Path: 52.76s
INFO: 343 processes: 308 local, 35 worker.
FAILED: Build did NOT complete successfully

@laszlocsomor
Copy link
Contributor

@filipesilva : You probably need to bazel clean. bazel-out/x64_windows-fastbuild/genfiles/tools/cpp/runfiles/runfiles.h is a stale output from an older build.

@laszlocsomor
Copy link
Contributor

...but given that sandboxing is not supported on Windows and all actions run non-sandboxed (under the execution root) the compilation action for @bazel_tools//tools/cpp/runfiles mistakenly picks up this stale header file.

@laszlocsomor
Copy link
Contributor

FYI, protobuf is updated to 3.6.1 at HEAD.

@filipesilva
Copy link

Can confirm that I was able to build after bazel clean 👍

@philwo philwo added the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Jun 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Windows Windows-specific issues and feature requests platform: windows team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website untriaged
Projects
None yet
Development

No branches or pull requests

6 participants