Skip to content

Commit

Permalink
compiletest: add split dwarf compare mode
Browse files Browse the repository at this point in the history
This commit adds a Split DWARF compare mode to compiletest so that
debuginfo tests are also tested using Split DWARF in split mode (and
manually in single mode).

Signed-off-by: David Wood <david@davidtw.co>
  • Loading branch information
davidtwco committed Dec 16, 2020
1 parent 2b22670 commit 99ad915
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
7 changes: 7 additions & 0 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Expand Up @@ -1037,6 +1037,13 @@ fn preserve_objects_for_their_debuginfo(sess: &Session) -> bool {
return false;
}

// Single mode keeps debuginfo in the same object file, but in such a way that it it skipped
// by the linker - so it's expected that when codegen units are linked together that this
// debuginfo would be lost without keeping around the temps.
if sess.opts.debugging_opts.split_dwarf == config::SplitDwarfKind::Single {
return true;
}

// If we're on OSX then the equivalent of split dwarf is turned on by
// default. The final executable won't actually have any debug information
// except it'll have pointers to elsewhere. Historically we've always run
Expand Down
7 changes: 6 additions & 1 deletion src/bootstrap/test.rs
Expand Up @@ -897,7 +897,12 @@ default_test!(Incremental {
suite: "incremental"
});

default_test!(Debuginfo { path: "src/test/debuginfo", mode: "debuginfo", suite: "debuginfo" });
default_test_with_compare_mode!(Debuginfo {
path: "src/test/debuginfo",
mode: "debuginfo",
suite: "debuginfo",
compare_mode: "split-dwarf"
});

host_test!(UiFullDeps { path: "src/test/ui-fulldeps", mode: "ui", suite: "ui-fulldeps" });

Expand Down
6 changes: 6 additions & 0 deletions src/tools/compiletest/src/common.rs
Expand Up @@ -127,6 +127,8 @@ pub enum CompareMode {
Nll,
Polonius,
Chalk,
SplitDwarf,
SplitDwarfSingle,
}

impl CompareMode {
Expand All @@ -135,6 +137,8 @@ impl CompareMode {
CompareMode::Nll => "nll",
CompareMode::Polonius => "polonius",
CompareMode::Chalk => "chalk",
CompareMode::SplitDwarf => "split-dwarf",
CompareMode::SplitDwarfSingle => "split-dwarf-single",
}
}

Expand All @@ -143,6 +147,8 @@ impl CompareMode {
"nll" => CompareMode::Nll,
"polonius" => CompareMode::Polonius,
"chalk" => CompareMode::Chalk,
"split-dwarf" => CompareMode::SplitDwarf,
"split-dwarf-single" => CompareMode::SplitDwarfSingle,
x => panic!("unknown --compare-mode option: {}", x),
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/tools/compiletest/src/header.rs
Expand Up @@ -852,6 +852,8 @@ impl Config {
Some(CompareMode::Nll) => name == "compare-mode-nll",
Some(CompareMode::Polonius) => name == "compare-mode-polonius",
Some(CompareMode::Chalk) => name == "compare-mode-chalk",
Some(CompareMode::SplitDwarf) => name == "compare-mode-split-dwarf",
Some(CompareMode::SplitDwarfSingle) => name == "compare-mode-split-dwarf-single",
None => false,
} ||
(cfg!(debug_assertions) && name == "debug") ||
Expand Down
6 changes: 6 additions & 0 deletions src/tools/compiletest/src/runtest.rs
Expand Up @@ -2017,6 +2017,12 @@ impl<'test> TestCx<'test> {
Some(CompareMode::Chalk) => {
rustc.args(&["-Zchalk"]);
}
Some(CompareMode::SplitDwarf) => {
rustc.args(&["-Zsplit-dwarf=split"]);
}
Some(CompareMode::SplitDwarfSingle) => {
rustc.args(&["-Zsplit-dwarf=single"]);
}
None => {}
}

Expand Down

0 comments on commit 99ad915

Please sign in to comment.