diff --git a/llvm/lib/DWP/DWP.cpp b/llvm/lib/DWP/DWP.cpp index b565edbfe96db..ab73651846e45 100644 --- a/llvm/lib/DWP/DWP.cpp +++ b/llvm/lib/DWP/DWP.cpp @@ -650,6 +650,7 @@ Error write(MCStreamer &Out, ArrayRef Inputs, uint32_t ContributionOffsets[8] = {}; uint16_t Version = 0; uint32_t IndexVersion = 0; + StringRef FirstInput; bool AnySectionOverflow = false; DWPStringPool Strings(Out, StrSection); @@ -708,8 +709,12 @@ Error write(MCStreamer &Out, ArrayRef Inputs, if (Version == 0) { Version = Header.Version; IndexVersion = Version < 5 ? 2 : 5; + FirstInput = Input; } else if (Version != Header.Version) { - return make_error("incompatible DWARF compile unit versions."); + return make_error( + "incompatible DWARF compile unit version: " + Input + " (version " + + utostr(Header.Version) + ") and " + FirstInput.str() + " (version " + + 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..9f7da58c5d463 --- /dev/null +++ b/llvm/test/tools/llvm-dwp/X86/incompatible_dwarf_version.test @@ -0,0 +1,6 @@ +RUN: rm -rf %t && mkdir -p %t && cd %t +RUN: llvm-mc --triple=x86_64-unknown-linux --filetype=obj --split-dwarf-file=%t/main_v5.dwo -dwarf-version=5 %p/../Inputs/overflow/main_v5.s -o %t/main_v5.o +RUN: llvm-mc --triple=x86_64-unknown-linux --filetype=obj --split-dwarf-file=%t/debug_info_v4.dwo -dwarf-version=4 %p/../Inputs/overflow/debug_info_v4.s -o %t/debug_info_v4.o +RUN: not llvm-dwp %t/main_v5.dwo %t/debug_info_v4.dwo -o main.dwp 2>&1 | FileCheck %s + +CHECK: error: incompatible DWARF compile unit version: {{.*}}debug_info_v4.dwo (version 4) and {{.*}}main_v5.dwo (version 5)