bazel-contrib / rules_go

Go rules for Bazel
Apache License 2.0
1.38k stars 661 forks source link

In mixed programming language projects, cross-compile and use the same C++ toolchain #2591

Open yicm opened 4 years ago

yicm commented 4 years ago

What version of rules_go are you using?

v0.23.6

What version of gazelle are you using?

v0.21.1

What version of Bazel are you using?

Build label: 3.3.1
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Jun 30 15:09:23 2020 (1593529763)
Build timestamp: 1593529763
Build timestamp as int: 1593529763

Does this issue reproduce with the latest releases of all the above?

Yes

What operating system and processor architecture are you using?

$ echo $MACHTYPE
x86_64-pc-linux-gnu

Any other potentially useful information about your toolchain?

What did you do?

For a mixed project of C++ and Go, I want to achieve cross compilation, and the two programming languages share the C++ cross compilation toolchain. Is there a way to use the following commands to achieve one-time compilation? eg:

Able to compile successfully in two steps, but not share a compiler:

# build cpp language
$ bazel build --platforms=//platforms:custom_platform  //cpp
# build golang language
$ bazel build --platforms=@io_bazel_rules_go//go/toolchain:linux_arm //golang

I want to compile successfully in one step, and use the same compiler:

$ bazel build --platforms=//platforms:custom_platform  //...

Demo project: https://github.com/yicm/BazelMixedLanguage/

What did you expect to see?

build all success

What did you see instead?

ERROR: While resolving toolchains for target //golang/cmd/hello:hello: no matching toolchains found for types @io_bazel_rules_go//go:toolchain
ERROR: Analysis of target '//golang/cmd/hello:hello' failed; build aborted: no matching toolchains found for types @io_bazel_rules_go//go:toolchain
jayconrod commented 4 years ago

In general, this is expected to work. rules_go uses the platform and toolchain mechanism to select a Go toolchain, to configure GOOS and GOARCH, and to decide whether a C/C++ toolchain is needed for cgo or external linking. It shouldn't matter whether the C/C++ toolchain is configured with --cpu or --platforms; rules_go gets the same view of it either way. It just needs to match the target platform that rules_go expects.

The area where this gets a little tricky is setting up the platform definitions. The targets in @io_bazel_rules_go//go/platform are provided for convenience, but you can use your own. Whichever platform you use needs three constraint values:

I would guess the last constraint is missing from your platforms. Does --toolchain_resolution_debug give any useful output there?

I took a quick look at your example, but it's too large for me to read through it and audit for security in a reasonable amount of time. If you can give a more minimal example (like ~100 lines, no non-essential dependencies), I can take a look next week.

yicm commented 4 years ago

@jayconrod I added these three constraints to each custom native.platform, and then --toolchain_resolution_debug gave two results that matched ToolchainResolution. It seemed that toolchain toolchain @go_sdk//:go_linux_arm-impl... was selected first, and then custom toolchain toolchain //toolchains/cpp:ubuntu_arm_linux_gnueabihf_linux_arm_gcc_arm-linux-gnueabihf-_cc_toolchain.... The following is the complete compilation output information.

$ bazel build --platforms=//platforms:p_ubuntu_arm_linux_gnueabihf //golang/cmd/hello

output:

