[llvm] [llvm-dwp] Give more information when incompatible version found (PR #168511)
Jinjie Huang via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 18 02:47:28 PST 2025
https://github.com/Jinjie-Huang created https://github.com/llvm/llvm-project/pull/168511
Provide more information when detecting a DWARF version mismatch in .dwo files to help locate the issue, aligning with other similar errors.
>From 0fd50382b0bf62ee8c78d21555885b6ada576075 Mon Sep 17 00:00:00 2001
From: huangjinjie <huangjinjie at bytedance.com>
Date: Tue, 18 Nov 2025 18:40:12 +0800
Subject: [PATCH] add more detail when incompatible version found
---
llvm/lib/DWP/DWP.cpp | 4 +++-
.../llvm-dwp/X86/incompatible_dwarf_version.test | 15 +++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
create mode 100644 llvm/test/tools/llvm-dwp/X86/incompatible_dwarf_version.test
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() {}
More information about the llvm-commits
mailing list