@@ -1218,6 +1218,13 @@ def rustc_compile_action(
1218
1218
if experimental_use_cc_common_link :
1219
1219
emit = ["obj" ]
1220
1220
1221
+ 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 ()
1222
+ if use_split_debuginfo :
1223
+ rust_flags = rust_flags + [
1224
+ "--codegen=split-debuginfo=unpacked" ,
1225
+ "--codegen=debuginfo=full" ,
1226
+ ]
1227
+
1221
1228
args , env_from_args = construct_arguments (
1222
1229
ctx = ctx ,
1223
1230
attr = attr ,
@@ -1318,6 +1325,13 @@ def rustc_compile_action(
1318
1325
elif toolchain .target_os == "darwin" :
1319
1326
dsym_folder = ctx .actions .declare_directory (crate_info .output .basename + ".dSYM" , sibling = crate_info .output )
1320
1327
action_outputs .append (dsym_folder )
1328
+ if use_split_debuginfo :
1329
+ fission_directory = crate_info .name + "_fission"
1330
+ if output_hash :
1331
+ fission_directory = fission_directory + output_hash
1332
+ dwo_outputs = ctx .actions .declare_directory (fission_directory , sibling = crate_info .output )
1333
+ args .process_wrapper_flags .add ("--kludge-move-dwo-to" , dwo_outputs .path )
1334
+ action_outputs .append (dwo_outputs )
1321
1335
1322
1336
if ctx .executable ._process_wrapper :
1323
1337
# Run as normal
@@ -1374,15 +1388,19 @@ def rustc_compile_action(
1374
1388
else :
1375
1389
fail ("No process wrapper was defined for {}" .format (ctx .label ))
1376
1390
1391
+ cco_args = {}
1377
1392
if experimental_use_cc_common_link :
1378
1393
# Wrap the main `.o` file into a compilation output suitable for
1379
1394
# cc_common.link. The main `.o` file is useful in both PIC and non-PIC
1380
1395
# modes.
1381
- compilation_outputs = cc_common .create_compilation_outputs (
1382
- objects = depset ([output_o ]),
1383
- pic_objects = depset ([output_o ]),
1384
- )
1385
-
1396
+ cco_args ["objects" ] = depset ([output_o ])
1397
+ cco_args ["pic_objects" ] = depset ([output_o ])
1398
+ if use_split_debuginfo :
1399
+ cco_args ["dwo_objects" ] = depset ([dwo_outputs ]) # buildifier: disable=uninitialized
1400
+ cco_args ["pic_dwo_objects" ] = depset ([dwo_outputs ]) # buildifier: disable=uninitialized
1401
+ compilation_outputs = cc_common .create_compilation_outputs (** cco_args )
1402
+ debug_context = cc_common .create_debug_context (compilation_outputs )
1403
+ if experimental_use_cc_common_link :
1386
1404
malloc_library = ctx .attr ._custom_malloc or ctx .attr .malloc
1387
1405
1388
1406
# Collect the linking contexts of the standard library and dependencies.
@@ -1527,7 +1545,7 @@ def rustc_compile_action(
1527
1545
else :
1528
1546
providers .extend ([crate_info , dep_info ])
1529
1547
1530
- providers += establish_cc_info (ctx , attr , crate_info , toolchain , cc_toolchain , feature_configuration , interface_library )
1548
+ providers += establish_cc_info (ctx , attr , crate_info , toolchain , cc_toolchain , feature_configuration , interface_library , debug_context )
1531
1549
1532
1550
output_group_info = {}
1533
1551
@@ -1583,7 +1601,7 @@ def _collect_nonstatic_linker_inputs(cc_info):
1583
1601
))
1584
1602
return shared_linker_inputs
1585
1603
1586
- def establish_cc_info (ctx , attr , crate_info , toolchain , cc_toolchain , feature_configuration , interface_library ):
1604
+ def establish_cc_info (ctx , attr , crate_info , toolchain , cc_toolchain , feature_configuration , interface_library , debug_context = None ):
1587
1605
"""If the produced crate is suitable yield a CcInfo to allow for interop with cc rules
1588
1606
1589
1607
Args:
@@ -1594,7 +1612,7 @@ def establish_cc_info(ctx, attr, crate_info, toolchain, cc_toolchain, feature_co
1594
1612
cc_toolchain (CcToolchainInfo): The current `CcToolchainInfo`
1595
1613
feature_configuration (FeatureConfiguration): Feature configuration to be queried.
1596
1614
interface_library (File): Optional interface library for cdylib crates on Windows.
1597
-
1615
+ debug_context (DebugContext): Optional debug context.
1598
1616
Returns:
1599
1617
list: A list containing the CcInfo provider
1600
1618
"""
@@ -1660,7 +1678,10 @@ def establish_cc_info(ctx, attr, crate_info, toolchain, cc_toolchain, feature_co
1660
1678
)
1661
1679
1662
1680
cc_infos = [
1663
- CcInfo (linking_context = linking_context ),
1681
+ CcInfo (
1682
+ linking_context = linking_context ,
1683
+ debug_context = debug_context ,
1684
+ ),
1664
1685
toolchain .stdlib_linkflags ,
1665
1686
]
1666
1687
0 commit comments