Loading:
Loading: 0 packages loaded
Analyzing: target //golang/cmd/hello:hello (1 packages loaded, 0 targets configured)
Analyzing: target //golang/cmd/hello:hello (14 packages loaded, 10 targets configured)
INFO: ToolchainResolution: Looking for toolchain of type @io_bazel_rules_go//go:toolchain...
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_aix_ppc64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:aix, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @io_bazel_rules_go//go/toolchain:ppc64, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_aix_ppc64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_android_386-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:android, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_32, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_android_386-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_android_amd64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:android, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_64, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_android_amd64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_android_arm-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:android, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_android_arm-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_android_arm64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:android, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:aarch64, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_android_arm64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_darwin_386-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:osx, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_32, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_darwin_386-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_darwin_amd64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:osx, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_64, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_darwin_amd64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_darwin_arm-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:osx, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_darwin_arm-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_darwin_arm64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:osx, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:aarch64, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_darwin_arm64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_dragonfly_amd64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:dragonfly, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_64, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_dragonfly_amd64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_freebsd_386-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:freebsd, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_32, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_freebsd_386-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_freebsd_amd64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:freebsd, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_64, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_freebsd_amd64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_freebsd_arm-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:freebsd, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_freebsd_arm-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_freebsd_arm64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:freebsd, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:aarch64, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_freebsd_arm64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_illumos_amd64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:illumos, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_64, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_illumos_amd64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_js_wasm-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:js, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @io_bazel_rules_go//go/toolchain:wasm, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_js_wasm-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_linux_386-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_32, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_linux_386-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_linux_amd64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_64, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_linux_amd64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_linux_arm-impl...
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_linux_arm64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:aarch64, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_linux_arm64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_linux_mips-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @io_bazel_rules_go//go/toolchain:mips, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_linux_mips-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_linux_mips64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @io_bazel_rules_go//go/toolchain:mips64, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_linux_mips64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_linux_mips64le-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @io_bazel_rules_go//go/toolchain:mips64le, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_linux_mips64le-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_linux_mipsle-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @io_bazel_rules_go//go/toolchain:mipsle, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_linux_mipsle-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_linux_ppc64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @io_bazel_rules_go//go/toolchain:ppc64, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_linux_ppc64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_linux_ppc64le-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:ppc, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_linux_ppc64le-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_linux_riscv64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @io_bazel_rules_go//go/toolchain:riscv64, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_linux_riscv64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_linux_s390x-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:s390x, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_linux_s390x-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_nacl_386-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:nacl, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_32, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_nacl_386-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_nacl_amd64p32-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:nacl, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @io_bazel_rules_go//go/toolchain:amd64p32, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_nacl_amd64p32-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_nacl_arm-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:nacl, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_nacl_arm-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_netbsd_386-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:netbsd, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_32, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_netbsd_386-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_netbsd_amd64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:netbsd, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_64, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_netbsd_amd64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_netbsd_arm-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:netbsd, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_netbsd_arm-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_netbsd_arm64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:netbsd, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:aarch64, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_netbsd_arm64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_openbsd_386-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:openbsd, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_32, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_openbsd_386-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_openbsd_amd64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:openbsd, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_64, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_openbsd_amd64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_openbsd_arm-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:openbsd, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_openbsd_arm-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_openbsd_arm64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:openbsd, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:aarch64, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_openbsd_arm64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_plan9_386-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:plan9, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_32, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_plan9_386-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_plan9_amd64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:plan9, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_64, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_plan9_amd64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_plan9_arm-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:plan9, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_plan9_arm-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_solaris_amd64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:solaris, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_64, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_solaris_amd64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_windows_386-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:windows, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_32, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_windows_386-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_windows_amd64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:windows, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_64, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_windows_amd64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_windows_arm-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:windows, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_windows_arm-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_ios_arm-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:ios, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_ios_arm-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_ios_arm64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:ios, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:aarch64, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_ios_arm64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_ios_386-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:ios, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_32, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_ios_386-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_ios_amd64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:ios, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_64, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_ios_amd64-impl, because of target platform mismatch
INFO: ToolchainResolution:   For toolchain type @io_bazel_rules_go//go:toolchain, possible execution platforms and toolchains: {@local_config_platform//:host -> @go_sdk//:go_linux_arm-impl}
INFO: ToolchainResolution: Selected execution platform @local_config_platform//:host, type @io_bazel_rules_go//go:toolchain -> toolchain @go_sdk//:go_linux_arm-impl
INFO: ToolchainResolution: Selected execution platform @local_config_platform//:host,
INFO: ToolchainResolution: Selected execution platform @local_config_platform//:host,
INFO: ToolchainResolution: Looking for toolchain of type @bazel_tools//tools/cpp:toolchain_type...
INFO: ToolchainResolution:   Considering toolchain //toolchains/cpp:ubuntu_gcc_linux_x86_64_gcc__cc_toolchain...
INFO: ToolchainResolution:     Toolchain constraint //platforms/devices:platform has value //platforms/devices:ubuntu_gcc, which does not match value //platforms/devices:ubuntu_arm_linux_gnueabihf from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_64, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain //toolchains/cpp:ubuntu_gcc_linux_x86_64_gcc__cc_toolchain, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain //toolchains/cpp:ubuntu_clang_linux_x86_64_clang__cc_toolchain...
INFO: ToolchainResolution:     Toolchain constraint //platforms/devices:platform has value //platforms/devices:ubuntu_clang, which does not match value //platforms/devices:ubuntu_arm_linux_gnueabihf from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_64, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain //toolchains/cpp:ubuntu_clang_linux_x86_64_clang__cc_toolchain, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain //toolchains/cpp:ubuntu_arm_linux_gnueabihf_linux_arm_gcc_arm-linux-gnueabihf-_cc_toolchain...
INFO: ToolchainResolution:   Considering toolchain @local_config_cc//:cc-compiler-armeabi-v7a...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:android, which does not match value @platforms//os:linux from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @local_config_cc//:cc-compiler-armeabi-v7a, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @local_config_cc//:cc-compiler-k8...
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_64, which does not match value @platforms//cpu:arm from the target platform //platforms:p_ubuntu_arm_linux_gnueabihf
INFO: ToolchainResolution:   Rejected toolchain @local_config_cc//:cc-compiler-k8, because of target platform mismatch
INFO: ToolchainResolution:   For toolchain type @bazel_tools//tools/cpp:toolchain_type, possible execution platforms and toolchains: {@local_config_platform//:host -> //toolchains/cpp:ubuntu_arm_linux_gnueabihf_linux_arm_gcc_arm-linux-gnueabihf-_cc_toolchain}
INFO: ToolchainResolution: Selected execution platform @local_config_platform//:host, type @bazel_tools//tools/cpp:toolchain_type -> toolchain //toolchains/cpp:ubuntu_arm_linux_gnueabihf_linux_arm_gcc_arm-linux-gnueabihf-_cc_toolchain
INFO: ToolchainResolution: Looking for toolchain of type @bazel_tools//tools/cpp:toolchain_type...
INFO: ToolchainResolution:   Considering toolchain //toolchains/cpp:ubuntu_gcc_linux_x86_64_gcc__cc_toolchain...
INFO: ToolchainResolution:     Toolchain constraint //platforms/devices:platform has value //platforms/devices:ubuntu_gcc, which does not match value <missing> from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain //toolchains/cpp:ubuntu_gcc_linux_x86_64_gcc__cc_toolchain, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain //toolchains/cpp:ubuntu_clang_linux_x86_64_clang__cc_toolchain...
INFO: ToolchainResolution:     Toolchain constraint //platforms/devices:platform has value //platforms/devices:ubuntu_clang, which does not match value <missing> from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain //toolchains/cpp:ubuntu_clang_linux_x86_64_clang__cc_toolchain, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain //toolchains/cpp:ubuntu_arm_linux_gnueabihf_linux_arm_gcc_arm-linux-gnueabihf-_cc_toolchain...
INFO: ToolchainResolution:     Toolchain constraint //platforms/devices:platform has value //platforms/devices:ubuntu_arm_linux_gnueabihf, which does not match value <missing> from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:arm, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain //toolchains/cpp:ubuntu_arm_linux_gnueabihf_linux_arm_gcc_arm-linux-gnueabihf-_cc_toolchain, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @local_config_cc//:cc-compiler-armeabi-v7a...
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:arm, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:android, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @local_config_cc//:cc-compiler-armeabi-v7a, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @local_config_cc//:cc-compiler-k8...
INFO: ToolchainResolution:   For toolchain type @bazel_tools//tools/cpp:toolchain_type, possible execution platforms and toolchains: {@local_config_platform//:host -> @local_config_cc//:cc-compiler-k8}
INFO: ToolchainResolution: Selected execution platform @local_config_platform//:host, type @bazel_tools//tools/cpp:toolchain_type -> toolchain @local_config_cc//:cc-compiler-k8
INFO: ToolchainResolution: Looking for toolchain of type @io_bazel_rules_go//go:toolchain...
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_aix_ppc64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:aix, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @io_bazel_rules_go//go/toolchain:ppc64, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_aix_ppc64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_android_386-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:android, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_32, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_android_386-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_android_amd64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:android, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_android_amd64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_android_arm-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:android, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:arm, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_android_arm-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_android_arm64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:android, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:aarch64, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_android_arm64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_darwin_386-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:osx, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_32, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_darwin_386-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_darwin_amd64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:osx, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_darwin_amd64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_darwin_arm-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:osx, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:arm, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_darwin_arm-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_darwin_arm64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:osx, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:aarch64, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_darwin_arm64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_dragonfly_amd64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:dragonfly, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_dragonfly_amd64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_freebsd_386-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:freebsd, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_32, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_freebsd_386-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_freebsd_amd64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:freebsd, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_freebsd_amd64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_freebsd_arm-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:freebsd, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:arm, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_freebsd_arm-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_freebsd_arm64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:freebsd, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:aarch64, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_freebsd_arm64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_illumos_amd64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:illumos, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_illumos_amd64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_js_wasm-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:js, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @io_bazel_rules_go//go/toolchain:wasm, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_js_wasm-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_linux_386-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_32, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_linux_386-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_linux_amd64-impl...
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_linux_arm-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:arm, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_linux_arm-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_linux_arm64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:aarch64, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_linux_arm64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_linux_mips-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @io_bazel_rules_go//go/toolchain:mips, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_linux_mips-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_linux_mips64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @io_bazel_rules_go//go/toolchain:mips64, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_linux_mips64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_linux_mips64le-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @io_bazel_rules_go//go/toolchain:mips64le, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_linux_mips64le-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_linux_mipsle-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @io_bazel_rules_go//go/toolchain:mipsle, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_linux_mipsle-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_linux_ppc64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @io_bazel_rules_go//go/toolchain:ppc64, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_linux_ppc64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_linux_ppc64le-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:ppc, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_linux_ppc64le-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_linux_riscv64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @io_bazel_rules_go//go/toolchain:riscv64, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_linux_riscv64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_linux_s390x-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:s390x, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_linux_s390x-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_nacl_386-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:nacl, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_32, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_nacl_386-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_nacl_amd64p32-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:nacl, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @io_bazel_rules_go//go/toolchain:amd64p32, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_nacl_amd64p32-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_nacl_arm-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:nacl, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:arm, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_nacl_arm-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_netbsd_386-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:netbsd, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_32, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_netbsd_386-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_netbsd_amd64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:netbsd, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_netbsd_amd64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_netbsd_arm-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:netbsd, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:arm, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_netbsd_arm-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_netbsd_arm64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:netbsd, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:aarch64, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_netbsd_arm64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_openbsd_386-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:openbsd, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_32, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_openbsd_386-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_openbsd_amd64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:openbsd, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_openbsd_amd64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_openbsd_arm-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:openbsd, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:arm, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_openbsd_arm-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_openbsd_arm64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:openbsd, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:aarch64, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_openbsd_arm64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_plan9_386-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:plan9, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_32, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_plan9_386-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_plan9_amd64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:plan9, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_plan9_amd64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_plan9_arm-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:plan9, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:arm, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_plan9_arm-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_solaris_amd64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @io_bazel_rules_go//go/toolchain:solaris, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_solaris_amd64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_windows_386-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:windows, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_32, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_windows_386-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_windows_amd64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:windows, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_windows_amd64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_windows_arm-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:windows, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:arm, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_windows_arm-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_ios_arm-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:ios, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:arm, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_ios_arm-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_ios_arm64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:ios, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:aarch64, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_ios_arm64-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_ios_386-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:ios, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:x86_32, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_ios_386-impl, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @go_sdk//:go_ios_amd64-impl...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:ios, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @go_sdk//:go_ios_amd64-impl, because of target platform mismatch
INFO: ToolchainResolution:   For toolchain type @io_bazel_rules_go//go:toolchain, possible execution platforms and toolchains: {@local_config_platform//:host -> @go_sdk//:go_linux_amd64-impl}
INFO: ToolchainResolution: Selected execution platform @local_config_platform//:host, type @io_bazel_rules_go//go:toolchain -> toolchain @go_sdk//:go_linux_amd64-impl
INFO: ToolchainResolution: Selected execution platform @local_config_platform//:host,
INFO: ToolchainResolution: Looking for toolchain of type @bazel_tools//tools/cpp:toolchain_type...
INFO: ToolchainResolution:   Considering toolchain //toolchains/cpp:ubuntu_gcc_linux_x86_64_gcc__cc_toolchain...
INFO: ToolchainResolution:     Toolchain constraint //platforms/devices:platform has value //platforms/devices:ubuntu_gcc, which does not match value <missing> from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain //toolchains/cpp:ubuntu_gcc_linux_x86_64_gcc__cc_toolchain, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain //toolchains/cpp:ubuntu_clang_linux_x86_64_clang__cc_toolchain...
INFO: ToolchainResolution:     Toolchain constraint //platforms/devices:platform has value //platforms/devices:ubuntu_clang, which does not match value <missing> from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain //toolchains/cpp:ubuntu_clang_linux_x86_64_clang__cc_toolchain, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain //toolchains/cpp:ubuntu_arm_linux_gnueabihf_linux_arm_gcc_arm-linux-gnueabihf-_cc_toolchain...
INFO: ToolchainResolution:     Toolchain constraint //platforms/devices:platform has value //platforms/devices:ubuntu_arm_linux_gnueabihf, which does not match value <missing> from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:arm, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain //toolchains/cpp:ubuntu_arm_linux_gnueabihf_linux_arm_gcc_arm-linux-gnueabihf-_cc_toolchain, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @local_config_cc//:cc-compiler-armeabi-v7a...
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:arm, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:android, which does not match value @platforms//os:linux from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain @local_config_cc//:cc-compiler-armeabi-v7a, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @local_config_cc//:cc-compiler-k8...
INFO: ToolchainResolution:   For toolchain type @bazel_tools//tools/cpp:toolchain_type, possible execution platforms and toolchains: {@local_config_platform//:host -> @local_config_cc//:cc-compiler-k8}
INFO: ToolchainResolution: Selected execution platform @local_config_platform//:host, type @bazel_tools//tools/cpp:toolchain_type -> toolchain @local_config_cc//:cc-compiler-k8
Analyzing: target //golang/cmd/hello:hello (39 packages loaded, 6802 targets configured)
Analyzing: target //golang/cmd/hello:hello (39 packages loaded, 6802 targets configured)
INFO: Analyzed target //golang/cmd/hello:hello (67 packages loaded, 7248 targets configured).
INFO: Found 1 target...
[0 / 4] [Prepa] BazelWorkspaceStatusAction stable-status.txt
[6 / 38] checking cached actions
Target //golang/cmd/hello:hello up-to-date:
  bazel-bin/golang/cmd/hello/hello_/hello
INFO: Elapsed time: 8.660s, Critical Path: 2.70s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
jayconrod commented 4 years ago

Looks like it selected both toolchains and the build succeeded. Any other problems or should this issue be closed?

yicm commented 4 years ago

@jayconrod But only one binary file is generated, and it is not generated by the compiler I want, how do I control only the toolchain I want?

jayconrod commented 4 years ago

What other binaries did you expect to be generated? The command line bazel build --platforms=//platforms:p_ubuntu_arm_linux_gnueabihf //golang/cmd/hello only names one target, so I'd only expect to see the Go binary generated there.

What Go compiler did you expect it to use? It says it selected @go_sdk//:go_linux_arm-impl for the target configuration, which seems correct.

What C compiler did you expect it to use? It says it selected //toolchains/cpp:ubuntu_arm_linux_gnueabihf_linux_arm_gcc_arm-linux-gnueabihf-_cc_toolchain for the target configuration. That also seems correct.

Your go_binary doesn't seem to contain any cgo code and isn't built in a way that would require external linking, so it should be configured to use the C compiler (CGO_ENABLED=1 and CC will be set for each action), but I don't think it will actually be used.

Are you able to build a cc_binary in this configuration?

yicm commented 4 years ago

@jayconrod Maybe I didn't make it clear, because at the end two prompts of successful compilation were output.

INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action

How do I know which compiler was selected from the debugging information of --toolchain_resolution_debug? I tested it and the binary file generated by the compilation is always the compiler bound to the platform I set, which meets my needs. I am just confused why more than one compiler is matched. In addition, I also tested whether CGO is turned on and off, and everything is normal.

jayconrod commented 4 years ago

Maybe I didn't make it clear, because at the end two prompts of successful compilation were output.

Not sure why that line is printed twice. Doesn't seem like a problem though?

How do I know which compiler was selected from the debugging information of --toolchain_resolution_debug? I tested it and the binary file generated by the compilation is always the compiler bound to the platform I set, which meets my needs. I am just confused why more than one compiler is matched. In addition, I also tested whether CGO is turned on and off, and everything is normal.

Look for lines containing the word "Selected" in the --toolchain_resolution_debug output. These lines say which toolchain was selected for each toolchain type. The surrounding lines add context.

INFO: ToolchainResolution: Selected execution platform @local_config_platform//:host, type @io_bazel_rules_go//go:toolchain -> toolchain @go_sdk//:go_linux_arm-impl
INFO: ToolchainResolution: Selected execution platform @local_config_platform//:host, type @bazel_tools//tools/cpp:toolchain_type -> toolchain //toolchains/cpp:ubuntu_arm_linux_gnueabihf_linux_arm_gcc_arm-linux-gnueabihf-_cc_toolchain
INFO: ToolchainResolution: Selected execution platform @local_config_platform//:host, type @bazel_tools//tools/cpp:toolchain_type -> toolchain @local_config_cc//:cc-compiler-k8
INFO: ToolchainResolution: Selected execution platform @local_config_platform//:host, type @io_bazel_rules_go//go:toolchain -> toolchain @go_sdk//:go_linux_amd64-impl
INFO: ToolchainResolution: Selected execution platform @local_config_platform//:host, type @bazel_tools//tools/cpp:toolchain_type -> toolchain @local_config_cc//:cc-compiler-k8

