diff --git a/site/docs/toolchains.md b/site/docs/toolchains.md index 9a767ee5a4e6ef..740c4f7a7a2116 100644 --- a/site/docs/toolchains.md +++ b/site/docs/toolchains.md @@ -431,7 +431,8 @@ independently to each version of the target. ## Debugging toolchains -When adding toolchain support to an existing rule, use the -`--toolchain_resolution_debug` flag to make toolchain resolution verbose. Bazel -will output names of toolchains it is checking and skipping during the -resolution process. +If you are adding toolchain support to an existing rule, use the +`--toolchain_resolution_debug=regex` flag. During toolchain resolution, the flag +provides verbose output for toolchain types that match the regex variable. You +can use `.*` to output all information. Bazel will output names of toolchains it +checks and skips during the resolution process. diff --git a/site/docs/user-manual.html b/site/docs/user-manual.html index a348edf2818917..21c69a7e01261e 100644 --- a/site/docs/user-manual.html +++ b/site/docs/user-manual.html @@ -1627,11 +1627,12 @@

--extra_toolchains=label register_toolchains().

-

--toolchain_resolution_debug=false

+

--toolchain_resolution_debug=regex

- Print debug information while finding toolchains for a rule. This might help - developers of Bazel or Starlark rules with debugging failures due to missing - toolchains. + Print debug information while finding toolchains if the toolchain type matches + the regex. Multiple regexes can be separated by commas. The regex can be + negated by using a - at the beginning. This might help developers + of Bazel or Starlark rules with debugging failures due to missing toolchains.

Miscellaneous

diff --git a/src/main/java/com/google/devtools/build/lib/analysis/PlatformConfiguration.java b/src/main/java/com/google/devtools/build/lib/analysis/PlatformConfiguration.java index f95800df796803..24b1483b028bde 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/PlatformConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/PlatformConfiguration.java @@ -24,6 +24,7 @@ import com.google.devtools.build.lib.events.EventHandler; import com.google.devtools.build.lib.starlarkbuildapi.platform.PlatformConfigurationApi; import com.google.devtools.build.lib.util.RegexFilter; +import java.util.Collection; import java.util.List; import java.util.Map; @@ -36,6 +37,7 @@ public class PlatformConfiguration extends Fragment implements PlatformConfigura private final Label targetPlatform; private final ImmutableList extraToolchains; private final List>> targetFilterToAdditionalExecConstraints; + private final RegexFilter toolchainResolutionDebugRegexFilter; public PlatformConfiguration(BuildOptions buildOptions) { PlatformOptions platformOptions = buildOptions.get(PlatformOptions.class); @@ -46,6 +48,7 @@ public PlatformConfiguration(BuildOptions buildOptions) { this.extraToolchains = ImmutableList.copyOf(platformOptions.extraToolchains); this.targetFilterToAdditionalExecConstraints = platformOptions.targetFilterToAdditionalExecConstraints; + this.toolchainResolutionDebugRegexFilter = platformOptions.toolchainResolutionDebug; } @Override @@ -111,4 +114,23 @@ public List