镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

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

Closed

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?

Activity

  1. aignas commented on Apr 9, 2024

    @aignas
    Collaborator

    From the first glance I am not sure how this is gazelle plugin's problem.

    What kind of toolchains do you have cotfigured to build gazelle? I don't see anything about it in the repro.

  2. xytan0056 commented on Apr 10, 2024

    @xytan0056
    Author

    we just use normal golang toolchain https://github.com/xytan0056/cgo_test/blob/30a62b2654561f0d08e98dbf14c2e6a7c8d55e74/WORKSPACE#L193

    The problem is cross-compilation of gazelle works all good before enabling the python extension

  3. aignas commented on Apr 17, 2024

    @aignas
    Collaborator

    I think this is because we include a .zip file with the interpreter and the python code that parses the python files.

    The code in question is here: https://github.com/bazelbuild/rules_python/blob/4be00a69ae3a0c4e7ef3a5f952254bacd16d0a2a/gazelle/python/BUILD.bazel#L70

    @alexeagle has mentioned in a94deb8 that they may be working on a better version for their aspect-cli, but I am not sure if that was done and if it has, I am not sure if he has any plans (if it is feasible) on upstreaming the work to this repo.

    Note, that in #1485 we discussed about the effect of that change breaking cross-compilation, but I am not sure if it is documented in README.

  4. linzhp commented on Apr 17, 2024

    @linzhp
    Contributor

    Actually, the root cause is in py_binary, not the zip file. Created a separate ticket with reproduction: #1857.

  5. aignas commented on May 13, 2024

    @aignas
    Collaborator

    Closing this ticket as fixing #1857 would fix this as well.

  6. reopened this on May 15, 2024
  7. aignas commented on May 15, 2024

    @aignas
    Collaborator

    Re-opening because there is a PR that will address the cross-building of the gazelle plugin.

  8. added a commit that references this issue on May 20, 2024
    7fc7962
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions