Skip to content

Commit

Permalink
cherry-pick from @tromey: do not emit .debug_pubnames .debug_pubtypes…
Browse files Browse the repository at this point in the history
… on linux
  • Loading branch information
csmoe committed Feb 21, 2022
1 parent 777bb86 commit 598bd00
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 3 deletions.
23 changes: 22 additions & 1 deletion compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use super::debuginfo::{
DIArray, DIBasicType, DIBuilder, DICompositeType, DIDerivedType, DIDescriptor, DIEnumerator,
DIFile, DIFlags, DIGlobalVariableExpression, DILexicalBlock, DILocation, DINameSpace,
DISPFlags, DIScope, DISubprogram, DISubrange, DITemplateTypeParameter, DIType, DIVariable,
DebugEmissionKind,
DebugEmissionKind, DebugNameTableKind,
};

use libc::{c_char, c_int, c_uint, size_t};
Expand Down Expand Up @@ -955,6 +955,26 @@ pub mod debuginfo {
}
}
}

/// LLVMRustDebugNameTableKind
#[derive(Clone, Copy)]
#[repr(C)]
pub enum DebugNameTableKind {
Default,
None,
Gnu,
}

impl DebugNameTableKind {
pub fn from_generic(kind: rustc_session::config::DebugNameTableKind) -> DebugNameTableKind {
use rustc_session::config;
match kind {
config::DebugNameTableKind::None => DebugNameTableKind::None,
config::DebugNameTableKind::Default => DebugNameTableKind::Default,
config::DebugNameTableKind::Gnu => DebugNameTableKind::Gnu,
}
}
}
}

extern "C" {
Expand Down Expand Up @@ -1919,6 +1939,7 @@ extern "C" {
kind: DebugEmissionKind,
DWOId: u64,
SplitDebugInlining: bool,
DebugNameTableKind: DebugNameTableKind,
) -> &'a DIDescriptor;

pub fn LLVMRustDIBuilderCreateFile<'a>(
Expand Down
26 changes: 24 additions & 2 deletions compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,25 @@ static DICompileUnit::DebugEmissionKind fromRust(LLVMRustDebugEmissionKind Kind)
}
}

enum class LLVMRustDebugNameTableKind {
Default,
None,
Gnu,
};

static DICompileUnit::DebugNameTableKind fromRust(LLVMRustDebugNameTableKind Kind) {
switch (Kind) {
case LLVMRustDebugNameTableKind::Default:
return DICompileUnit::DebugNameTableKind::Default;
case LLVMRustDebugNameTableKind::None:
return DICompileUnit::DebugNameTableKind::None;
case LLVMRustDebugNameTableKind::Gnu:
return DICompileUnit::DebugNameTableKind::Gnu;
default:
report_fatal_error("bad DebugNameTableKind.");
}
}

enum class LLVMRustChecksumKind {
None,
MD5,
Expand Down Expand Up @@ -749,13 +768,16 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateCompileUnit(
const char *Flags, unsigned RuntimeVer,
const char *SplitName, size_t SplitNameLen,
LLVMRustDebugEmissionKind Kind,
uint64_t DWOId, bool SplitDebugInlining) {
uint64_t DWOId, bool SplitDebugInlining,
LLVMRustDebugNameTableKind TableKind) {
auto *File = unwrapDI<DIFile>(FileRef);
bool DebugInfoForProfiling = false;

return wrap(Builder->createCompileUnit(Lang, File, StringRef(Producer, ProducerLen),
isOptimized, Flags, RuntimeVer,
StringRef(SplitName, SplitNameLen),
fromRust(Kind), DWOId, SplitDebugInlining));
fromRust(Kind), DWOId, SplitDebugInlining,
DebugInfoForProfiling, fromRust(TableKind));
}

extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateFile(
Expand Down
7 changes: 7 additions & 0 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,13 @@ pub enum DebugInfo {
Full,
}

#[derive(Clone, Copy, Debug, PartialEq, Hash)]
pub enum DebugNameTableKind {
Default,
None,
Gnu,
}

/// Split debug-information is enabled by `-C split-debuginfo`, this enum is only used if split
/// debug-information is enabled (in either `Packed` or `Unpacked` modes), and the platform
/// uses DWARF for debug-information.
Expand Down
17 changes: 17 additions & 0 deletions compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,21 @@ mod parse {
}
}

crate fn parse_debug_name_table_kind(slot: &mut DebugNameTableKind, v: Option<&str>) -> bool {
match v {
None => false,
Some(s) => {
*slot = match s {
"none" => DebugNameTableKind::None,
"gnu" => DebugNameTableKind::Gnu,
_ => DebugNameTableKind::Default,
};
true
}
_ => false,
}
}

crate fn parse_lto(slot: &mut LtoCli, v: Option<&str>) -> bool {
if v.is_some() {
let mut bool_arg = None;
Expand Down Expand Up @@ -1151,6 +1166,8 @@ options! {
"inject the given attribute in the crate"),
debug_info_for_profiling: bool = (false, parse_bool, [TRACKED],
"emit discriminators and other data necessary for AutoFDO"),
debug_name_table_kind: DebugNameTableKind = (DebugNameTableKind::Default, parse_debug_name_table_kind, [TRACKED],
"emit .debug_pubnames .debug_pubtypes(default: default)"),
debug_macros: bool = (false, parse_bool, [TRACKED],
"emit line numbers debug info inside macros (default: no)"),
deduplicate_diagnostics: bool = (true, parse_bool, [UNTRACKED],
Expand Down

0 comments on commit 598bd00

Please sign in to comment.