bazelbuild / bazelbuild/bazel

C++ host compile actions can conflict when --experimental_platform_in_output_dir is enabled

Open
#26,228 4 comments 0 reactions 1 assignee Claimed by @gregestren View on GitHub
team-Configurability type: bug untriaged
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 18h
Merged PRs (30d)
75

Description

### Description of the bug:

When `--experimental_platform_in_output_dir` is enabled, any C++ compile
actions targeting `@local_config_platform//:host` will conflict with identical
actions targeting `@platforms//host`.

### Which category does this issue belong to?

Configurability

### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

https://github.com/armandomontanez/bazel_reproducers/tree/main/action_conflicts_with_platform_name_in_out_dir

Summary:
```
cc_binary(
name = "data_binary",
srcs = ["main.cc"],
)

platform_data(
name = "explicit_host_binary",
# Note that today the default host platform is @bazel_tools//tools:host_platform
# which in turn is an alias pointing to @platforms//host.
platform = "@local_config_platform//:host",
target = ":data_binary",
)

py_binary(
name = "main_binary",
main = "outer.py",
srcs = ["outer.py"],
data = [
":data_binary",
":explicit_host_binary",
],
)
```

### Which operating system are you running Bazel on?

macOS/Linux

### What is the output of `bazel info release`?

release 8.1.0

### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.

_No response_

### What's the output of `git remote get-url origin; git rev-parse HEAD` ?

```text

```

### If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

_No response_

### Have you found anything relevant by searching the web?

_No response_

### Any other information, logs, or outputs that you want to share?

