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