bazelbuild / bazelbuild/rules_apple
`target_compatible_with` appears to be broken in Bazel 7.x
- Dominant language
- Starlark
- Stars
- 593
- Forks
- 334
- Avg merge
- 16h 48m
- Merged PRs (30d)
- 9
Description
The `macos_build_test` `target_compatible_with` field appears to no longer work as of Bazel 7.x.
## Repro steps
```
$ docker run -it --rm swift:5.10 bash
$$ apt-get update && apt-get install -y curl
$$ curl -O -L https://github.com/bazelbuild/bazelisk/releases/download/v1.19.0/bazelisk-linux-arm64
$$ chmod +x bazelisk-linux-arm64
$$ mv bazelisk-linux-arm64 /usr/local/bin/bazel
$$ git clone https://github.com/jpsim/Yams.git
$$ cd Yams
$$ git checkout 5.1.1
$$ bazel build //Tests/...
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
ERROR: /root/.cache/bazel/_bazel_root/6e1a49d43c4d1802da03fcf367427d33/external/bazel_tools/tools/cpp/BUILD:58:19: in cc_toolchain_alias rule @@bazel_tools//tools/cpp:current_cc_toolchain:
Traceback (most recent call last):
File "/virtual_builtins_bzl/common/cc/cc_toolchain_alias.bzl", line 26, column 48, in _impl
File "/virtual_builtins_bzl/common/cc/cc_helper.bzl", line 219, column 17, in _find_cpp_toolchain
Error in fail: Unable to find a CC toolchain using toolchain resolution. Target: @@bazel_tools//tools/cpp:current_cc_toolchain, Platform: @@apple_support~//platforms:macos_x86_64, Exec platform: @@local_config_platform//:host
ERROR: /root/.cache/bazel/_bazel_root/6e1a49d43c4d1802da03fcf367427d33/external/bazel_tools/tools/cpp/BUILD:58:19: Analysis of target '@@bazel_tools//tools/cpp:current_cc_toolchain' failed
ERROR: Analysis of target '//Tests:macOSBuildTest' failed; build aborted: Analysis failed
INFO: Elapsed time: 6.366s, Critical Path: 0.02s
INFO: 2 processes: 1 internal, 1 processwrapper-sandbox.
ERROR: Build did NOT complete successfully
FAILED:
Fetching repository @@rules_swift~~non_module_deps~build_bazel_rules_swift_local_config; starting
Fetching repository @@bazel_tools~cc_configure_extension~local_config_cc; starting
```
This worked with Bazel 6.x.
Contributor guide
Research direction
Start by reproducing the failure with the Docker commands in the issue, using the Yams 5.1.1 checkout and `bazel build //Tests/...`. Investigate the `macos_build_test` `target_compatible_with` handling and compare Bazel 6.x with Bazel 7.x behavior; done means the incompatible macOS target is handled correctly without the reported toolchain-resolution failure.
Written by the indexing model from the issue text.
Assessment
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100