diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 347221ad5d48..416c2e6b68a3 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -676,6 +676,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "dump MIR state at various points in translation"), orbit: bool = (false, parse_bool, "get MIR where it belongs - everywhere; most importantly, in orbit"), + rust_debuginfo: bool = (false, parse_bool, + "emit Rust-specific debuginfo instead of fallback encoding"), } pub fn default_lib_output() -> CrateType { diff --git a/src/librustc_trans/debuginfo/metadata.rs b/src/librustc_trans/debuginfo/metadata.rs index de403732269f..dad32d300725 100644 --- a/src/librustc_trans/debuginfo/metadata.rs +++ b/src/librustc_trans/debuginfo/metadata.rs @@ -53,6 +53,8 @@ use syntax::parse::token; // From DWARF 5. // See http://www.dwarfstd.org/ShowIssue.php?issue=140129.1 const DW_LANG_RUST: c_uint = 0x1c; +const DW_LANG_UNKNOWN: c_uint = 0x0; + #[allow(non_upper_case_globals)] const DW_ATE_boolean: c_uint = 0x02; #[allow(non_upper_case_globals)] @@ -1013,10 +1015,17 @@ pub fn compile_unit_metadata(cx: &CrateContext) -> DIDescriptor { let producer = CString::new(producer).unwrap(); let flags = "\0"; let split_name = "\0"; + + let language = if cx.sess().opts.debugging_opts.rust_debuginfo { + DW_LANG_RUST + } else { + DW_LANG_UNKNOWN + }; + return unsafe { llvm::LLVMDIBuilderCreateCompileUnit( debug_context(cx).builder, - DW_LANG_RUST, + language, compile_unit_name, work_dir.as_ptr(), producer.as_ptr(),