bazelbuild / rules_apple

Bazel rules to build apps for Apple platforms.
Apache License 2.0
512 stars 269 forks source link

`target_compatible_with` appears to be broken in Bazel 7.x #2442

Open jpsim opened 7 months ago

jpsim commented 7 months ago

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.

c16a commented 5 months ago

Just tried to reproduce this and yes it's broken. Seems like the ios_application, watchos_application work, though.