Skip to content

Commit 6aac62c

Browse files
committed
refactor: only check dwarf version when emitting dwarf
1 parent 1667f3d commit 6aac62c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ use rustc_span::FileName;
3939
use rustc_span::{FileNameDisplayPreference, SourceFile};
4040
use rustc_symbol_mangling::typeid_for_trait_ref;
4141
use rustc_target::abi::{Align, Size};
42+
use rustc_target::spec::DebuginfoKind;
4243
use smallvec::smallvec;
4344

4445
use libc::{c_char, c_longlong, c_uint};
@@ -881,9 +882,14 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
881882

882883
let dwarf_version =
883884
tcx.sess.opts.unstable_opts.dwarf_version.unwrap_or(tcx.sess.target.default_dwarf_version);
885+
let is_dwarf_kind =
886+
matches!(tcx.sess.target.debuginfo_kind, DebuginfoKind::Dwarf | DebuginfoKind::DwarfDsym);
884887
// Don't emit `.debug_pubnames` and `.debug_pubtypes` on DWARFv4 or lower.
885-
let debug_name_table_kind =
886-
if dwarf_version > 4 { DebugNameTableKind::Default } else { DebugNameTableKind::None };
888+
let debug_name_table_kind = if is_dwarf_kind && dwarf_version <= 4 {
889+
DebugNameTableKind::None
890+
} else {
891+
DebugNameTableKind::Default
892+
};
887893

888894
unsafe {
889895
let compile_unit_file = llvm::LLVMRustDIBuilderCreateFile(

0 commit comments

Comments
 (0)