From ed4f9eea9b72797c7be56861849f1881bf05e301 Mon Sep 17 00:00:00 2001 From: Lee Mracek Date: Mon, 23 Jan 2023 01:57:21 -0800 Subject: [PATCH] Add tool name for objcopy It is not clear to me why this constant is in [src/main/starlark/builtins_bzl/common/cc/action_names.bzl](https://github.com/bazelbuild/bazel/blob/master/src/main/starlark/builtins_bzl/common/cc/action_names.bzl) but not in [tools/build_defs/cc/action_names.bzl](https://github.com/bazelbuild/bazel/blob/master/tools/build_defs/cc/action_names.bzl), but it makes `get_tool_for_action` really annoying. Furthermore, it seems that if we are willing to define `llvm-cov` for everyone we should do the same for `objcopy`. Closes #16158. PiperOrigin-RevId: 503922270 Change-Id: Ic0803de27150bb6da02a9daf5bb0337ba5ccc17c --- tools/build_defs/cc/action_names.bzl | 4 ++++ tools/cpp/unix_cc_toolchain_config.bzl | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/tools/build_defs/cc/action_names.bzl b/tools/build_defs/cc/action_names.bzl index a4ced7b190db0d..55da4e8a8ccf85 100644 --- a/tools/build_defs/cc/action_names.bzl +++ b/tools/build_defs/cc/action_names.bzl @@ -91,6 +91,9 @@ OBJC_FULLY_LINK_ACTION_NAME = "objc-fully-link" # A string constant for the clif actions. CLIF_MATCH_ACTION_NAME = "clif-match" +# A string constant for the obj copy actions. +OBJ_COPY_ACTION_NAME = "objcopy_embed_data" + ACTION_NAMES = struct( c_compile = C_COMPILE_ACTION_NAME, cpp_compile = CPP_COMPILE_ACTION_NAME, @@ -118,4 +121,5 @@ ACTION_NAMES = struct( objcpp_compile = OBJCPP_COMPILE_ACTION_NAME, objcpp_executable = OBJCPP_EXECUTABLE_ACTION_NAME, clif_match = CLIF_MATCH_ACTION_NAME, + objcopy_embed_data = OBJ_COPY_ACTION_NAME, ) diff --git a/tools/cpp/unix_cc_toolchain_config.bzl b/tools/cpp/unix_cc_toolchain_config.bzl index 64e8f0c95ebb76..867013473927ee 100644 --- a/tools/cpp/unix_cc_toolchain_config.bzl +++ b/tools/cpp/unix_cc_toolchain_config.bzl @@ -188,7 +188,17 @@ def _impl(ctx): ], ) + objcopy_action = action_config( + action_name = ACTION_NAMES.objcopy_embed_data, + tools = [ + tool( + path = ctx.attr.tool_paths["objcopy"], + ), + ], + ) + action_configs.append(llvm_cov_action) + action_configs.append(objcopy_action) supports_pic_feature = feature( name = "supports_pic",