bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
23.15k stars 4.05k forks source link

--toolchain_resolution_debug output is hard to understand #8502

Closed brandjon closed 4 years ago

brandjon commented 5 years ago

The output I see while debugging an integration test is:

Analyzing: target //test:pybin (1 packages loaded, 0 targets configured)
INFO: ToolchainResolution: Looking for toolchain of type @bazel_tools//tools/cpp:toolchain_type...
INFO: ToolchainResolution: Looking for toolchain of type @bazel_tools//tools/python:toolchain_type...
INFO: ToolchainResolution:   Considering toolchain @local_config_cc//:cc-compiler-armabi-v7a...
INFO: ToolchainResolution:   Considering toolchain //tools/python/windows:py_runtime_pair...
INFO: ToolchainResolution:     Toolchain constraint @bazel_tools//platforms:cpu has value @bazel_tools//platforms:arm, which does not match value @bazel_tools//platforms:x86_64 from the target platform @bazel_tools//platforms:target_platform
INFO: ToolchainResolution:   Considering toolchain @bazel_tools//tools/python:_autodetecting_py_runtime_pair...
INFO: ToolchainResolution:     Toolchain constraint @bazel_tools//platforms:os has value @bazel_tools//platforms:android, which does not match value @bazel_tools//platforms:windows from the target platform @bazel_tools//platforms:target_platform
INFO: ToolchainResolution:   Rejected toolchain @local_config_cc//:cc-compiler-armabi-v7a, because of target platform mismatch
INFO: ToolchainResolution:   Considering toolchain @local_config_cc//:cc-compiler-x64_windows...
INFO: ToolchainResolution:   For toolchain type @bazel_tools//tools/python:toolchain_type, possible execution platforms and toolchains: {@bazel_tools//platforms:host_platform -> //tools/python/windows:py_runtime_pair}
INFO: ToolchainResolution:   For toolchain type @bazel_tools//tools/cpp:toolchain_type, possible execution platforms and toolchains: {@bazel_tools//platforms:host_platform -> @local_config_cc//:cc-compiler-x64_windows}
INFO: ToolchainResolution: Selected execution platform @bazel_tools//platforms:host_platform, type @bazel_tools//tools/cpp:toolchain_type -> toolchain @local_config_cc//:cc-compiler-x64_windows, type @bazel_tools//tools/python:toolchain_type -> toolchain //tools/python/windows:py_runtime_pair

I would expect that the indentation after ToolchainResolution: is significant -- that each line corresponds to work done for the most recent preceding line having less indentation. So why is "Considering toolchain @local_config_cc[...]" underneath "Looking for [...]python:toolchain_type"? If it determines all toolchain types before considering any of them, maybe that can be rephrased as "Looking for the following toolchain types: [type1], [type2], ...".

More importantly, I don't understand what the toolchain constraint lines mean:

Toolchain constraint @bazel_tools//platforms:cpu has value @bazel_tools//platforms:arm, which does not match value @bazel_tools//platforms:x86_64 from the target platform @bazel_tools//platforms:target_platform

The wording sounds like it's saying a constraint setting has a bad value, but conceptually constraint settings do not have values at all. Toolchains have values for a constraint setting. And critically, I don't know what toolchain this is referring to. I'd rephrase as

Toolchain //foo does not match constraints of target platform //bar. Toolchain has value //qux for setting //quux, but platform has value /quuz.

(That's the most metasyntactic vars I've ever had a non-contrived use for.)

cushon commented 5 years ago

related: #7713

katre commented 4 years ago

Closing this in favor of #7713.