分析阶段如何分析不成功的构建?

How to analyze unsuccessful builds in the analysis phase?

我正在构建的 bazel 二进制文件在分析阶段未成功完成。我可以使用哪些标志和工具来调试它在分析过程中失败的原因。

目前,clean 构建return以下输出

ERROR: build interrupted
INFO: Elapsed time: 57.819 s
FAILED: Build did NOT complete successfully (133 packages loaded)

如果我在失败完成后重试构建,我会收到以下输出

ERROR: build interrupted
INFO: Elapsed time: 55.514 s
FAILED: Build did NOT complete successfully (68 packages loaded)

我可以使用哪些标志来识别

本质上,与 --verbose_failures 类似,但用于分析阶段而不是执行阶段。

到目前为止,我已经 运行 通过构建分析器构建了我的构建,但未能收集到任何信息。这是我构建的输出:

WARNING: This information is intended for consumption by Blaze developers only, and may change at any time.  Script against it at your own risk
INFO: Loading /<>/result
INFO: bazel profile for <> at Mon Jun 04 00:10:11 GMT 2018, build ID: <>, 49405 record(s)
INFO: Aggregating task statistics

=== PHASE SUMMARY INFORMATION ===

Total launch phase time         9.00 ms    0.02%
Total init phase time           91.0 ms    0.16%
Total loading phase time        1.345 s    2.30%
Total analysis phase time      57.063 s   97.53%
Total run time                 58.508 s  100.00%

=== INIT PHASE INFORMATION ===

Total init phase time                    91.0 ms

Total time (across all threads) spent on:
              Type    Total    Count     Average

=== LOADING PHASE INFORMATION ===

Total loading phase time                 1.345 s

Total time (across all threads) spent on:
              Type    Total    Count     Average
    CREATE_PACKAGE    0.67%        9     3.55 ms
          VFS_STAT    0.69%      605     0.05 ms
           VFS_DIR    0.96%      255     0.18 ms
          VFS_OPEN    2.02%        8     12.1 ms
          VFS_READ    0.00%        5     0.01 ms
          VFS_GLOB   23.74%     1220     0.93 ms
     SKYFRAME_EVAL   24.44%        3      389 ms
       SKYFUNCTION   36.95%     8443     0.21 ms
     SKYLARK_LEXER    0.19%       31     0.29 ms
    SKYLARK_PARSER    0.68%       31     1.04 ms
   SKYLARK_USER_FN    0.03%        5     0.27 ms
SKYLARK_BUILTIN_FN    5.91%      349     0.81 ms

=== ANALYSIS PHASE INFORMATION ===

Total analysis phase time               57.063 s

Total time (across all threads) spent on:
              Type    Total    Count     Average
    CREATE_PACKAGE    0.30%      138     3.96 ms
          VFS_STAT    0.05%     2381     0.03 ms
           VFS_DIR    0.19%     1020     0.35 ms
          VFS_OPEN    0.04%      128     0.61 ms
          VFS_READ    0.00%      128     0.01 ms
          VFS_GLOB    0.92%     3763     0.45 ms
     SKYFRAME_EVAL   31.13%        1    57.037 s
       SKYFUNCTION   65.21%    32328     3.70 ms
     SKYLARK_LEXER    0.01%      147     0.10 ms
    SKYLARK_PARSER    0.03%      147     0.39 ms
   SKYLARK_USER_FN    0.20%      343     1.08 ms

就我的命令而言,我是运行

bazel build src:MY_TARGET --embed_label MY_LABEL --stamp --show_loading_progress

在构建过程中使用 --host_jvm_debug 启动标志调试 Bazel 本身。

来自 https://bazel.build/contributing.html:

Debugging Bazel

Start creating a debug configuration for both C++ and Java in your .bazelrc with the following:

build:debug -c dbg
build:debug --javacopt="-g"
build:debug --copt="-g"
build:debug --strip="never"

Then you can rebuild Bazel with bazel build --config debug //src:bazel and use your favorite debugger to start debugging.

For debugging the C++ client you can just run it from gdb or lldb as you normally would. But if you want to debug the Java code, you must attach to the server using the following:

  • Run Bazel with debugging option --host_jvm_debug before the command (e.g., bazel --batch --host_jvm_debug build //src:bazel).

  • Attach a debugger to the port 5005. With jdb for instance, run jdb -attach localhost:5005. From within Eclipse, use the remote Java application launch configuration.

  • Our IntelliJ plugin has built-in debugging support