Skip to content

Commit 598bd00

Browse files
committed
cherry-pick from @tromey: do not emit .debug_pubnames .debug_pubtypes on linux
1 parent 777bb86 commit 598bd00

File tree

4 files changed

+70
-3
lines changed

4 files changed

+70
-3
lines changed

Diff for: compiler/rustc_codegen_llvm/src/llvm/ffi.rs

+22-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use super::debuginfo::{
77
DIArray, DIBasicType, DIBuilder, DICompositeType, DIDerivedType, DIDescriptor, DIEnumerator,
88
DIFile, DIFlags, DIGlobalVariableExpression, DILexicalBlock, DILocation, DINameSpace,
99
DISPFlags, DIScope, DISubprogram, DISubrange, DITemplateTypeParameter, DIType, DIVariable,
10-
DebugEmissionKind,
10+
DebugEmissionKind, DebugNameTableKind,
1111
};
1212

1313
use libc::{c_char, c_int, c_uint, size_t};
@@ -955,6 +955,26 @@ pub mod debuginfo {
955955
}
956956
}
957957
}
958+
959+
/// LLVMRustDebugNameTableKind
960+
#[derive(Clone, Copy)]
961+
#[repr(C)]
962+
pub enum DebugNameTableKind {
963+
Default,
964+
None,
965+
Gnu,
966+
}
967+
968+
impl DebugNameTableKind {
969+
pub fn from_generic(kind: rustc_session::config::DebugNameTableKind) -> DebugNameTableKind {
970+
use rustc_session::config;
971+
match kind {
972+
config::DebugNameTableKind::None => DebugNameTableKind::None,
973+
config::DebugNameTableKind::Default => DebugNameTableKind::Default,
974+
config::DebugNameTableKind::Gnu => DebugNameTableKind::Gnu,
975+
}
976+
}
977+
}
958978
}
959979

960980
extern "C" {
@@ -1919,6 +1939,7 @@ extern "C" {
19191939
kind: DebugEmissionKind,
19201940
DWOId: u64,
19211941
SplitDebugInlining: bool,
1942+
DebugNameTableKind: DebugNameTableKind,
19221943
) -> &'a DIDescriptor;
19231944

19241945
pub fn LLVMRustDIBuilderCreateFile<'a>(

Diff for: compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

+24-2
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,25 @@ static DICompileUnit::DebugEmissionKind fromRust(LLVMRustDebugEmissionKind Kind)
682682
}
683683
}
684684

685+
enum class LLVMRustDebugNameTableKind {
686+
Default,
687+
None,
688+
Gnu,
689+
};
690+
691+
static DICompileUnit::DebugNameTableKind fromRust(LLVMRustDebugNameTableKind Kind) {
692+
switch (Kind) {
693+
case LLVMRustDebugNameTableKind::Default:
694+
return DICompileUnit::DebugNameTableKind::Default;
695+
case LLVMRustDebugNameTableKind::None:
696+
return DICompileUnit::DebugNameTableKind::None;
697+
case LLVMRustDebugNameTableKind::Gnu:
698+
return DICompileUnit::DebugNameTableKind::Gnu;
699+
default:
700+
report_fatal_error("bad DebugNameTableKind.");
701+
}
702+
}
703+
685704
enum class LLVMRustChecksumKind {
686705
None,
687706
MD5,
@@ -749,13 +768,16 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateCompileUnit(
749768
const char *Flags, unsigned RuntimeVer,
750769
const char *SplitName, size_t SplitNameLen,
751770
LLVMRustDebugEmissionKind Kind,
752-
uint64_t DWOId, bool SplitDebugInlining) {
771+
uint64_t DWOId, bool SplitDebugInlining,
772+
LLVMRustDebugNameTableKind TableKind) {
753773
auto *File = unwrapDI<DIFile>(FileRef);
774+
bool DebugInfoForProfiling = false;
754775

755776
return wrap(Builder->createCompileUnit(Lang, File, StringRef(Producer, ProducerLen),
756777
isOptimized, Flags, RuntimeVer,
757778
StringRef(SplitName, SplitNameLen),
758-
fromRust(Kind), DWOId, SplitDebugInlining));
779+
fromRust(Kind), DWOId, SplitDebugInlining,
780+
DebugInfoForProfiling, fromRust(TableKind));
759781
}
760782

761783
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateFile(

Diff for: compiler/rustc_session/src/config.rs

+7
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,13 @@ pub enum DebugInfo {
231231
Full,
232232
}
233233

234+
#[derive(Clone, Copy, Debug, PartialEq, Hash)]
235+
pub enum DebugNameTableKind {
236+
Default,
237+
None,
238+
Gnu,
239+
}
240+
234241
/// Split debug-information is enabled by `-C split-debuginfo`, this enum is only used if split
235242
/// debug-information is enabled (in either `Packed` or `Unpacked` modes), and the platform
236243
/// uses DWARF for debug-information.

Diff for: compiler/rustc_session/src/options.rs

+17
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,21 @@ mod parse {
811811
}
812812
}
813813

814+
crate fn parse_debug_name_table_kind(slot: &mut DebugNameTableKind, v: Option<&str>) -> bool {
815+
match v {
816+
None => false,
817+
Some(s) => {
818+
*slot = match s {
819+
"none" => DebugNameTableKind::None,
820+
"gnu" => DebugNameTableKind::Gnu,
821+
_ => DebugNameTableKind::Default,
822+
};
823+
true
824+
}
825+
_ => false,
826+
}
827+
}
828+
814829
crate fn parse_lto(slot: &mut LtoCli, v: Option<&str>) -> bool {
815830
if v.is_some() {
816831
let mut bool_arg = None;
@@ -1151,6 +1166,8 @@ options! {
11511166
"inject the given attribute in the crate"),
11521167
debug_info_for_profiling: bool = (false, parse_bool, [TRACKED],
11531168
"emit discriminators and other data necessary for AutoFDO"),
1169+
debug_name_table_kind: DebugNameTableKind = (DebugNameTableKind::Default, parse_debug_name_table_kind, [TRACKED],
1170+
"emit .debug_pubnames .debug_pubtypes(default: default)"),
11541171
debug_macros: bool = (false, parse_bool, [TRACKED],
11551172
"emit line numbers debug info inside macros (default: no)"),
11561173
deduplicate_diagnostics: bool = (true, parse_bool, [UNTRACKED],

0 commit comments

Comments
 (0)