Example conflict:
```
ERROR: file '_objs/data_binary/main.o' is generated by these conflicting actions:
Label: //:data_binary
RuleClass: cc_binary rule
JavaActionClass: class com.google.devtools.build.lib.rules.cpp.CppCompileAction
Configuration: c80e5e0cf4f1be62db5504937d2ca971bc878717f37de07ce0f4f526e6bcd575, 1266988732fa9e033085170afb27b1844ac37e0321fb67d8ec9b375ebfc93f26
Mnemonic: CppCompile
Action key: 7dc6772ccd5192cbc39d0cc9e7e2b47cceb66fe50881d8e5b5904789885b71b5
Progress message: Compiling main.cc
Action describeKey: Compiling main.cc
Command: external/rules_cc++cc_configure_extension+local_config_cc/cc_wrapper.sh
Argument: -U_FORTIFY_SOURCE
Argument: -fstack-protector
Argument: -Wall
Argument: -Wthread-safety
Argument: -Wself-assign
Argument: -Wunused-but-set-parameter
Argument: -Wno-free-nonheap-object
Argument: -fcolor-diagnostics
Argument: -fno-omit-frame-pointer
Argument: '-std=c++17'
Argument: '-frandom-seed=bazel-out/darwin_x86_64-fastbuild/bin/_objs/data_binary/main.o'
Argument: '-mmacosx-version-min=10.11'
Argument: -MD
Argument: -MF
Argument: bazel-out/darwin_x86_64-fastbuild/bin/_objs/data_binary/main.d
Argument: -iquote
Argument: .
Argument: -iquote
Argument: bazel-out/darwin_x86_64-fastbuild/bin
Argument: -iquote
Argument: external/rules_cc+
Argument: -iquote
Argument: bazel-out/darwin_x86_64-fastbuild/bin/external/rules_cc+
Argument: -iquote
Argument: external/bazel_tools
Argument: -iquote
Argument: bazel-out/darwin_x86_64-fastbuild/bin/external/bazel_tools
Argument: -c
Argument: main.cc
Argument: -o
Argument: bazel-out/darwin_x86_64-fastbuild/bin/_objs/data_binary/main.o
Argument: -no-canonical-prefixes
Argument: -Wno-builtin-macro-redefined
Argument: '-D__DATE__="redacted"'
Argument: '-D__TIMESTAMP__="redacted"'
Argument: '-D__TIME__="redacted"'

PrimaryInput: File:[/Users/amontanez/development/projects/armandomontanez_github/bazel_reproducers/action_conflicts_with_platform_name_in_out_dir[source]]main.cc
PrimaryOutput: File:[[]bazel-out/darwin_x86_64-fastbuild/bin]_objs/data_binary/main.o
Owner information: ConfiguredTargetKey{label=//:data_binary, config=BuildConfigurationKey[c80e5e0cf4f1be62db5504937d2ca971bc878717f37de07ce0f4f526e6bcd575]}, ConfiguredTargetKey{label=//:data_binary, config=BuildConfigurationKey[1266988732fa9e033085170afb27b1844ac37e0321fb67d8ec9b375ebfc93f26]}
MandatoryInputs: are equal
Outputs: are equal
Use --verbose_failures to see the command lines of failed build steps.
ERROR: file '_objs/data_binary/main.o' is generated by these conflicting actions:
Label: //:data_binary
RuleClass: cc_binary rule
JavaActionClass: class com.google.devtools.build.lib.rules.cpp.CppCompileAction
Configuration: c80e5e0cf4f1be62db5504937d2ca971bc878717f37de07ce0f4f526e6bcd575, 1266988732fa9e033085170afb27b1844ac37e0321fb67d8ec9b375ebfc93f26
Mnemonic: CppCompile
Action key: 7dc6772ccd5192cbc39d0cc9e7e2b47cceb66fe50881d8e5b5904789885b71b5
Progress message: Compiling main.cc
Action describeKey: Compiling main.cc
Command: external/rules_cc++cc_configure_extension+local_config_cc/cc_wrapper.sh
Argument: -U_FORTIFY_SOURCE
Argument: -fstack-protector
Argument: -Wall
Argument: -Wthread-safety
Argument: -Wself-assign
Argument: -Wunused-but-set-parameter
Argument: -Wno-free-nonheap-object
Argument: -fcolor-diagnostics
Argument: -fno-omit-frame-pointer
Argument: '-std=c++17'
Argument: '-frandom-seed=bazel-out/darwin_x86_64-fastbuild/bin/_objs/data_binary/main.o'
Argument: '-mmacosx-version-min=10.11'
Argument: -MD
Argument: -MF
Argument: bazel-out/darwin_x86_64-fastbuild/bin/_objs/data_binary/main.d
Argument: -iquote
Argument: .
Argument: -iquote
Argument: bazel-out/darwin_x86_64-fastbuild/bin
Argument: -iquote
Argument: external/rules_cc+
Argument: -iquote
Argument: bazel-out/darwin_x86_64-fastbuild/bin/external/rules_cc+
Argument: -iquote
Argument: external/bazel_tools
Argument: -iquote
Argument: bazel-out/darwin_x86_64-fastbuild/bin/external/bazel_tools
Argument: -c
Argument: main.cc
Argument: -o
Argument: bazel-out/darwin_x86_64-fastbuild/bin/_objs/data_binary/main.o
Argument: -no-canonical-prefixes
Argument: -Wno-builtin-macro-redefined
Argument: '-D__DATE__="redacted"'
Argument: '-D__TIMESTAMP__="redacted"'
Argument: '-D__TIME__="redacted"'

PrimaryInput: File:[/Users/amontanez/development/projects/armandomontanez_github/bazel_reproducers/action_conflicts_with_platform_name_in_out_dir[source]]main.cc
PrimaryOutput: File:[[]bazel-out/darwin_x86_64-fastbuild/bin]_objs/data_binary/main.o
Owner information: ConfiguredTargetKey{label=//:data_binary, config=BuildConfigurationKey[c80e5e0cf4f1be62db5504937d2ca971bc878717f37de07ce0f4f526e6bcd575]}, ConfiguredTargetKey{label=//:data_binary, config=BuildConfigurationKey[1266988732fa9e033085170afb27b1844ac37e0321fb67d8ec9b375ebfc93f26]}
MandatoryInputs: are equal
Outputs: are equal
INFO: Elapsed time: 0.613s, Critical Path: 0.00s
INFO: 4 processes: 4 action cache hit, 4 internal.
ERROR: Build did NOT complete successfully
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.