1
Fork 0

Auto merge of #99252 - lqd:win-dwarf5, r=eddyb

fix dwarf debuginfo being used in addition to CodeView on windows

Tackles the debuginfo size increase regression on windows to [unblock clippy](https://github.com/rust-lang/rust/issues/99143#issuecomment-1184638573) -- introduced by the DWARF5 support in #98350 cc `@pcwalton.`

r? `@eddyb`
Fixes #99143
This commit is contained in:
bors 2022-07-14 19:03:58 +00:00
commit c2f428d2f3

View file

@ -97,23 +97,26 @@ impl<'ll, 'tcx> CodegenUnitDebugContext<'ll, 'tcx> {
unsafe { unsafe {
llvm::LLVMRustDIBuilderFinalize(self.builder); llvm::LLVMRustDIBuilderFinalize(self.builder);
if !sess.target.is_like_msvc {
// Debuginfo generation in LLVM by default uses a higher // Debuginfo generation in LLVM by default uses a higher
// version of dwarf than macOS currently understands. We can // version of dwarf than macOS currently understands. We can
// instruct LLVM to emit an older version of dwarf, however, // instruct LLVM to emit an older version of dwarf, however,
// for macOS to understand. For more info see #11352 // for macOS to understand. For more info see #11352
// This can be overridden using --llvm-opts -dwarf-version,N. // This can be overridden using --llvm-opts -dwarf-version,N.
// Android has the same issue (#22398) // Android has the same issue (#22398)
let dwarf_version = let dwarf_version = sess
sess.opts.unstable_opts.dwarf_version.unwrap_or(sess.target.default_dwarf_version); .opts
.unstable_opts
.dwarf_version
.unwrap_or(sess.target.default_dwarf_version);
llvm::LLVMRustAddModuleFlag( llvm::LLVMRustAddModuleFlag(
self.llmod, self.llmod,
llvm::LLVMModFlagBehavior::Warning, llvm::LLVMModFlagBehavior::Warning,
"Dwarf Version\0".as_ptr().cast(), "Dwarf Version\0".as_ptr().cast(),
dwarf_version, dwarf_version,
); );
} else {
// Indicate that we want CodeView debug information on MSVC // Indicate that we want CodeView debug information on MSVC
if sess.target.is_like_msvc {
llvm::LLVMRustAddModuleFlag( llvm::LLVMRustAddModuleFlag(
self.llmod, self.llmod,
llvm::LLVMModFlagBehavior::Warning, llvm::LLVMModFlagBehavior::Warning,