[llvm] [llvm-dwp] Give more information when incompatible version found (PR #168511)

via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 18 02:48:01 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-debuginfo

Author: Jinjie Huang  (Jinjie-Huang)

<details>
<summary>Changes</summary>

Provide more information when detecting a DWARF version mismatch in .dwo files to help locate the issue, aligning with other similar errors.

---
Full diff: https://github.com/llvm/llvm-project/pull/168511.diff


2 Files Affected:

- (modified) llvm/lib/DWP/DWP.cpp (+3-1) 
- (added) llvm/test/tools/llvm-dwp/X86/incompatible_dwarf_version.test (+15) 


``````````diff
diff --git a/llvm/lib/DWP/DWP.cpp b/llvm/lib/DWP/DWP.cpp
index b565edbfe96db..a6624339f704f 100644
--- a/llvm/lib/DWP/DWP.cpp
+++ b/llvm/lib/DWP/DWP.cpp
@@ -709,7 +709,9 @@ Error write(MCStreamer &Out, ArrayRef<std::string> Inputs,
       Version = Header.Version;
       IndexVersion = Version < 5 ? 2 : 5;
     } else if (Version != Header.Version) {
-      return make_error<DWPError>("incompatible DWARF compile unit versions.");
+      return make_error<DWPError>(
+          Input + ": incompatible DWARF compile unit version, found " +
+          utostr(Header.Version) + " and expecting " + utostr(Version));
     }
 
     writeStringsAndOffsets(Out, Strings, StrOffsetSection, CurStrSection,
diff --git a/llvm/test/tools/llvm-dwp/X86/incompatible_dwarf_version.test b/llvm/test/tools/llvm-dwp/X86/incompatible_dwarf_version.test
new file mode 100644
index 0000000000000..886fe834a3263
--- /dev/null
+++ b/llvm/test/tools/llvm-dwp/X86/incompatible_dwarf_version.test
@@ -0,0 +1,15 @@
+RUN: rm -rf %t && split-file %s %t && cd %t
+RUN: clang++ -g -gsplit-dwarf -gdwarf-5 -c %t/a.cpp -o %t/a.o
+RUN: clang++ -g -gsplit-dwarf -gdwarf-4 -c %t/b.cpp -o %t/b.o
+RUN: clang++ %t/a.o %t/b.o -o %t/main.exe
+RUN: not llvm-dwp -e %t/main.exe -o %t/main.exe.dwp 2>&1 | FileCheck %s
+
+# CHECK: error: {{.*}}b.dwo: incompatible DWARF compile unit version, found 4 and expecting 5
+
+;--- a.cpp
+int main() {
+    return 0;
+}
+
+;--- b.cpp
+void b() {}

``````````

</details>


https://github.com/llvm/llvm-project/pull/168511


More information about the llvm-commits mailing list