about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_codegen_llvm/src/debuginfo/mod.rs6
-rw-r--r--tests/ui/lto/dwarf-mixed-versions-lto.stderr4
2 files changed, 5 insertions, 5 deletions
diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs
index 496178c6b1d..471cdc17148 100644
--- a/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs
+++ b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs
@@ -97,7 +97,11 @@ impl<'ll, 'tcx> CodegenUnitDebugContext<'ll, 'tcx> {
                 // Android has the same issue (#22398)
                 llvm::add_module_flag_u32(
                     self.llmod,
-                    llvm::ModuleFlagMergeBehavior::Warning,
+                    // In the case where multiple CGUs with different dwarf version
+                    // values are being merged together, such as with cross-crate
+                    // LTO, then we want to use the highest version of dwarf
+                    // we can. This matches Clang's behavior as well.
+                    llvm::ModuleFlagMergeBehavior::Max,
                     "Dwarf Version",
                     sess.dwarf_version(),
                 );
diff --git a/tests/ui/lto/dwarf-mixed-versions-lto.stderr b/tests/ui/lto/dwarf-mixed-versions-lto.stderr
deleted file mode 100644
index 15988383c29..00000000000
--- a/tests/ui/lto/dwarf-mixed-versions-lto.stderr
+++ /dev/null
@@ -1,4 +0,0 @@
-warning: linking module flags 'Dwarf Version': IDs have conflicting values ('i32 4' from  with 'i32 5' from dwarf_mixed_versions_lto.7f4a44b55cf2f174-cgu.0)
-
-warning: 1 warning emitted
-