bazelbuild / bazelbuild/rules_cc
objcopy not properly set in legacy CcToolchainInfo
- Dominant language
- Starlark
- Stars
- 247
- Forks
- 196
- PR merge metrics
- No merged PRs in 30d
Description
Tested with rules_cc version 0.1.1 and Bazel 7.4.1 :
When using the new rule_based toolchain pattern overriding the default objcopy tool in cc_tool_map results in the CcToolchainInfo not being properly updated.
Example:
```
cc_tool_map(
name = "all_tools",
tools = {
"@rules_cc//cc/toolchains/actions:ar_actions": ":ar",
"@rules_cc//cc/toolchains/actions:assembly_actions": ":gcc",
"@rules_cc//cc/toolchains/actions:c_compile": ":gcc",
"@rules_cc//cc/toolchains/actions:cpp_compile_actions": ":g++",
"@rules_cc//cc/toolchains/actions:link_actions": ":ld",
"@rules_cc//cc/toolchains/actions:objcopy_embed_data": ":objcopy",
"@rules_cc//cc/toolchains/actions:strip": ":strip",
},
visibility = ["//visibility:public"],
)
cc_tool(
name = "objcopy",
src = "@gcc-11.3.0-linux-x86_64//:bin/x86_64-linux-objcopy",
)
-----------------
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")
cc_toolchain = find_cpp_toolchain(ctx)
print(cc_toolchain.objcopy_executable)
```
**Results in cc_toolchain.objcopy_executable to be set to ""**
The following workaround could be used until a fix has been implemented:
```
feature_configuration = cc_common.configure_features(
ctx = ctx,
cc_toolchain = cc_toolchain,
requested_features = [],
unsupported_features = [],
)
objcopy_tool_path = cc_common.get_tool_for_action(
feature_configuration = feature_configuration,
action_name = "objcopy_embed_data"
)
```
Contributor guide
Assessment
This issue has not been assessed yet.