We've been noticing that dynamically linked c++ executables are re-linked when we don't expect them to be. Header changes to libraries should trigger re-linking and do. However, it is not clear why source-only changes should require transitive downstream dependencies to re-link, though it seems they actually do so during a Bazel build. I have not found a reference in the documentation, nor any threads addressing this topic. We would appreciate clarification on whether this behavior is intended or configurable.
To demonstrate this behavior, we can use the cpp-tutorial/stage2 hello-world application in the bazel tutorials:
https://github.com/bazelbuild/examples/
Make the binary dynamic by adding "linkstatic=0" to the cc_binary rule. Change the string in hello-greet.cc, and the binary will re-link upon building //main:hello-world.
Subcommands show:
SUBCOMMAND: # //main:hello-greet [action 'Compiling main/hello-greet.cc']
SUBCOMMAND: # //main:hello-greet [action 'Linking main/libhello-greet.so']
SUBCOMMAND: # //main:hello-world [action 'Linking main/hello-world']
Explanations of rebuilds show:
Executing action 'BazelWorkspaceStatusAction stable-status.txt': unconditional execution is requested.
Executing action 'Compiling main/hello-greet.cc': One of the files has changed.
Executing action 'Linking main/libhello-greet.so': One of the files has changed.
Executing action 'SolibSymlink _solib_k8/libmain_Slibhello-greet.so': One of the files has changed.
Executing action 'Linking main/hello-world': One of the files has changed.
Since hello-greet.h wasn't changed, I think chain should have been able to stop after re-linking the shared library. This was done with 0.7.0
We'd appreciate your thoughts.