Compare Bazel execlogs to find non-deterministic parts of the build
Recently I was wondering why a part of my application is getting rebuilt even though the sources are seemingly the same. Passing
--verbose_explanations didn’t help, as I can’t see the exact source being changed (BTW, these options apparently being quietly retired).
execlog to the rescue! First, make sure you build this tool from the Bazel tree.
Then, the idea is to make two builds of your product with execution logs enabled:
bazel build --experimental_execution_log_file=exec-1.log ... bazel build --experimental_execution_log_file=exec-2.log ...
And then generate textual represenations of the actions done using
path/to/execlog/parser --log_path=/tmp/exec-1.log --log_path=/tmp/exec-2.log --output_path=/tmp/exec-1.log.txt --output_path=/tmp/exec-2.log.txt
(As mentioned in the README, you have to convert the two files together, to guarantee the same ordering)
Then, since the two files are correctly ordered,
exec-2.log.txt will show you what exactly has changed.