Bazel considers three platforms when selecting toolchains: host (where Bazel runs), execution (where actions run), and target (where your binaries should run). It will attempt to select one toolchain of each type for each platform where it's required.

This shows that Go and C toolchains are selected for the execution and target platforms. A C toolchain is also selected for the host platform.

I can't speak for C, but Go often needs separate toolchains for execution and target in order to build code generation or analysis tools like protoc-gen-go. Although there are different toolchains as far as Bazel is considered, they're actually the same compiler / linker binaries, just with different GOOS / GOARCH settings. Bazel doesn't tell us any information about the target platform, so we have to infer that from the toolchain that gets selected.

yicm commented 4 years ago

@jayconrod Please forgive me for persisting to the bottom of the matter ^_^.

Not sure why that line is printed twice. Doesn't seem like a problem though?

I only know that the compilation completion event is triggered twice here, but I don't know why it is triggered twice

Bazel considers three platforms when selecting toolchains......

I am even more confused 😕😖. I know from the official documentation that the host platform is automatically selected based on @local_config_platform//:host, and it only indicates the platform on which the binary file Bazel runs. My current build scenario is a Cross-compilation builds scenario, it means that the host and the execution platform are the same, but the target platform is different.

A C toolchain is also selected for the host platform.

The host platform I understand is just an environment for running the bazel binary, and has nothing to do with the specific build toolchain, as can be seen from the parameters of the toolchain(... exec_compatible_with, target_compatible_with, toolchain, toolchain_type ...) rule.

