Why is target platform @local_config_platform//:host even when I set --platforms?

822 views
Skip to first unread message

Shuai Shao

unread,
Sep 15, 2022, 4:14:15 PM9/15/22
to bazel-...@googlegroups.com
Hi,

We have set up our own platforms and toolchains, and we always set `--platforms` and `--host_platforms` to those platforms. However, the chosen toolchain is always `@local_config_cc//:cc-compiler-k8` rather than our own toolchains for some targets. I debugged a bit with `--toolchain_resolution_debug`, and I saw this:

INFO: ToolchainResolution: Target platform @local_config_platform//:host: Selected execution platform @local_config_platform//:host, type @bazel_tools//tools/cpp:toolchain_type -> toolchain @local_config_cc//:cc-compiler-k8

I have no idea why target platform is `@local_config_platform//:host` even if I have set `--platforms`. And FYI I got this when building Tensorflow (tensorflow/python).

How can I get rid of this `@local_config_platform//:host` and use our own platform instead?

Philipp Schrader

unread,
Sep 16, 2022, 12:24:26 AM9/16/22
to bazel-discuss
Make sure to also set --extra_execution_platforms to match your --host_platforms. Once we set that, I'm pretty sure the flaky behaviour like what you're describing disappeared for us. It's been a while though.

John Cater

unread,
Sep 16, 2022, 10:14:27 AM9/16/22
to bazel-discuss
The other flag that defaults to `@local_config_platform//:host` is `--target_platform_fallback`, perhaps you need to also set that (in addition to `--platforms` and `--host_platform`)?

There shouldn't be any need to set `--extra_execution_platforms` if you have `--host_platform` set and you really don't have any other execution platforms.

Shuai Shao

unread,
Oct 6, 2022, 1:41:01 PM10/6/22
to bazel-discuss
Thanks for answering! I verified setting `--extra_execution_platforms` to match `--host_platforms` works!

However, setting `--target_platform_fallback` doesn't work. My guess is that the failure happened when building `tensorflow/compiler/mlir/tools/kernel_gen:tf_to_kernel`, which is a tool that's run on the execution platform rather than the target platform. So we want to override the host/execution platform rather than the `target` platform.

This is too confusing that `extra_execution_platforms` is set and used silently. Hope Bazel team can fix it somehow.
Reply all
Reply to author
Forward
0 new messages