拒绝的go_darwin_arm64不匹配值:x86_64

发布于 2025-02-10 21:43:27 字数 2031 浏览 1 评论 0原文

我正在尝试在蒙特雷上的MacBook Pro M1上工作Bazel构建,而且我度过了艰难的时期。当我尝试构建Docker映像时,我会获得GO工具链错误(使用-toolchain_resolution_debug ='go'),看起来像这样:

INFO: ToolchainResolution:     Type @io_bazel_rules_go//go:toolchain: target platform @local_config_platform//:host: Rejected toolchain @go-auto//:go_darwin_amd64-impl; mismatching values: x86_64
INFO: ToolchainResolution:     Type @io_bazel_rules_go//go:toolchain: target platform @local_config_platform//:host: Rejected toolchain @go-auto//:go_darwin_arm-impl; mismatching values: arm
INFO: ToolchainResolution:     Type @io_bazel_rules_go//go:toolchain: execution platform @local_config_platform//:host: Rejected toolchain @go-auto//:go_darwin_arm64-impl; mismatching values: x86_64

为什么它说它拒绝ARM64实现,因为它不是x86_64?似乎这里有些东西破了。

作为参考,这是Bazel版本

Bazelisk version: development
Build label: 5.2.0
Build target: bazel-out/darwin_arm64-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Jun 7 16:11:09 2022 (1654618269)
Build timestamp: 1654618269
Build timestamp as int: 1654618269

以及我的工作区中的一些相关位:

http_archive(
    name = "io_bazel_rules_docker",
    sha256 = "b1e80761a8a8243d03ebca8845e9cc1ba6c82ce7c5179ce2b295cd36f7e394bf",
    urls = ["https://github.com/bazelbuild/rules_docker/releases/download/v0.25.0/rules_docker-v0.25.0.tar.gz"],
)

...

load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
git_repository(
    name = "io_bazel_rules_k8s",
    remote = "https://github.com/bazelbuild/rules_k8s.git",
    # branch = "master",
    commit = "fee80eb69e1921c076167ebebcf5eea3d2e9c707",
    shallow_since = "1655492445 -0700",
)

load("@io_bazel_rules_k8s//k8s:k8s.bzl", "k8s_repositories")

k8s_repositories()


load("@io_bazel_rules_go//go:deps.bzl", "go_download_sdk", "go_register_toolchains", "go_rules_dependencies")

go_rules_dependencies()

go_register_toolchains()

go_download_sdk(
    name = "go-auto",
)

I'm trying to get a Bazel build working on my MacBook Pro M1 on Monterey, and I'm having a difficult time. When I try to build a docker image, I get go toolchain errors (with --toolchain_resolution_debug='go') that look like this:

INFO: ToolchainResolution:     Type @io_bazel_rules_go//go:toolchain: target platform @local_config_platform//:host: Rejected toolchain @go-auto//:go_darwin_amd64-impl; mismatching values: x86_64
INFO: ToolchainResolution:     Type @io_bazel_rules_go//go:toolchain: target platform @local_config_platform//:host: Rejected toolchain @go-auto//:go_darwin_arm-impl; mismatching values: arm
INFO: ToolchainResolution:     Type @io_bazel_rules_go//go:toolchain: execution platform @local_config_platform//:host: Rejected toolchain @go-auto//:go_darwin_arm64-impl; mismatching values: x86_64

Why does it say it rejects an arm64 implementation because it's not x86_64? It seems like there's something broken here.

For reference, here's bazel version:

Bazelisk version: development
Build label: 5.2.0
Build target: bazel-out/darwin_arm64-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Jun 7 16:11:09 2022 (1654618269)
Build timestamp: 1654618269
Build timestamp as int: 1654618269

And some relevant bits from my WORKSPACE:

http_archive(
    name = "io_bazel_rules_docker",
    sha256 = "b1e80761a8a8243d03ebca8845e9cc1ba6c82ce7c5179ce2b295cd36f7e394bf",
    urls = ["https://github.com/bazelbuild/rules_docker/releases/download/v0.25.0/rules_docker-v0.25.0.tar.gz"],
)

...

load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
git_repository(
    name = "io_bazel_rules_k8s",
    remote = "https://github.com/bazelbuild/rules_k8s.git",
    # branch = "master",
    commit = "fee80eb69e1921c076167ebebcf5eea3d2e9c707",
    shallow_since = "1655492445 -0700",
)

load("@io_bazel_rules_k8s//k8s:k8s.bzl", "k8s_repositories")

k8s_repositories()


load("@io_bazel_rules_go//go:deps.bzl", "go_download_sdk", "go_register_toolchains", "go_rules_dependencies")

go_rules_dependencies()

go_register_toolchains()

go_download_sdk(
    name = "go-auto",
)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北城挽邺 2025-02-17 21:43:27

如果您想在ARM上为Linux X86_64构建,则- platforms =@io_bazel_rules_go // go/toolchain:linux_amd64对我有用。 X86容器将在手臂机上的仿真中运行。

您可能可以使用工具链来定位ARM Linux容器:Linux_arm64

If you'd like to build for linux x86_64 on arm, --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 works for me. The x86 container will run in emulation on the arm machine.

You could probably target an arm linux container with toolchain:linux_arm64

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文