From cf6ccb93f44a542c4a7461a0af46d45febed0bc4 Mon Sep 17 00:00:00 2001 From: Googler Date: Fri, 6 Sep 2024 08:13:20 -0700 Subject: [PATCH] Implement linker_param_file as cc_args BEGIN_PUBLIC Implement linker_param_file as cc_args Implements the linker_param_file feature as cc_args rules. END_PUBLIC PiperOrigin-RevId: 671762576 Change-Id: Ic6bd3ad3b059599c796680cdb4e2b63f6929b8a9 --- cc/toolchains/args/BUILD | 2 +- cc/toolchains/args/linker_param_file/BUILD | 26 +++++++++++++++++++ cc/toolchains/features/legacy/BUILD | 1 + .../legacy_features_as_args/BUILD | 6 +++++ .../goldens/unix/linker_param_file.textproto | 15 +++++++++++ 5 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 cc/toolchains/args/linker_param_file/BUILD create mode 100644 tests/rule_based_toolchain/legacy_features_as_args/goldens/unix/linker_param_file.textproto diff --git a/cc/toolchains/args/BUILD b/cc/toolchains/args/BUILD index b12019c..94012d0 100644 --- a/cc/toolchains/args/BUILD +++ b/cc/toolchains/args/BUILD @@ -15,6 +15,7 @@ cc_feature( name = "experimental_replace_legacy_action_config_features", args = [ "//cc/toolchains/args/archiver_flags", + "//cc/toolchains/args/linker_param_file", ], feature_name = "experimental_replace_legacy_action_config_features", # TODO: Convert remaining items in this list into their actual args. @@ -35,7 +36,6 @@ cc_feature( "//cc/toolchains/features/legacy:user_link_flags", "//cc/toolchains/features/legacy:force_pic_flags", "//cc/toolchains/features/legacy:libraries_to_link", - "//cc/toolchains/features/legacy:linker_param_file", "//cc/toolchains/features/legacy:runtime_library_search_directories", "//cc/toolchains/features/legacy:shared_flag", ], diff --git a/cc/toolchains/args/linker_param_file/BUILD b/cc/toolchains/args/linker_param_file/BUILD new file mode 100644 index 0000000..64471dc --- /dev/null +++ b/cc/toolchains/args/linker_param_file/BUILD @@ -0,0 +1,26 @@ +load("//cc/toolchains:args.bzl", "cc_args") +load("//cc/toolchains:args_list.bzl", "cc_args_list") + +package(default_visibility = ["//visibility:private"]) + +cc_args_list( + name = "linker_param_file", + args = [":use_param_file"], + visibility = ["//visibility:public"], +) + +cc_args( + name = "use_param_file", + actions = [ + "//cc/toolchains/actions:cpp_link_executable", + "//cc/toolchains/actions:cpp_link_dynamic_library", + "//cc/toolchains/actions:cpp_link_nodeps_dynamic_library", + "//cc/toolchains/actions:lto_index_for_executable", + "//cc/toolchains/actions:lto_index_for_dynamic_library", + "//cc/toolchains/actions:lto_index_for_nodeps_dynamic_library", + "//cc/toolchains/actions:cpp_link_static_library", + ], + args = ["@{param_file}"], + format = {"param_file": "//cc/toolchains/variables:linker_param_file"}, + requires_not_none = "//cc/toolchains/variables:linker_param_file", +) diff --git a/cc/toolchains/features/legacy/BUILD b/cc/toolchains/features/legacy/BUILD index b1db5be..7dbe406 100644 --- a/cc/toolchains/features/legacy/BUILD +++ b/cc/toolchains/features/legacy/BUILD @@ -215,6 +215,7 @@ cc_external_feature( cc_external_feature( name = "linker_param_file", + deprecation = "Use //cc/toolchains/args/linker_param_file instead", feature_name = "linker_param_file", overridable = True, ) diff --git a/tests/rule_based_toolchain/legacy_features_as_args/BUILD b/tests/rule_based_toolchain/legacy_features_as_args/BUILD index 24f3c44..12470ec 100644 --- a/tests/rule_based_toolchain/legacy_features_as_args/BUILD +++ b/tests/rule_based_toolchain/legacy_features_as_args/BUILD @@ -17,3 +17,9 @@ compare_feature_implementation( "//conditions:default": "//tests/rule_based_toolchain/legacy_features_as_args:goldens/unix/archiver_flags.textproto", }), ) + +compare_feature_implementation( + name = "linker_param_file_test", + actual_implementation = "//cc/toolchains/args/linker_param_file", + expected = "//tests/rule_based_toolchain/legacy_features_as_args:goldens/unix/linker_param_file.textproto", +) diff --git a/tests/rule_based_toolchain/legacy_features_as_args/goldens/unix/linker_param_file.textproto b/tests/rule_based_toolchain/legacy_features_as_args/goldens/unix/linker_param_file.textproto new file mode 100644 index 0000000..d20b60b --- /dev/null +++ b/tests/rule_based_toolchain/legacy_features_as_args/goldens/unix/linker_param_file.textproto @@ -0,0 +1,15 @@ +enabled: false +flag_sets { + actions: "c++-link-dynamic-library" + actions: "c++-link-executable" + actions: "c++-link-nodeps-dynamic-library" + actions: "c++-link-static-library" + actions: "lto-index-for-dynamic-library" + actions: "lto-index-for-executable" + actions: "lto-index-for-nodeps-dynamic-library" + flag_groups { + expand_if_available: "linker_param_file" + flags: "@%{linker_param_file}" + } +} +name: "linker_param_file_test"