Skip to content

Unable to execute Bazel binary built on Windows #6053

Closed

Description

@jin

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

Activity

  1. jin commented on Aug 31, 2018

    @jin
    MemberAuthor

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

  2. added
    area-Windows
    untriaged
    on Aug 31, 2018
  3. jin commented on Aug 31, 2018

    @jin
    MemberAuthor

    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)
    
  4. cushon commented on Sep 1, 2018

    @cushon
    Contributor

    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.

  5. meteorcloudy commented on Sep 3, 2018

    @meteorcloudy
    Member

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

  6. meteorcloudy commented on Sep 3, 2018

    @meteorcloudy
    Member
  7. jin commented on Sep 4, 2018

    @jin
    MemberAuthor

    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
    
  8. laszlocsomor commented on Sep 4, 2018

    @laszlocsomor
    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

  9. laszlocsomor commented on Sep 4, 2018

    @laszlocsomor
    Contributor

    (FYI, ea642d6 depends on 131e31c.)

  10. jin commented on Sep 4, 2018

    @jin
    MemberAuthor
  11. self-assigned this
    on Sep 5, 2018
  12. filipesilva commented on Sep 5, 2018

    @filipesilva

    @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
    
  13. laszlocsomor commented on Sep 5, 2018

    @laszlocsomor
    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.

  14. laszlocsomor commented on Sep 5, 2018

    @laszlocsomor
    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.

  15. laszlocsomor commented on Sep 5, 2018

    @laszlocsomor
    Contributor

    FYI, protobuf is updated to 3.6.1 at HEAD.

  16. filipesilva commented on Sep 5, 2018

    @filipesilva

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

  17. added
    team-OSS
    on Jun 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-Windowsplatform: windowsteam-OSSuntriaged

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions