forked from OSchip/llvm-project
dsymutil: Fix the DWOId mismatch check for cached modules.
In verbose mode, we emit a warning if the DWOId of a skeleton CU mismatches the DWOId of the referenced module. This patch updates the cached DWOId after a module has been loaded to the DWOId of the module on disk (instead of storing the DWOId we expected to load). This allows us to correctly emit the mismatch warning for all subsequent object files that want to import the same module. This patch also ensures both warnings are only emitted in verbose mode. rdar://problem/26214027 llvm-svn: 269383
This commit is contained in:
parent
55c28889c1
commit
e1bc3e2027
|
@ -14,10 +14,17 @@
|
|||
-fdisable-module-hash mismatch.m -o /dev/null
|
||||
*/
|
||||
|
||||
// RUN: llvm-dsymutil --verbose -f -oso-prepend-path=%p/../Inputs/mismatch \
|
||||
// RUN: rm -rf %t.dir && mkdir %t.dir
|
||||
// RUN: cp %p/../Inputs/mismatch/1.o %p/../Inputs/mismatch/mismatch.pcm %t.dir
|
||||
// RUN: cp %p/../Inputs/mismatch/1.o %t.dir/2.o
|
||||
// RUN: llvm-dsymutil --verbose -f -oso-prepend-path=%t.dir \
|
||||
// RUN: -y %p/dummy-debug-map.map -o %t.bin 2>&1 | FileCheck %s
|
||||
|
||||
@import mismatch;
|
||||
|
||||
void f() {}
|
||||
// Mismatch after importing the module.
|
||||
// CHECK: warning: hash mismatch
|
||||
// Mismatch in the cache.
|
||||
// CHECK: warning: hash mismatch
|
||||
// CHECK: cached
|
||||
|
|
|
@ -3249,7 +3249,10 @@ bool DwarfLinker::registerModuleReference(
|
|||
|
||||
auto Cached = ClangModules.find(PCMfile);
|
||||
if (Cached != ClangModules.end()) {
|
||||
if (Cached->second != DwoId)
|
||||
// FIXME: Until PR27449 (https://llvm.org/bugs/show_bug.cgi?id=27449) is
|
||||
// fixed in clang, only warn about DWO_id mismatches in verbose mode.
|
||||
// ASTFileSignatures will change randomly when a module is rebuilt.
|
||||
if (Options.Verbose && (Cached->second != DwoId))
|
||||
reportWarning(Twine("hash mismatch: this object file was built against a "
|
||||
"different version of the module ") + PCMfile);
|
||||
if (Options.Verbose)
|
||||
|
@ -3343,10 +3346,15 @@ void DwarfLinker::loadClangModule(StringRef Filename, StringRef ModulePath,
|
|||
// FIXME: Until PR27449 (https://llvm.org/bugs/show_bug.cgi?id=27449) is
|
||||
// fixed in clang, only warn about DWO_id mismatches in verbose mode.
|
||||
// ASTFileSignatures will change randomly when a module is rebuilt.
|
||||
if (Options.Verbose && (getDwoId(*CUDie, *CU) != DwoId))
|
||||
reportWarning(
|
||||
Twine("hash mismatch: this object file was built against a "
|
||||
"different version of the module ") + Filename);
|
||||
uint64_t PCMDwoId = getDwoId(*CUDie, *CU);
|
||||
if (PCMDwoId != DwoId) {
|
||||
if (Options.Verbose)
|
||||
reportWarning(
|
||||
Twine("hash mismatch: this object file was built against a "
|
||||
"different version of the module ") + Filename);
|
||||
// Update the cache entry with the DwoId of the module loaded from disk.
|
||||
ClangModules[Filename] = PCMDwoId;
|
||||
}
|
||||
|
||||
// Add this module.
|
||||
Unit = llvm::make_unique<CompileUnit>(*CU, UnitID++, !Options.NoODR,
|
||||
|
|
Loading…
Reference in New Issue