about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/debuginfo
diff options
context:
space:
mode:
authorWeihang Lo <me@weihanglo.tw>2023-11-15 23:07:37 -0500
committerWeihang Lo <me@weihanglo.tw>2023-12-11 14:58:02 -0500
commit1667f3d2cc131e1f39d4314296b7cafa9dbfa0f4 (patch)
treed2784e0038b6e72c4a5c63ce2708a119505bd8bf /compiler/rustc_codegen_llvm/src/debuginfo
parenta2d328fa12ca66edb47398c4a620523d252ff727 (diff)
downloadrust-1667f3d2cc131e1f39d4314296b7cafa9dbfa0f4.tar.gz
rust-1667f3d2cc131e1f39d4314296b7cafa9dbfa0f4.zip
fix: stop emitting `.debug_pubnames` and `.debug_pubtypes`
`.debug_pubnames` and `.debug_pubtypes` are poorly designed and people
seldom use them. However, they take a considerable portion of size in
the final binary. This tells LLVM stop emitting those sections on
DWARFv4 or lower. DWARFv5 use `.debug_names` which is more concise
in size and performant for name lookup.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/debuginfo')
-rw-r--r--compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
index 98563673c30..0f807ee6e57 100644
--- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
+++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
@@ -17,6 +17,7 @@ use crate::debuginfo::utils::FatPtrKind;
 use crate::llvm;
 use crate::llvm::debuginfo::{
     DIDescriptor, DIFile, DIFlags, DILexicalBlock, DIScope, DIType, DebugEmissionKind,
+    DebugNameTableKind,
 };
 use crate::value::Value;
 
@@ -878,6 +879,12 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
     let split_name = split_name.to_str().unwrap();
     let kind = DebugEmissionKind::from_generic(tcx.sess.opts.debuginfo);
 
+    let dwarf_version =
+        tcx.sess.opts.unstable_opts.dwarf_version.unwrap_or(tcx.sess.target.default_dwarf_version);
+    // Don't emit `.debug_pubnames` and `.debug_pubtypes` on DWARFv4 or lower.
+    let debug_name_table_kind =
+        if dwarf_version > 4 { DebugNameTableKind::Default } else { DebugNameTableKind::None };
+
     unsafe {
         let compile_unit_file = llvm::LLVMRustDIBuilderCreateFile(
             debug_context.builder,
@@ -907,6 +914,7 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
             kind,
             0,
             tcx.sess.opts.unstable_opts.split_dwarf_inlining,
+            debug_name_table_kind,
         );
 
         if tcx.sess.opts.unstable_opts.profile {