Search code examples
bazel

Bazel action graph middleman mnemonic in actions


I am using Bazel action graph to see what happens behind the scenes. I am using V1 (analysis.proto) and the graph seems complete and everything makes sense except for actions with "Middleman" mnemonic. I have looked everywhere and there is no mention of this mnemonic. The mnemonic itself is very strange because it does not do anything concrete. I have pasted a version of the graph below:

artifacts {
  id: "0"
  exec_path: "bazel-out/k8-fastbuild/internal/_middlemen/_S_Smain_Chello-greet-BazelCppSemantics_build_arch_k8-fastbuild"
}
artifacts {
  id: "1"
  exec_path: "bazel-out/k8-fastbuild/internal/_middlemen/_S_Smain_Chello-world-BazelCppSemantics_build_arch_k8-fastbuild"
}
actions {
  target_id: "0"
  action_key: "db9e25a4399752c6f2173101cef156d8cc65052294fbaae629f895aa7120c672"
  mnemonic: "Middleman"
  configuration_id: "0"
  input_dep_set_ids: "0"
  output_ids: "1"
}

In the action, the input and output point to the same file. What does "Middleman" mnemonic do and in general what is the purpose of mnemonic tag?


Solution

  • All actions have a mnemonic, which is a type of categorization.

    Middlemen are special actions internally generated by Bazel. A middleman action does nothing but force its inputs to be built.