bazelbuild / bazel

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

need a supported way to obtain the registered toolchains and the registered execution platforms #23104

Open dws opened 1 month ago

dws commented 1 month ago

Description of the feature request:

The file produced by bazel sync --experimental_repository_resolved_file=resolve.out contains entries for //external/register_toolchains and //external/register_execution_platforms which provide insight into what toolchains and execution platforms are currently registered for use by Bazel.

In the case of registered toolchains, this information is superior to what can be obtained via --toolchain_resolution_debug because one can definitively identify, for instance, all registered toolchains with certain constraints, without having to know a priori what all the possible things are you'd need to build, and how to build them, in order to see the toolchains mentioned in the --toolchain_resolution_debug output.

Since bazel sync is not supported with bzlmod and is slated to be deprecated (per slack conversation with @Wyverald and @katre ) it would be helpful to have a supported way to obtain this information with or without bzlmod. Hence, this request.

One suggestion in this conversation was to have one or more special new operators in Bazel's query language that would yield the lists of interest above. Note that these lists may include both targets inside the main repo and targets outside the main repo.

Which category does this issue belong to?

CLI

What underlying problem are you trying to solve with this feature?

To gain insight into certain bits of vital information about Bazel's internal state in a supported way.

Which operating system are you running Bazel on?

No response

What is the output of bazel info release?

No response

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?

No response

Have you found anything relevant by searching the web?

No.

Any other information, logs, or outputs that you want to share?

No response

katre commented 1 month ago

At one point I looked into adding a new cquery operator (so that --extra_toolchains would be considered), and was unable to figure out the necessary plumbing of types.

Nonetheless, I think this is an interesting idea.

CC @c-parsons, who was recently adding toolchains-related functions for query: do you think this is possible?