-
-
Notifications
You must be signed in to change notification settings - Fork 677
Closed
Labels
Description
🐞 bug report
Affected Rule
The issue is caused by the rule: py_binaryIs this a regression?
Yes, the previous version in which this bug was not present was: Bazel 6.3.2Description
Cross-compiling py_binary from macOS arm64 to either macOS amd64 or Linux amd64 break when using Bazel 7. It was working in Bazel 6.
Not sure if this bug report belongs here or Bazel. Let me know if I should move it to Bazel.
🔬 Minimal Reproduction
Run bazel build --incompatible_enable_cc_toolchain_resolution --platforms //:darwin_amd64 --enable_bzlmod //:hello in the following workspace with Bazel 7 and Bazel 6:
-- MODULE.bazel --
module(name = "cross_compliing")
bazel_dep(name = "rules_python", version = "0.31.0")
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
configure_coverage_tool = True,
ignore_root_user_error = True,
is_default = True,
python_version = "3.9",
)
-- WORKSPACE --
-- BUILD.bazel --
load("@rules_python//python:defs.bzl", "py_binary")
py_binary(
name = "hello",
srcs = ["hello.py"],
)
platform(
name = "darwin_amd64",
constraint_values = [
"@platforms//cpu:x86_64",
"@platforms//os:macos",
],
visibility = ["//visibility:public"],
)
platform(
name = "linux_amd64",
constraint_values = [
"@platforms//cpu:x86_64",
"@platforms//os:linux",
],
visibility = ["//visibility:public"],
)
-- hello.py --
if __name__ == "__main__":
print("hello world")
🔥 Exception or Error
ERROR: /private/var/tmp/_bazel_zplin/91d514326e938596854c0d93324b38ae/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: @@//:darwin_amd64, Exec platform: @@local_config_platform//:host
ERROR: /private/var/tmp/_bazel_zplin/91d514326e938596854c0d93324b38ae/external/bazel_tools/tools/cpp/BUILD:58:19: Analysis of target '@@bazel_tools//tools/cpp:current_cc_toolchain' failed
ERROR: Analysis of target '//:hello' failed; build aborted: Analysis failed
🌍 Your Environment
Operating System:
macOS Sonoma 14.4.1 on Apple M1 Max
Output of bazel version:
Build label: 7.1.1
Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
Build time: Thu Mar 21 18:08:59 2024 (1711044539)
Build timestamp: 1711044539
Build timestamp as int: 1711044539
Rules_python version:
bazel_dep(name = "rules_python", version = "0.31.0")
Anything else relevant?
The issue can be worked around with --noincompatible_enable_cc_toolchain_resolution in Bazel 7, although it worked in Bazel 6 with and without cc_toolchain resolution.
This is the root cause for #1825
Reactions are currently unavailable