This PR changes how `ModuleManager` deduplicates module files. Previously, `ModuleManager` used `FileEntry` for assigning unique identity to module files. This works fine for explicitly-built modules because they don't change during the lifetime of a single Clang instance. For implicitly-built modules however, there are two issues: 1. The `FileEntry` objects are deduplicated by `FileManager` based on the inode number. Some file systems reuse inode numbers of previously removed files. Because implicitly-built module files are rapidly removed and created, this deduplication breaks and compilations may fail spuriously when inode numbers are recycled during the lifetime of a single Clang instance. 2. The first thing `ModuleManager` does when loading a module file is consulting the `FileManager` and checking the file size and modification time match the expectation of the importer. This is done even when such module file already lives in the `InMemoryModuleCache`. This introduces racy behavior into the mechanism that explicitly tries to solve race conditions, and may lead into spurious compilation failures. This PR identifies implicitly-built module files by a pair of `DirectoryEntry` of the module cache path and the path suffix `<context-hash>/<module-name>-<module-map-path-hash>.pcm`. This gives us canonicalization of the user-provided module cache path without turning to `FileEntry` for the PCM file. The path suffix is Clang-generated and is already canonical. Some tests needed to be updated because the module cache path directory was also used as an include directory. This PR relies on not caching the non-existence of the module cache directory in the `FileManager`. When other parts of Clang are trying to look up the same path and cache its non-existence, things break. This is probably very specific to some of our tests and not how users are setting up their compilations.
89 lines
3.3 KiB
Objective-C
89 lines
3.3 KiB
Objective-C
// UNSUPPORTED: target={{.*}}-zos{{.*}}, target={{.*}}-aix{{.*}}
|
|
// Test that debug info is emitted for an Objective-C module and
|
|
// a precompiled header.
|
|
|
|
// REQUIRES: asserts
|
|
|
|
// Modules:
|
|
// RUN: rm -rf %t
|
|
// RUN: %clang_cc1 -x objective-c -fmodules -fmodule-format=obj \
|
|
// RUN: -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t/cache %s \
|
|
// RUN: -I %S/Inputs -I %t -emit-llvm -o %t.ll \
|
|
// RUN: -mllvm -debug-only=pchcontainer &>%t-mod.ll
|
|
// RUN: cat %t-mod.ll | FileCheck %s
|
|
// RUN: cat %t-mod.ll | FileCheck %s --check-prefix=CHECK2
|
|
|
|
// PCH:
|
|
// RUN: %clang_cc1 -x objective-c -emit-pch -fmodule-format=obj -I %S/Inputs \
|
|
// RUN: -o %t.pch %S/Inputs/DebugObjC.h \
|
|
// RUN: -mllvm -debug-only=pchcontainer &>%t-pch.ll
|
|
// RUN: cat %t-pch.ll | FileCheck %s
|
|
// RUN: cat %t-pch.ll | FileCheck %s --check-prefix=CHECK2
|
|
|
|
#ifdef MODULES
|
|
@import DebugObjC;
|
|
#endif
|
|
|
|
// CHECK: distinct !DICompileUnit(language: DW_LANG_ObjC, file: ![[FILE:[0-9]+]],
|
|
// CHECK-SAME: isOptimized: false
|
|
|
|
// CHECK: ![[FILE]] = !DIFile(filename: "{{DebugObjC|.*DebugObjC.h}}"
|
|
|
|
// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type,
|
|
// CHECK-SAME: scope: ![[MODULE:[0-9]+]],
|
|
// CHECK: ![[MODULE]] = !DIModule(scope: null, name: "DebugObjC
|
|
|
|
// CHECK: ![[TD_ENUM:.*]] = !DICompositeType(tag: DW_TAG_enumeration_type,
|
|
// CHECK-NOT: name:
|
|
// CHECK-SAME: elements:
|
|
|
|
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDecl",
|
|
// CHECK-SAME: scope: ![[MODULE]],
|
|
// CHECK-SAME: runtimeLang: DW_LANG_ObjC
|
|
|
|
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClass",
|
|
// CHECK-SAME: scope: ![[MODULE]],
|
|
// CHECK-SAME: elements
|
|
|
|
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClassWithPrivateIVars",
|
|
// CHECK-SAME: scope: ![[MODULE]],
|
|
// CHECK-SAME: elements
|
|
|
|
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDeclared"
|
|
// CHECK-SAME: elements:
|
|
|
|
// CHECK: ![[TD_UNION:.*]] = distinct !DICompositeType(tag: DW_TAG_union_type,
|
|
// CHECK-NOT: name:
|
|
// CHECK-SAME: elements:
|
|
|
|
// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "TypedefUnion",
|
|
// CHECK-SAME: baseType: ![[TD_UNION]])
|
|
|
|
// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "TypedefEnum",
|
|
// CHECK-SAME: baseType: ![[TD_ENUM:.*]])
|
|
|
|
// CHECK: ![[TD_STRUCT:.*]] = distinct !DICompositeType(tag: DW_TAG_structure_type,
|
|
// CHECK-NOT: name:
|
|
// CHECK-SAME: elements:
|
|
// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "TypedefStruct",
|
|
// CHECK-SAME: baseType: ![[TD_STRUCT]])
|
|
|
|
// CHECK: !DICompositeType(tag: DW_TAG_union_type,
|
|
// CHECK-NOT: name:
|
|
// CHECK-SAME: )
|
|
|
|
// CHECK: !DICompositeType(tag: DW_TAG_structure_type,
|
|
// CHECK-NOT: name:
|
|
// CHECK-SAME: )
|
|
|
|
// CHECK-NEG-NOT: !DICompositeType(tag: DW_TAG_structure_type, name: "PureForwardDecl"
|
|
|
|
// The output order is sublty different for module vs. pch,
|
|
// so these are checked separately:
|
|
//
|
|
// CHECK2: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDecl",
|
|
// CHECK2: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClass",
|
|
// CHECK2: !DIObjCProperty(name: "property",
|
|
// CHECK2: !DIDerivedType(tag: DW_TAG_member, name: "ivar"
|
|
// CHECK2: !DIDerivedType(tag: DW_TAG_typedef, name: "InnerEnum"
|