bazelbuild / rules_cc

C++ Rules for Bazel
https://bazel.build
Apache License 2.0
189 stars 94 forks source link

rules_cc copy of `@bazel_tools//tools/cpp:BUILD.tpl` might not make sense #284

Closed malt3 closed 2 days ago

malt3 commented 2 days ago

Description of the problem:

rules_cc is the new owner of what previously was @bazel_tools//tools/cpp:BUILD.tpl. This file is now here: https://github.com/bazelbuild/rules_cc/blob/5be90a4e04e64df0e9d26382e1006d3df21aaa91/cc/private/toolchain/BUILD.tpl

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Using new versions of rules_cc with older versions of Bazel (< 8.0.0rc1) fails, because BUILD.tpl directly passes attributes to cc_toolchain_config which are only available in new Bazel versions (like extra_flags_per_feature):

https://github.com/bazelbuild/rules_cc/blob/5be90a4e04e64df0e9d26382e1006d3df21aaa91/cc/private/toolchain/BUILD.tpl#L103-L126

I think this would also prevent the addition of new attributes in the future, since everyone would need to upgrade Bazel and rules_cc in lockstep.

What operating system are you running Bazel on?

Ubuntu 22.04 amd64

What's the output of bazel info release?

Multiple versions including release 6.5.0.

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

N/A

What version of rules_cc do you use? Can you paste the workspace rule used to fetch rules_cc? What other relevant dependencies does your project have?

Anything after c2549f6eb07ce00e529b84f9b9f1b31135a9ff77.

What Bazel options do you use to trigger the issue? What C++ toolchain do you use?

Have you found anything relevant by searching the web?

malt3 commented 2 days ago

Pinging @meteorcloudy for awareness: If my understanding of this problem is correct, this might be a problem we might want to solve prior to a release of Bazel 8.

malt3 commented 2 days ago

Just noticed that for most consumers, BUILD.tpl and the implementation of cc_toolchain_config will be in sync. This is only a problem for rules_nixpkgs.