This shows that Go and C toolchains are selected for the execution and target platforms.

INFO: ToolchainResolution: Selected execution platform @local_config_platform//:host, type @io_bazel_rules_go//go:toolchain -> toolchain @go_sdk//:go_linux_arm-impl
INFO: ToolchainResolution: Selected execution platform @local_config_platform//:host, type @bazel_tools//tools/cpp:toolchain_type -> toolchain //toolchains/cpp:ubuntu_arm_linux_gnueabihf_linux_arm_gcc_arm-linux-gnueabihf-_cc_toolchain
INFO: ToolchainResolution: Selected execution platform @local_config_platform//:host, type @bazel_tools//tools/cpp:toolchain_type -> toolchain @local_config_cc//:cc-compiler-k8
INFO: ToolchainResolution: Selected execution platform @local_config_platform//:host, type @io_bazel_rules_go//go:toolchain -> toolchain @go_sdk//:go_linux_amd64-impl
INFO: ToolchainResolution: Selected execution platform @local_config_platform//:host, type @bazel_tools//tools/cpp:toolchain_type -> toolchain @local_config_cc//:cc-compiler-k8

Is the execution platform here related to the target_compatible_with parameter of the toolchain rule? I call it like this in the actual sample.

Interestingly, I actually tested and found that if the execution platform constraint OS of rule toolchain() is inconsistent with the host platform OS, the Go target can be compiled successfully, but the C++ target will fail.

