Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No matching toolchains found for types @io_bazel_rules_go//go:toolchain #4053

Open
Boring545 opened this issue Aug 17, 2024 · 2 comments
Open

Comments

@Boring545
Copy link

Boring545 commented Aug 17, 2024

I am attempting to use rules_go and Bazel to compile a Go program on an operating system with a RISC-V CPU architecture, and I want to use the locally installed Go to compile the example project in rules_go. Unfortunately, when I tried running the test program, I encountered the following issue:

[zjq@openeuler-riscv-4-4 basic-gazelle]$ bazel run //:basic-gazelle --@io_bazel_rules_go//go/toolchain:sdk_version="host"
INFO: Build options --@io_bazel_rules_go//go/toolchain:sdk_version and --toolchain_resolution_debug have changed, discarding analysis cache.
ERROR: /home/zjq/bazel_test/rules_go/examples/basic-gazelle/BUILD.bazel:29:10: While resolving toolchains for target //:basic-gazelle: No matching toolchains found for types @io_bazel_rules_go//go:toolchain.
To debug, rerun with --toolchain_resolution_debug='@io_bazel_rules_go//go:toolchain'
If platforms or toolchains are a new concept for you, we'd encourage reading https://bazel.build/concepts/platforms-intro.
ERROR: Analysis of target '//:basic-gazelle' failed; build aborted:
INFO: Elapsed time: 12.347s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 212 targets configured)
ERROR: Build failed. Not running target

After investigating related issues, I found one that closely matches my problem: issue. It was resolved by adding the parameter "ppc64": "@platforms//cpu:ppc" to BAZEL_GOARCH_CONSTRAINTS in rules_go/go/private/platforms.bzl. Should I do something similar, such as adding "riscv64": "@platforms//cpu:riscv64"?

I also ran the command bazel run //:basic-gazelle --toolchain_resolution_debug='.*', and the output showed:

INFO: ToolchainResolution: Type @io_bazel_rules_go//go:toolchain: target platform @local_config_platform//:host: Rejected toolchain @go_sdk//:go_linux_riscv64-impl; mismatching values: riscv64.

Additionally, please note that I have set go_register_toolchains(go_version = "host") in the WORKSPACE file.

@Boring545
Copy link
Author

I successfully ran the example program using the command:
bazel run //:basic-gazelle --host_platform="@io_bazel_rules_go//go/toolchain:linux_riscv64" --platforms="@io_bazel_rules_go//go/toolchain:linux_riscv64".

@fmeum
Copy link
Member

fmeum commented Aug 18, 2024

Yes, feel free to send a PR adding a new entry to that dictionary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants