bazelbuild / bazelbuild/bazel

Expose enabled/requested features in `FeatureConfigurationForStarlark` to Starlark

Open
#23,815 6 comments 0 reactions 0 assignees View on GitHub
P2 team-Rules-CPP type: feature request
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 18h
Merged PRs (30d)
75

Description

### Description of the feature request:

I have a need to introspect the current feature configuration of the current toolchain from starlark, but currently that's not possible:

* `is_enabled()` and `is_requested()` both are considered private API:
```
Error in is_enabled: file '//pw_toolchain/cc/current_toolchain:enabled_toolchain_feature.bzl' cannot use private API
```
* Enabled and requested feature names are not exposed to Starlark as list members of a `FeatureConfiguration` provider.

### Which category does this issue belong to?

C++ Rules

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

In short, I'm exposing the current toolchain configuration so it can be communicated for use in `config_settings` as a more granular way to control `select()` statements throughout a build. This is meant to be a more powerful alternative to [`compiler_flag`](https://cs.opensource.google/bazel/bazel/+/master:tools/cpp/compiler_flag.bzl) in `@bazel_tools`. This would, for example, allow toolchains to communicate the flavor of compiler and linker in parallel via sentinel features, which is important for some configurations where `clang` might be used to compile while `gcc` is used to link.

More context at https://pwbug.dev/361229275.

### 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 response_

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

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by locating FeatureConfigurationForStarlark and the handling of is_enabled() and is_requested(), then compare the existing FeatureConfiguration provider surface with the compiler_flag.bzl approach. Done means Starlark can inspect enabled and requested feature names for the current toolchain without private-API errors, with coverage for the exposed provider values.

Written by the indexing model from the issue text.

Assessment

Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.