bazelbuild / bazelbuild/bazel

Toolchain resolution error and debug messages are missing log prefixes

Open
#26,068 2 comments 0 reactions 0 assignees View on GitHub
stale team-Core type: bug
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

Toolchain resolution debug messages are printed with various internal newlines, to make the output more readable. However, this causes the output to not have the leading log prefixes that other messages do:

```
INFO: ToolchainResolution: Target platform @@platforms//host:host: Selected execution platform @@platforms//host:host,
INFO: ToolchainResolution: Performing resolution of @@bazel_tools//tools/cpp:toolchain_type for target platform @@platforms//host:host
ToolchainResolution: Rejected toolchain @@+cc_configure_extension+local_config_cc_toolchains//:cc-toolchain-armeabi-v7a (resolves to @@+cc_configure_extension+local_config_cc//:cc-compiler-armeabi-v7a) ; mismatching values: armv7, android
ToolchainResolution: Toolchain @@+cc_configure_extension+local_config_cc_toolchains//:cc-toolchain-k8 (resolves to @@+cc_configure_extension+local_config_cc//:cc-compiler-k8) is compatible with target platform, searching for execution platforms:
ToolchainResolution: Compatible execution platform @@platforms//host:host
ToolchainResolution: All execution platforms have been assigned a @@bazel_tools//tools/cpp:toolchain_type toolchain, stopping
ToolchainResolution: Recap of selected @@bazel_tools//tools/cpp:toolchain_type toolchains for target platform @@platforms//host:host:
ToolchainResolution: Selected @@+cc_configure_extension+local_config_cc//:cc-compiler-k8 to run on execution platform @@platforms//host:host
INFO: ToolchainResolution: Target platform @@platforms//host:host: Selected execution platform @@platforms//host:host, type @@bazel_tools//tools/cpp:toolchain_type -> toolchain @@+cc_configure_extension+local_config_cc//:cc-compiler-k8
INFO: ToolchainResolution: Target platform @@platforms//host:host: Selected execution platform @@platforms//host:host,
INFO: ToolchainResolution: Target platform @@platforms//host:host: Selected execution platform @@platforms//host:host,
```

This can be confusing for automation that is collecting messages based on the prefix (and, for toolchain errors, is most relevant for [the error when no toolchain is found](https://cs.opensource.google/bazel/bazel/+/master:src/main/java/com/google/devtools/build/lib/skyframe/toolchains/ToolchainResolutionFunction.java;drc=09857ccf6385f436336303d013329a6146a3bc2d;l=413):

```
INFO: ToolchainResolution: Performing resolution of //tools/test:default_test_toolchain_type for target platform //:ios_x86_64
ToolchainResolution: Toolchain //tools/test:default_test_toolchain (resolves to //tools/test:empty_toolchain) is compatible with target platform, searching for execution platforms:
ToolchainResolution: Incompatible execution platform //apple_1; mismatching values: ios
ToolchainResolution: Incompatible execution platform //apple_2; mismatching values: ios
ToolchainResolution: No //tools/test:default_test_toolchain_type toolchain found for target platform //:ios_x86_64.
ERROR: /REDACTED/BUILD:153:14: While resolving toolchains for target //test:test (150f998): No matching toolchains found for types:
//tools/test:default_test_toolchain_type
```

A system that only copies lines that begin with `ERROR:` would skip the list of actual missing toolchain types.

Contributor guide

Open the contributing guide

Research direction

Start with src/main/java/com/google/devtools/build/lib/skyframe/toolchains/ToolchainResolutionFunction.java, especially the no-toolchain error path linked in the issue. Reproduce the shown toolchain-resolution output and inspect how multiline debug and error messages are emitted. Done means each relevant line retains the expected log prefix, including the list of missing toolchain types.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.