Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
malt3 opened this issue Nov 29, 2024 · 2 comments
Closed

Comments

@malt3
Copy link

malt3 commented Nov 29, 2024

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):

name = "%{cc_toolchain_identifier}",
cpu = "%{target_cpu}",
compiler = "%{compiler}",
toolchain_identifier = "%{cc_toolchain_identifier}",
host_system_name = "%{host_system_name}",
target_system_name = "%{target_system_name}",
target_libc = "%{target_libc}",
abi_version = "%{abi_version}",
abi_libc_version = "%{abi_libc_version}",
cxx_builtin_include_directories = [%{cxx_builtin_include_directories}],
tool_paths = {%{tool_paths}},
compile_flags = [%{compile_flags}],
opt_compile_flags = [%{opt_compile_flags}],
dbg_compile_flags = [%{dbg_compile_flags}],
conly_flags = [%{conly_flags}],
cxx_flags = [%{cxx_flags}],
link_flags = [%{link_flags}],
link_libs = [%{link_libs}],
opt_link_flags = [%{opt_link_flags}],
unfiltered_compile_flags = [%{unfiltered_compile_flags}],
coverage_compile_flags = [%{coverage_compile_flags}],
coverage_link_flags = [%{coverage_link_flags}],
supports_start_end_lib = %{supports_start_end_lib},
extra_flags_per_feature = %{extra_flags_per_feature},

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 c2549f6.

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

  • @bazel_tools//tools/cpp:unix_cc_configure.bzl
  • rules_nixpkgs

Have you found anything relevant by searching the web?

@malt3
Copy link
Author

malt3 commented Nov 29, 2024

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
Copy link
Author

malt3 commented Nov 29, 2024

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.

@malt3 malt3 closed this as completed Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant