From 0d1b084cfa75dc2f41e4b638ebd544fc93b82edf Mon Sep 17 00:00:00 2001 From: Googler Date: Thu, 27 Jun 2024 06:55:22 -0700 Subject: [PATCH] Update toolchain variable definitions to allow static linking BEGIN_PUBLIC Update toolchain variable definitions to allow static linking Updates the rules-based-toolchain variable definitions to reflect the how the variables are used in Bazel's CppActionConfigs.java Java implementation, particularly with respect to static linking. END_PUBLIC PiperOrigin-RevId: 647301605 Change-Id: I7ff87a75f9654d70ea160282ba66e99363c79ce5 --- cc/toolchains/variables/BUILD | 68 ++++++++++++++++++++++++++++++++--- 1 file changed, 64 insertions(+), 4 deletions(-) diff --git a/cc/toolchains/variables/BUILD b/cc/toolchains/variables/BUILD index d0c8977..3740ce7 100644 --- a/cc/toolchains/variables/BUILD +++ b/cc/toolchains/variables/BUILD @@ -156,8 +156,15 @@ cc_variable( cc_variable( name = "libraries_to_link", - actions = ["//cc/toolchains/actions:link_actions"], + actions = [ + "//cc/toolchains/actions:cpp_link_static_library", + "//cc/toolchains/actions:link_actions", + ], type = types.option(types.list(types.struct( + name = types.string, + is_whole_archive = types.bool, + object_files = types.list(types.file), + path = types.string, shared_libraries = types.list(types.struct( name = types.string, is_whole_archive = types.bool, @@ -165,9 +172,56 @@ cc_variable( path = types.file, type = types.string, )), + type = types.string, ))), ) +cc_variable( + name = "libraries_to_link.type", + actions = [ + "//cc/toolchains/actions:cpp_link_static_library", + "//cc/toolchains/actions:link_actions", + ], + # See :libraries_to_link. + type = types.string, +) + +cc_variable( + name = "libraries_to_link.name", + actions = [ + "//cc/toolchains/actions:cpp_link_static_library", + "//cc/toolchains/actions:link_actions", + ], + # See :libraries_to_link. + type = types.string, +) + +cc_variable( + name = "libraries_to_link.path", + actions = [ + "//cc/toolchains/actions:cpp_link_static_library", + "//cc/toolchains/actions:link_actions", + ], + # See :libraries_to_link. + type = types.string, +) + +cc_variable( + name = "libraries_to_link.object_files", + actions = [ + "//cc/toolchains/actions:cpp_link_static_library", + "//cc/toolchains/actions:link_actions", + ], + # See :libraries_to_link. + type = types.list(types.file), +) + +cc_variable( + name = "libraries_to_link.is_whole_archive", + actions = ["//cc/toolchains/actions:link_actions"], + type = types.bool, +) + cc_variable( name = "libraries_to_link.shared_libraries", actions = ["//cc/toolchains/actions:link_actions"], @@ -213,8 +267,11 @@ cc_variable( cc_variable( name = "linker_param_file", - actions = ["//cc/toolchains/actions:link_actions"], - type = types.file, + actions = [ + "//cc/toolchains/actions:cpp_link_static_library", + "//cc/toolchains/actions:link_actions", + ], + type = types.option(types.file), ) cc_variable( @@ -255,7 +312,10 @@ cc_variable( cc_variable( name = "output_execpath", - actions = ["//cc/toolchains/actions:link_actions"], + actions = [ + "//cc/toolchains/actions:cpp_link_static_library", + "//cc/toolchains/actions:link_actions", + ], type = types.option(types.directory), )