Skip to content

Commit 57d05d3

Browse files
committed
session: add split-dwarf flag
This commit adds a flag for Split DWARF, which enables debuginfo to be split into multiple files. Signed-off-by: David Wood <[email protected]>
1 parent 341aa97 commit 57d05d3

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

compiler/rustc_session/src/config.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,23 @@ pub enum DebugInfo {
221221
Full,
222222
}
223223

224+
/// Some debuginfo requires link-time relocation and some does not. LLVM can partition the debuginfo
225+
/// into sections depending on whether or not it requires link-time relocation. Split DWARF
226+
/// provides a mechanism which allows the linker to skip the sections which don't require link-time
227+
/// relocation - either by putting those sections into DWARF object files, or keeping them in the
228+
/// object file in such a way that the linker will skip them.
229+
#[derive(Clone, Copy, Debug, PartialEq, Hash)]
230+
pub enum SplitDwarfKind {
231+
/// Disabled.
232+
None,
233+
/// Sections which do not require relocation are written into the object file but ignored
234+
/// by the linker.
235+
Single,
236+
/// Sections which do not require relocation are written into a DWARF object (`.dwo`) file,
237+
/// which is skipped by the linker by virtue of being a different file.
238+
Split,
239+
}
240+
224241
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, PartialOrd, Ord)]
225242
#[derive(Encodable, Decodable)]
226243
pub enum OutputType {

compiler/rustc_session/src/options.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ macro_rules! options {
269269
pub const parse_switch_with_opt_path: &str =
270270
"an optional path to the profiling data output directory";
271271
pub const parse_merge_functions: &str = "one of: `disabled`, `trampolines`, or `aliases`";
272+
pub const parse_split_dwarf_kind: &str = "one of: `none`, `single` or `split`";
272273
pub const parse_symbol_mangling_version: &str = "either `legacy` or `v0` (RFC 2603)";
273274
pub const parse_src_file_hash: &str = "either `md5` or `sha1`";
274275
pub const parse_relocation_model: &str =
@@ -676,6 +677,19 @@ macro_rules! options {
676677
true
677678
}
678679

680+
fn parse_split_dwarf_kind(
681+
slot: &mut SplitDwarfKind,
682+
v: Option<&str>,
683+
) -> bool {
684+
*slot = match v {
685+
Some("none") => SplitDwarfKind::None,
686+
Some("split") => SplitDwarfKind::Split,
687+
Some("single") => SplitDwarfKind::Single,
688+
_ => return false,
689+
};
690+
true
691+
}
692+
679693
fn parse_symbol_mangling_version(
680694
slot: &mut Option<SymbolManglingVersion>,
681695
v: Option<&str>,
@@ -1088,6 +1102,11 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
10881102
"hash algorithm of source files in debug info (`md5`, `sha1`, or `sha256`)"),
10891103
strip: Strip = (Strip::None, parse_strip, [UNTRACKED],
10901104
"tell the linker which information to strip (`none` (default), `debuginfo` or `symbols`)"),
1105+
split_dwarf: SplitDwarfKind = (SplitDwarfKind::None, parse_split_dwarf_kind, [UNTRACKED],
1106+
"enable generation of split dwarf"),
1107+
split_dwarf_inlining: bool = (true, parse_bool, [UNTRACKED],
1108+
"provide minimal debug info in the object/executable to facilitate online \
1109+
symbolication/stack traces in the absence of .dwo/.dwp files when using Split DWARF"),
10911110
symbol_mangling_version: Option<SymbolManglingVersion> = (None,
10921111
parse_symbol_mangling_version, [TRACKED],
10931112
"which mangling version to use for symbol names ('legacy' (default) or 'v0')"),

0 commit comments

Comments
 (0)