This repo demonstrates an issue with using the --host_action_env
flag
The gen
rule defined in gen/gen.bzl
generates a Go file and uses the NAME
environment variable to do so.
The //foo:foogen
target of rule type gen
is then a transitive dependency of the gomock
macro.
For context, Gomock functions by compiling a program that uses reflect to generate a mock file.
This program is build using the exec
config, including its dependency on //foo:foogen
.
The gomock
and go_test
targets aren't relevant, I'm only using them to get the gen
rule to build using the exec
config.
If we removed the --host_action_env
flag in .bazelrc
, the build will fail due to the missing environment variable.
If we did not, then the analysis phase fails with lots of errors that look like:
ERROR: file 'external/local_config_cc/watchos_x86_64.runfiles/MANIFEST' is generated by these conflicting actions:
Label: @local_config_cc//:watchos_x86_64
RuleClass: cc_toolchain_config rule
Configuration: 37b165abd5e81d1b92cc3cf13161485911327d1748f8400a07ac5192ec0539ea, 69e0c6652a1e6a217cbd640bbe8a32564b21e12b34f119ff485b45bdd608a1ce
Mnemonic: SymlinkTree
Action key: 62b7ca27cfaf7ba6883a5230e0a3305fb51091151ceacc2054523622e4a2df88, bf2d97f004755ac8886337b9dc0d50cb0348df2301ed7978e49a3684842d90bb
Progress message: Creating runfiles tree bazel-out/darwin-opt-exec-2B5CBBC6/bin/external/local_config_cc/watchos_x86_64.runfiles
PrimaryInput: File:[[<execution_root>]bazel-out/darwin-opt-exec-2B5CBBC6/bin]external/local_config_cc/watchos_x86_64.runfiles_manifest
PrimaryOutput: File:[[<execution_root>]bazel-out/darwin-opt-exec-2B5CBBC6/bin]external/local_config_cc/watchos_x86_64.runfiles/MANIFEST
Owner information: ConfiguredTargetKey{label=@local_config_cc//:watchos_x86_64, config=BuildConfigurationValue.Key[37b165abd5e81d1b92cc3cf13161485911327d1748f8400a07ac5192ec0539ea]}, ConfiguredTargetKey{label=@local_config_cc//:watchos_x86_64, config=BuildConfigurationValue.Key[69e0c6652a1e6a217cbd640bbe8a32564b21e12b34f119ff485b45bdd608a1ce]}
MandatoryInputs: are equal
Outputs: are equal
WARNING: errors encountered while analyzing target '@local_config_cc//:watchos_x86_64': it will not be built