native.toolchain(
    name = toolchain_name,         
    exec_compatible_with = [
        # change the OS constraint value in here
        "@platforms//os:%s" % bazel_exec_platform_info["os"],
        "@platforms//cpu:%s" % bazel_exec_platform_info["cpu"],
    ],
    target_compatible_with = [
        "//platforms/devices:%s" % platform,
        "@platforms//os:%s" % target_os,
        "@platforms//cpu:%s" % target_arch,
        "@io_bazel_rules_go//go/toolchain:cgo_%s" % target_cgo,
    ],
    toolchain = "//toolchains/cpp:%s" % cc_name,
    toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)

Finally, back to the original point, I may still not understand the toolchain rule and the toolchain selection here and the relevance of the three types of platforms. Is there a better reference or a simpler way to understand it?

jayconrod commented 4 years ago

My current build scenario is a Cross-compilation builds scenario, it means that the host and the execution platform are the same, but the target platform is different.

Right. Bazel still separates host and execution though, even when they're identical. The same toolchain will be selected for both.

Is the execution platform here related to the target_compatible_with parameter of the toolchain rule?

No, toolchain has two sets of constraints: exec_compatible_with is used to match the execution platform, and target_compatible_with is used to match the target platform. The terminology here is with respect to an action, not the overall build. For example, let's say you're cross-compiling from linux_amd64 to windows_amd64, and as part of the build, you need to build a binary for code generation. The toolchain used to build that binary will be selected with both execution and target platform linux_amd64.

Interestingly, I actually tested and found that if the execution platform constraint OS of rule toolchain() is inconsistent with the host platform OS, the Go target can be compiled successfully, but the C++ target will fail.

I'm a little surprised either build would work. Depends a lot on the exact setup though.

Finally, back to the original point, I may still not understand the toolchain rule and the toolchain selection here and the relevance of the three types of platforms. Is there a better reference or a simpler way to understand it?

I wrote Writing Bazel rules: platforms and toolchains a while ago. Might be useful as an example, but it sounds like you already know most of it. The bazel-discuss mailing list is another good place to ask.

yicm commented 4 years ago

@jayconrod

I wrote Writing Bazel rules: platforms and toolchains a while ago. Might be useful as an example, but it sounds like you already know most of it. The bazel-discuss mailing list is another good place to ask.

Yes, I basically know everything in this article. I want to wait for a thorough understanding before going to the bazel-discuss mailing list to ask new questions.

