[FR] Configuring C++ flag groups based on the target platform #16845
Labels
P4
This is either out of scope or we don't have bandwidth to review a PR. (No assignee)
stale
Issues or PRs that are stale (no activity for 30 days)
team-Rules-CPP
Issues for C++ rules
type: feature request
Description of the feature request:
I have a problem that could be solved by expanding the
feature
and/orflag_group
functionality in C++ toolchain configuration.In particular, I wonder if we could enhance
feature
like so:What underlying problem are you trying to solve with this feature?
We have 50 platforms we're targeting in our build. The majority of which are embedded ARM platforms. Most of those embedded ARM platforms use a single toolchain, but require slightly different compiler flags.
The way we solve this today is by defining those different flags in a per-platform
feature
. Those features are then turned on via a--config
setting. Our .bazelrc file looks roughly equivalent to:That works well enough, but we run into some challenges with transitions. Because it's hard to predict which platform you're transitioning from, we define all our transitions roughly like so:
We basically have to remove any possible features that may exist to avoid the risk of them interfering. This works for us today, but frequently results in hard-to-debug issues when folks add new features and forget to remove it from the big list in every transition.
One solution that I'm experimenting with right now is to define a dedicated toolchain for each platform. That means that we'd have 50 individual toolchains. I think this will work, but feels more like a work around.
I am looking for a better way for toolchains to adjust features based on constraints (or maybe platforms?). The toolchains already make decisions based on other aspects of a target. I think it could do the same for
Which operating system are you running Bazel on?
amd64 Linux
What is the output of
bazel info release
?N/A
If
bazel info release
returnsdevelopment version
or(@non-git)
, tell us how you built Bazel.N/A
What's the output of
git remote get-url origin; git rev-parse master; git rev-parse HEAD
?Have you found anything relevant by searching the web?
I have not found anything related to this.
Any other information, logs, or outputs that you want to share?
This idea came up when I was discussing my problem with @katre at Bazelcon last week.
The original idea involved adding functionality to
flag_group
. Possibly in the form of anexpand_if_target_platform_has_constraints
parameter or similar. This approach should also work, but is a little less expressive for triggering otherfeature
s viaimplies
andrequires
.The text was updated successfully, but these errors were encountered: