1313# limitations under the License.
1414"""Utilities for creating cc debug package information outputs"""
1515
16+ load ("//cc:action_names.bzl" , "ACTION_NAMES" )
1617load ("//cc:find_cc_toolchain.bzl" , "CC_TOOLCHAIN_TYPE" )
18+ load (":cc_common.bzl" , "cc_common" )
1719load (":cc_helper.bzl" , "linker_mode" )
1820load (":visibility.bzl" , "INTERNAL_VISIBILITY" )
1921
@@ -26,6 +28,7 @@ def create_debug_packager_actions(
2628 * ,
2729 cc_compilation_outputs ,
2830 cc_debug_context ,
31+ feature_configuration ,
2932 linking_mode ,
3033 use_pic = True ,
3134 lto_artifacts = []):
@@ -37,6 +40,7 @@ def create_debug_packager_actions(
3740 dwp_output: (File) the output of the final dwp action
3841 cc_compilation_outputs: (CcCompilationOutputs)
3942 cc_debug_context: (DebugContext)
43+ feature_configuration: (FeatureConfiguration)
4044 linking_mode: (str) See cc_helper.bzl%linker_mode
4145 use_pic: (bool)
4246 lto_artifacts: ([CcLtoBackendArtifacts])
@@ -74,7 +78,15 @@ def create_debug_packager_actions(
7478 # The actions form an n-ary tree with n == MAX_INPUTS_PER_DWP_ACTION. The tree is fuller
7579 # at the leaves than the root, but that both increases parallelism and reduces the final
7680 # action's input size.
77- packager = _create_intermediate_dwp_packagers (ctx , dwp_output , cc_toolchain , cc_toolchain ._dwp_files , dwo_files_list , 1 )
81+ packager = _create_intermediate_dwp_packagers (
82+ ctx ,
83+ dwp_output ,
84+ cc_toolchain ,
85+ feature_configuration ,
86+ cc_toolchain ._dwp_files ,
87+ dwo_files_list ,
88+ 1 ,
89+ )
7890 packager ["outputs" ].append (dwp_output )
7991 packager ["arguments" ].add ("-o" , dwp_output )
8092 ctx .actions .run (
@@ -118,21 +130,38 @@ def _get_intermediate_dwp_file(ctx, dwp_output, order_number):
118130
119131 return ctx .actions .declare_file ("_dwps/" + intermediate_path )
120132
121- def _create_intermediate_dwp_packagers (ctx , dwp_output , cc_toolchain , dwp_files , dwo_files , intermediate_dwp_count ):
133+ def _create_intermediate_dwp_packagers (
134+ ctx ,
135+ dwp_output ,
136+ cc_toolchain ,
137+ feature_configuration ,
138+ dwp_files ,
139+ dwo_files ,
140+ intermediate_dwp_count ):
122141 intermediate_outputs = dwo_files
123142
124143 # This long loop is a substitution for recursion, which is not currently supported in Starlark.
125144 for _ in range (2147483647 ):
126145 packagers = []
127- current_packager = _new_dwp_action (ctx , cc_toolchain , dwp_files )
146+ current_packager = _new_dwp_action (
147+ ctx ,
148+ cc_toolchain ,
149+ feature_configuration ,
150+ dwp_files ,
151+ )
128152 inputs_for_current_packager = 0
129153
130154 # Step 1: generate our batches. We currently break into arbitrary batches of fixed maximum
131155 # input counts, but we can always apply more intelligent heuristics if the need arises.
132156 for dwo_file in intermediate_outputs :
133157 if inputs_for_current_packager == 100 :
134158 packagers .append (current_packager )
135- current_packager = _new_dwp_action (ctx , cc_toolchain , dwp_files )
159+ current_packager = _new_dwp_action (
160+ ctx ,
161+ cc_toolchain ,
162+ feature_configuration ,
163+ dwp_files ,
164+ )
136165 inputs_for_current_packager = 0
137166 current_packager ["inputs" ].append (dwo_file )
138167
@@ -171,11 +200,16 @@ def _create_intermediate_dwp_packagers(ctx, dwp_output, cc_toolchain, dwp_files,
171200 # This is to fix buildifier errors, even though we should never reach this part of the code.
172201 return None
173202
174- def _new_dwp_action (ctx , cc_toolchain , dwp_tools ):
203+ def _new_dwp_action (ctx , cc_toolchain , feature_configuration , dwp_tools ):
175204 return {
205+ "tools" : dwp_tools ,
206+ # Old toolchains use tool_paths. But, those same old toolchains don't support the new
207+ # action configuration solution, so we have to try both.
208+ "executable" : cc_toolchain ._tool_paths .get ("dwp" , None ) or cc_common .get_tool_for_action (
209+ feature_configuration = feature_configuration ,
210+ action_name = ACTION_NAMES .dwp ,
211+ ),
176212 "arguments" : ctx .actions .args (),
177- "executable" : cc_toolchain ._tool_paths .get ("dwp" , None ),
178213 "inputs" : [],
179214 "outputs" : [],
180- "tools" : dwp_tools ,
181- }
215+ } # buildifier: disable=unsorted-dict-items
0 commit comments