I'm a little surprised either build would work. Depends a lot on the exact setup though.

I carefully analyzed the information printed when the --toolchain_resolution_debug debugging command parameter is turned on in the two cases:

Conditions:

native.platform(           
    name = "p_%s" % target_platform,
    constraint_values = [
        "//platforms/devices:%s" % target_platform,
        # needs three constraint values in rules_go for cross-compile   
        "@platforms//os:%s" % target_os,
        "@platforms//cpu:%s" % target_arch,
        "@io_bazel_rules_go//go/toolchain:cgo_%s" % target_cgo,            
    ],
    visibility = ["//visibility:public"],
)

native.toolchain(
    name = toolchain_name,         
    exec_compatible_with = [
        # change the OS constraint value in here
        "@platforms//os:macos",
        "@platforms//cpu:x86_64",
    ],
    target_compatible_with = [
        "//platforms/devices:%s" % device,
        "@platforms//os:%s" % target_os,
        "@platforms//cpu:%s" % target_arch,
        "@io_bazel_rules_go//go/toolchain:cgo_%s" % target_cgo,
    ],
    toolchain = "//toolchains/cpp:%s" % cc_name,
    toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)
# ① build failed
$ bazel build --platforms=//platforms:p_ubuntu_arm_linux_gnueabihf //cpp/hello-world
# ② build success
$ bazel build --platforms=//platforms:p_ubuntu_arm_linux_gnueabihf //golang/cmd/hello

Outputs:

INFO: ToolchainResolution:   Considering toolchain //toolchains/cpp:ubuntu_arm_linux_gnueabihf_linux_arm_gcc_arm-linux-gnueabihf-_cc_toolchain...
INFO: ToolchainResolution:     Toolchain constraint @platforms//os:os has value @platforms//os:osx, which does not match value @platforms//os:linux from the execution platform @local_config_platform//:host

INFO: ToolchainResolution:   Considering toolchain //toolchains/cpp:ubuntu_arm_linux_gnueabihf_linux_arm_gcc_arm-linux-gnueabihf-_cc_toolchain...
INFO: ToolchainResolution:     Toolchain constraint //platforms/devices:platform has value //platforms/devices:ubuntu_arm_linux_gnueabihf, which does not match value <missing> from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @platforms//cpu:cpu has value @platforms//cpu:arm, which does not match value @platforms//cpu:x86_64 from the target platform @local_config_platform//:host
INFO: ToolchainResolution:     Toolchain constraint @io_bazel_rules_go//go/toolchain:cgo_constraint has value @io_bazel_rules_go//go/toolchain:cgo_off, which does not match value <missing> from the target platform @local_config_platform//:host
INFO: ToolchainResolution:   Rejected toolchain //toolchains/cpp:ubuntu_arm_linux_gnueabihf_linux_arm_gcc_arm-linux-gnueabihf-_cc_toolchain, because of target platform mismatch

......

INFO: ToolchainResolution: Selected execution platform @local_config_platform//:host, type @io_bazel_rules_go//go:toolchain -> toolchain @go_sdk//:go_linux_arm-impl

......

INFO: ToolchainResolution: Selected execution platform @local_config_platform//:host, type @io_bazel_rules_go//go:toolchain -> toolchain @go_sdk//:go_linux_amd64-impl

My analysis:

I don’t know if I clarified my confusion this time. ^_^

jayconrod commented 4 years ago

For (1), I'm guessing here, but perhaps the build requires some tool built with the C toolchain, and the tool needs to run on the execution platform? So from the perspective of the actions that generate that tool, the action's target platform is the execution platform. If that's the case, you'd need multiple C toolchains registered, one which generates code for the target platform and one which generates code for the execution platform.

For (2), sorry, I don't know the toolchain resolution logic well enough to answer that without firing up a debugger. The mailing list may be able to help more than I can. If you're feeling adventurous, SingleToolchainResolutionFunction.java seems to be the file where those messages are printed.

yicm commented 4 years ago

Thank you for the discussion ^_^ . I will continue to dig deeper and try to understand.