Bazel build verbose compiler commands logging

左心房为你撑大大i 提交于 2020-12-02 00:09:29

问题


How can I increase the verbosity of the build process? Bazel seems to print compiler commands only if something goes wrong during the build.

I would like to see which compiler comands the cc_library rule fires, even if everything seems to be fine, to debug linking problems. I already tried various bazel command line parameters but nothing gives me the compiler commands :(


回答1:


This is probably what you are looking for

bazel build -s //my:target

The -s switch makes Bazel print out all the invoked commands.




回答2:


Useful information taken from Envoy's bazel readme (https://github.com/envoyproxy/envoy/blob/master/bazel/README.md)

When trying to understand what Bazel is doing, the -s and --explain options are useful. To have Bazel provide verbose output on which commands it is executing:

bazel build -s //source/...

To have Bazel emit to a text file the rationale for rebuilding a target:

bazel build --explain=file.txt //source/...

To get more verbose explanations:

bazel build --explain=file.txt --verbose_explanations //source/...



回答3:


Maybe you can generate the compile_commands.json file. I have created Shell scripts (under Linux) to automate that: https://github.com/vincent-picaud/Bazel_and_CompileCommands.



来源:https://stackoverflow.com/questions/32823625/bazel-build-verbose-compiler-commands-logging

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!