Skip to content

gazelle extension breaks cc toolchain resolution during cross compiling on darwin arm64 #1825

@xytan0056

Description

@xytan0056

🐞 bug report

Affected Rule

gazelle extension

Is this a regression?

No, previous versions also has this issue

Description

After enabling python extension in gazelle
https://github.com/xytan0056/cgo_test/blob/30a62b2654561f0d08e98dbf14c2e6a7c8d55e74/BUILD.bazel#L22

gazelle_binary(
    name = "gazelle_bin",
    languages = [
...
        "@com_github_bazelbuild_rules_python_gazelle//python",
    ]
)

We cannot cross compile gazelle on "darwin arm64" to "darwin amd64" with --incompatible_enable_cc_toolchain_resolution

🔬 Minimal Reproduction

https://github.com/xytan0056/cgo_test/tree/30a62b2654561f0d08e98dbf14c2e6a7c8d55e74

bazel build --announce_rc  //:gazelle_bin --platforms=@io_bazel_rules_go//go/toolchain:darwin_amd64 --incompatible_enable_cc_toolchain_resolution

fails

🔥 Exception or Error



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: @@io_bazel_rules_go//go/toolchain:darwin_amd64, Exec platform: @@local_config_platform//:host

The error is gone when either

  1. python extension is removed or
  2. CC toolchain resolution is disabled via --noincompatible_enable_cc_toolchain_resolution

🌍 Your Environment

Operating System:

  
uname -a
Darwin tanx-D5VYHJD2X7 23.4.0 Darwin Kernel Version 23.4.0: Wed Feb 21 21:44:43 PST 2024; root:xnu-10063.101.15~2/RELEASE_ARM64_T6000 arm64
  

Output of bazel version:

  
Bazelisk version: development
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:

  
v0.0.0-20240321125912-c5c03b2477dd
  

Anything else relevant?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions