@@ -1224,6 +1224,13 @@ def rustc_compile_action(
1224
1224
if experimental_use_cc_common_link :
1225
1225
emit = ["obj" ]
1226
1226
1227
+ use_split_debuginfo = cc_common .is_enabled (feature_configuration = feature_configuration , feature_name = "per_object_debug_info" ) and ctx .fragments .cpp .fission_active_for_current_compilation_mode ()
1228
+ if use_split_debuginfo :
1229
+ rust_flags = rust_flags + [
1230
+ "--codegen=split-debuginfo=unpacked" ,
1231
+ "--codegen=debuginfo=full" ,
1232
+ ]
1233
+
1227
1234
args , env_from_args = construct_arguments (
1228
1235
ctx = ctx ,
1229
1236
attr = attr ,
@@ -1324,6 +1331,13 @@ def rustc_compile_action(
1324
1331
elif toolchain .target_os == "darwin" :
1325
1332
dsym_folder = ctx .actions .declare_directory (crate_info .output .basename + ".dSYM" , sibling = crate_info .output )
1326
1333
action_outputs .append (dsym_folder )
1334
+ if use_split_debuginfo :
1335
+ fission_directory = crate_info .name + "_fission"
1336
+ if output_hash :
1337
+ fission_directory = fission_directory + output_hash
1338
+ dwo_outputs = ctx .actions .declare_directory (fission_directory , sibling = crate_info .output )
1339
+ args .process_wrapper_flags .add ("--kludge-move-dwo-to" , dwo_outputs .path )
1340
+ action_outputs .append (dwo_outputs )
1327
1341
1328
1342
if ctx .executable ._process_wrapper :
1329
1343
# Run as normal
@@ -1382,15 +1396,19 @@ def rustc_compile_action(
1382
1396
else :
1383
1397
fail ("No process wrapper was defined for {}" .format (ctx .label ))
1384
1398
1399
+ cco_args = {}
1385
1400
if experimental_use_cc_common_link :
1386
1401
# Wrap the main `.o` file into a compilation output suitable for
1387
1402
# cc_common.link. The main `.o` file is useful in both PIC and non-PIC
1388
1403
# modes.
1389
- compilation_outputs = cc_common .create_compilation_outputs (
1390
- objects = depset ([output_o ]),
1391
- pic_objects = depset ([output_o ]),
1392
- )
1393
-
1404
+ cco_args ["objects" ] = depset ([output_o ])
1405
+ cco_args ["pic_objects" ] = depset ([output_o ])
1406
+ if use_split_debuginfo :
1407
+ cco_args ["dwo_objects" ] = depset ([dwo_outputs ]) # buildifier: disable=uninitialized
1408
+ cco_args ["pic_dwo_objects" ] = depset ([dwo_outputs ]) # buildifier: disable=uninitialized
1409
+ compilation_outputs = cc_common .create_compilation_outputs (** cco_args )
1410
+ debug_context = cc_common .create_debug_context (compilation_outputs )
1411
+ if experimental_use_cc_common_link :
1394
1412
malloc_library = ctx .attr ._custom_malloc or ctx .attr .malloc
1395
1413
1396
1414
# Collect the linking contexts of the standard library and dependencies.
@@ -1535,7 +1553,7 @@ def rustc_compile_action(
1535
1553
else :
1536
1554
providers .extend ([crate_info , dep_info ])
1537
1555
1538
- providers += establish_cc_info (ctx , attr , crate_info , toolchain , cc_toolchain , feature_configuration , interface_library )
1556
+ providers += establish_cc_info (ctx , attr , crate_info , toolchain , cc_toolchain , feature_configuration , interface_library , debug_context )
1539
1557
1540
1558
output_group_info = {}
1541
1559
@@ -1617,7 +1635,7 @@ def _add_codegen_units_flags(toolchain, args):
1617
1635
1618
1636
args .add ("-Ccodegen-units={}" .format (toolchain ._codegen_units ))
1619
1637
1620
- def establish_cc_info (ctx , attr , crate_info , toolchain , cc_toolchain , feature_configuration , interface_library ):
1638
+ def establish_cc_info (ctx , attr , crate_info , toolchain , cc_toolchain , feature_configuration , interface_library , debug_context = None ):
1621
1639
"""If the produced crate is suitable yield a CcInfo to allow for interop with cc rules
1622
1640
1623
1641
Args:
@@ -1628,7 +1646,7 @@ def establish_cc_info(ctx, attr, crate_info, toolchain, cc_toolchain, feature_co
1628
1646
cc_toolchain (CcToolchainInfo): The current `CcToolchainInfo`
1629
1647
feature_configuration (FeatureConfiguration): Feature configuration to be queried.
1630
1648
interface_library (File): Optional interface library for cdylib crates on Windows.
1631
-
1649
+ debug_context (DebugContext): Optional debug context.
1632
1650
Returns:
1633
1651
list: A list containing the CcInfo provider
1634
1652
"""
@@ -1694,7 +1712,10 @@ def establish_cc_info(ctx, attr, crate_info, toolchain, cc_toolchain, feature_co
1694
1712
)
1695
1713
1696
1714
cc_infos = [
1697
- CcInfo (linking_context = linking_context ),
1715
+ CcInfo (
1716
+ linking_context = linking_context ,
1717
+ debug_context = debug_context ,
1718
+ ),
1698
1719
toolchain .stdlib_linkflags ,
1699
1720
]
1700
1721
0 commit comments