fix dwarf debuginfo being used in addition to CodeView on windows

Fixes the debuginfo size increase regression introduced by the DWARF5 support.
This commit is contained in:
Rémy Rakic 2022-07-14 20:41:55 +02:00
parent 24699bcbad
commit 97510f2128

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,