dsymutil: Provide better warnings when clang modules cannot be found.
rdar://problem/22823264 llvm-svn: 257784
This commit is contained in:
parent
b76bf106b1
commit
a9e2383528
Binary file not shown.
|
@ -1,13 +1,26 @@
|
|||
Test for module-related warnings.
|
||||
This reuses the files from the modules.m testcase.
|
||||
# Test for module-related warnings.
|
||||
# This reuses the inputs from the modules.m testcase.
|
||||
#
|
||||
# RUN: rm -rf %t.dir && mkdir %t.dir
|
||||
# RUN: cp %p/../Inputs/modules/1.o %p/../Inputs/modules/Foo.pcm %t.dir
|
||||
#
|
||||
# RUN: llvm-dsymutil -f -oso-prepend-path=%t.dir -y \
|
||||
# RUN: %p/dummy-debug-map.map -o %t 2>&1 | FileCheck %s
|
||||
#
|
||||
# Module-not-found should be reported only once.
|
||||
# The exact error message depends on the OS so we don't check for it.
|
||||
# CHECK: warning: {{.*}}Bar.pcm:
|
||||
# CHECK-NOT: warning: {{.*}}Bar.pcm:
|
||||
#
|
||||
# RUN: cp %p/../Inputs/modules/libstatic.a %t.dir
|
||||
# RUN: llvm-dsymutil -f -oso-prepend-path=%t.dir -y %s -o %t 2>&1 | FileCheck %s
|
||||
# CHECK: rebuild the module cache
|
||||
# CHECK-NOT: static libraries
|
||||
|
||||
RUN: rm -rf %t.dir && mkdir %t.dir
|
||||
RUN: cp %p/../Inputs/modules/1.o %p/../Inputs/modules/Foo.pcm %t.dir
|
||||
|
||||
RUN: llvm-dsymutil -f -oso-prepend-path=%t.dir -y \
|
||||
RUN: %p/dummy-debug-map.map -o %t 2>&1 | FileCheck %s
|
||||
|
||||
Module-not-found should be reported only once.
|
||||
The exact error message deoends on the OS so we don't check for it.
|
||||
CHECK: warning: {{.*}}Bar.pcm:
|
||||
CHECK-NOT: warning: {{.*}}Bar.pcm:
|
||||
---
|
||||
triple: 'x86_64-apple-darwin'
|
||||
objects:
|
||||
- filename: libstatic.a(1.o)
|
||||
symbols:
|
||||
- { sym: __Z3foov, objAddr: 0x0, binAddr: 0x10000, size: 0x10 }
|
||||
...
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===- tools/dsymutil/DebugMap.h - Generic debug map representation -------===//
|
||||
//=== tools/dsymutil/DebugMap.h - Generic debug map representation -*- C++ -*-//
|
||||
//
|
||||
// The LLVM Linker
|
||||
//
|
||||
|
|
|
@ -1458,6 +1458,9 @@ private:
|
|||
|
||||
/// Mapping the PCM filename to the DwoId.
|
||||
StringMap<uint64_t> ClangModules;
|
||||
|
||||
bool ModuleCacheHintDisplayed = false;
|
||||
bool ArchiveHintDisplayed = false;
|
||||
};
|
||||
|
||||
/// Similar to DWARFUnitSection::getUnitForOffset(), but returning our
|
||||
|
@ -3237,8 +3240,38 @@ void DwarfLinker::loadClangModule(StringRef Filename, StringRef ModulePath,
|
|||
auto &Obj =
|
||||
ModuleMap.addDebugMapObject(Path, sys::TimeValue::PosixZeroTime());
|
||||
auto ErrOrObj = loadObject(ObjHolder, Obj, ModuleMap);
|
||||
if (!ErrOrObj)
|
||||
if (!ErrOrObj) {
|
||||
// Try and emit more helpful warnings by applying some heuristics.
|
||||
StringRef ObjFile = CurrentDebugObject->getObjectFilename();
|
||||
bool isClangModule = sys::path::extension(Filename).equals(".pcm");
|
||||
bool isArchive = ObjFile.endswith(")");
|
||||
if (isClangModule) {
|
||||
sys::path::remove_filename(Path);
|
||||
StringRef ModuleCacheDir = sys::path::parent_path(Path);
|
||||
if (sys::fs::exists(ModuleCacheDir)) {
|
||||
// If the module's parent directory exists, we assume that the module
|
||||
// cache has expired and was pruned by clang. A more adventurous
|
||||
// dsymutil would invoke clang to rebuild the module now.
|
||||
if (!ModuleCacheHintDisplayed) {
|
||||
errs() << "note: The clang module cache may have expired since this "
|
||||
"object file was built. Rebuilding the object file will "
|
||||
"rebuild the module cache.\n";
|
||||
ModuleCacheHintDisplayed = true;
|
||||
}
|
||||
} else if (isArchive) {
|
||||
// If the module cache directory doesn't exist at all and the object
|
||||
// file is inside a static library, we assume that the static library
|
||||
// was built on a different machine. We don't want to discourage module
|
||||
// debugging for convenience libraries within a project though.
|
||||
if (!ArchiveHintDisplayed) {
|
||||
errs() << "note: Module debugging should be disabled when shipping "
|
||||
"static libraries.\n";
|
||||
ArchiveHintDisplayed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
std::unique_ptr<CompileUnit> Unit;
|
||||
|
||||
|
|
Loading…
Reference in New Issue