Skip to content

Commit e8828e1

Browse files
debuginfo: Don't emit DW_LANG_RUST unless explicitly demanded
1 parent c2aaad4 commit e8828e1

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/librustc/session/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
676676
"dump MIR state at various points in translation"),
677677
orbit: bool = (false, parse_bool,
678678
"get MIR where it belongs - everywhere; most importantly, in orbit"),
679+
rust_debuginfo: bool = (false, parse_bool,
680+
"emit Rust-specific debuginfo instead of fallback encoding"),
679681
}
680682

681683
pub fn default_lib_output() -> CrateType {

src/librustc_trans/debuginfo/metadata.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ use syntax::parse::token;
5353
// From DWARF 5.
5454
// See http://www.dwarfstd.org/ShowIssue.php?issue=140129.1
5555
const DW_LANG_RUST: c_uint = 0x1c;
56+
const DW_LANG_UNKNOWN: c_uint = 0x0;
57+
5658
#[allow(non_upper_case_globals)]
5759
const DW_ATE_boolean: c_uint = 0x02;
5860
#[allow(non_upper_case_globals)]
@@ -1013,10 +1015,17 @@ pub fn compile_unit_metadata(cx: &CrateContext) -> DIDescriptor {
10131015
let producer = CString::new(producer).unwrap();
10141016
let flags = "\0";
10151017
let split_name = "\0";
1018+
1019+
let language = if cx.sess().opts.debugging_opts.rust_debuginfo {
1020+
DW_LANG_RUST
1021+
} else {
1022+
DW_LANG_UNKNOWN
1023+
};
1024+
10161025
return unsafe {
10171026
llvm::LLVMDIBuilderCreateCompileUnit(
10181027
debug_context(cx).builder,
1019-
DW_LANG_RUST,
1028+
language,
10201029
compile_unit_name,
10211030
work_dir.as_ptr(),
10221031
producer.as_ptr(),

0 commit comments

Comments
 (0)