1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
|
// Test that modifications to a common header (imported from both a PCH and a TU)
// cause rebuilds of dependent modules imported from the TU on incremental build.
// RUN: rm -rf %t
// RUN: split-file %s %t
//--- module.modulemap
module mod_common { header "mod_common.h" }
module mod_tu { header "mod_tu.h" }
module mod_tu_extra { header "mod_tu_extra.h" }
//--- mod_common.h
#define MOD_COMMON_MACRO 0
//--- mod_tu.h
#include "mod_common.h"
#if MOD_COMMON_MACRO
#include "mod_tu_extra.h"
#endif
//--- mod_tu_extra.h
//--- prefix.h
#include "mod_common.h"
//--- tu.c
#include "mod_tu.h"
// Clean: scan the PCH.
// RUN: clang-scan-deps -format experimental-full -o %t/deps_pch_clean.json -- \
// RUN: %clang -x c-header %t/prefix.h -o %t/prefix.h.pch \
// RUN: -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache
// Clean: build the PCH.
// RUN: %deps-to-rsp %t/deps_pch_clean.json --module-name mod_common > %t/mod_common.rsp
// RUN: %deps-to-rsp %t/deps_pch_clean.json --tu-index 0 > %t/pch.rsp
// RUN: %clang @%t/mod_common.rsp
// RUN: %clang @%t/pch.rsp
// Clean: scan the TU.
// RUN: clang-scan-deps -format experimental-full -o %t/deps_tu_clean.json -- \
// RUN: %clang -c %t/tu.c -o %t/tu.o -include %t/prefix.h \
// RUN: -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache
// RUN: cat %t/deps_tu_clean.json | sed 's:\\\\\?:/:g' | FileCheck %s --check-prefix=CHECK-TU-CLEAN -DPREFIX=%/t
// CHECK-TU-CLEAN: {
// CHECK-TU-CLEAN-NEXT: "modules": [
// CHECK-TU-CLEAN-NEXT: {
// CHECK-TU-CLEAN-NEXT: "clang-module-deps": [],
// CHECK-TU-CLEAN-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
// CHECK-TU-CLEAN-NEXT: "command-line": [
// CHECK-TU-CLEAN: ],
// CHECK-TU-CLEAN-NEXT: "context-hash": "{{.*}}",
// CHECK-TU-CLEAN-NEXT: "file-deps": [
// CHECK-TU-CLEAN-NEXT: "[[PREFIX]]/module.modulemap",
// CHECK-TU-CLEAN-NEXT: "[[PREFIX]]/mod_tu.h"
// CHECK-TU-CLEAN-NEXT: ],
// CHECK-TU-CLEAN-NEXT: "link-libraries": [],
// CHECK-TU-CLEAN-NEXT: "name": "mod_tu"
// CHECK-TU-CLEAN-NEXT: }
// CHECK-TU-CLEAN-NEXT: ],
// CHECK-TU-CLEAN-NEXT: "translation-units": [
// CHECK-TU-CLEAN-NEXT: {
// CHECK-TU-CLEAN-NEXT: "commands": [
// CHECK-TU-CLEAN-NEXT: {
// CHECK-TU-CLEAN-NEXT: "clang-context-hash": "{{.*}}",
// CHECK-TU-CLEAN-NEXT: "clang-module-deps": [
// CHECK-TU-CLEAN-NEXT: {
// CHECK-TU-CLEAN-NEXT: "context-hash": "{{.*}}",
// CHECK-TU-CLEAN-NEXT: "module-name": "mod_tu"
// CHECK-TU-CLEAN-NEXT: }
// CHECK-TU-CLEAN-NEXT: ],
// CHECK-TU-CLEAN-NEXT: "command-line": [
// CHECK-TU-CLEAN: ],
// CHECK-TU-CLEAN-NEXT: "executable": "{{.*}}",
// CHECK-TU-CLEAN-NEXT: "file-deps": [
// CHECK-TU-CLEAN-NEXT: "[[PREFIX]]/tu.c",
// CHECK-TU-CLEAN-NEXT: "[[PREFIX]]/prefix.h.pch"
// CHECK-TU-CLEAN-NEXT: ],
// CHECK-TU-CLEAN-NEXT: "input-file": "[[PREFIX]]/tu.c"
// CHECK-TU-CLEAN-NEXT: }
// CHECK-TU-CLEAN-NEXT: ]
// CHECK-TU-CLEAN-NEXT: }
// CHECK-TU-CLEAN: ]
// CHECK-TU-CLEAN: }
// Clean: build the TU.
// RUN: %deps-to-rsp %t/deps_tu_clean.json --module-name mod_tu > %t/mod_tu.rsp
// RUN: %deps-to-rsp %t/deps_tu_clean.json --tu-index 0 > %t/tu.rsp
// RUN: %clang @%t/mod_tu.rsp
// RUN: %clang @%t/tu.rsp
// Incremental: modify the common module.
// RUN: sleep 1
// RUN: echo "#define MOD_COMMON_MACRO 1" > %t/mod_common.h
// Incremental: scan the PCH.
// RUN: clang-scan-deps -format experimental-full -o %t/deps_pch_incremental.json -- \
// RUN: %clang -x c-header %t/prefix.h -o %t/prefix.h.pch \
// RUN: -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache
// Incremental: build the PCH.
// RUN: %deps-to-rsp %t/deps_pch_incremental.json --module-name mod_common > %t/mod_common.rsp
// RUN: %deps-to-rsp %t/deps_pch_incremental.json --tu-index 0 > %t/pch.rsp
// RUN: %clang @%t/mod_common.rsp
// RUN: %clang @%t/pch.rsp
// Incremental: scan the TU. This needs to invalidate modules imported from the
// TU that depend on modules imported from the PCH and discover the
// new dependency on 'mod_tu_extra'.
// RUN: clang-scan-deps -format experimental-full -o %t/deps_tu_incremental.json -- \
// RUN: %clang -c %t/tu.c -o %t/tu.o -include %t/prefix.h \
// RUN: -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache
// RUN: cat %t/deps_tu_incremental.json | sed 's:\\\\\?:/:g' | FileCheck %s --check-prefix=CHECK-TU-INCREMENTAL -DPREFIX=%/t
// CHECK-TU-INCREMENTAL: {
// CHECK-TU-INCREMENTAL-NEXT: "modules": [
// CHECK-TU-INCREMENTAL-NEXT: {
// CHECK-TU-INCREMENTAL-NEXT: "clang-module-deps": [
// CHECK-TU-INCREMENTAL-NEXT: {
// CHECK-TU-INCREMENTAL-NEXT: "context-hash": "{{.*}}",
// CHECK-TU-INCREMENTAL-NEXT: "module-name": "mod_tu_extra"
// CHECK-TU-INCREMENTAL-NEXT: }
// CHECK-TU-INCREMENTAL-NEXT: ],
// CHECK-TU-INCREMENTAL-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
// CHECK-TU-INCREMENTAL-NEXT: "command-line": [
// CHECK-TU-INCREMENTAL: ],
// CHECK-TU-INCREMENTAL-NEXT: "context-hash": "{{.*}}",
// CHECK-TU-INCREMENTAL-NEXT: "file-deps": [
// CHECK-TU-INCREMENTAL-NEXT: "[[PREFIX]]/module.modulemap",
// CHECK-TU-INCREMENTAL-NEXT: "[[PREFIX]]/mod_tu.h"
// CHECK-TU-INCREMENTAL-NEXT: ],
// CHECK-TU-INCREMENTAL-NEXT: "link-libraries": [],
// CHECK-TU-INCREMENTAL-NEXT: "name": "mod_tu"
// CHECK-TU-INCREMENTAL-NEXT: },
// CHECK-TU-INCREMENTAL-NEXT: {
// CHECK-TU-INCREMENTAL-NEXT: "clang-module-deps": [],
// CHECK-TU-INCREMENTAL-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
// CHECK-TU-INCREMENTAL-NEXT: "command-line": [
// CHECK-TU-INCREMENTAL: ],
// CHECK-TU-INCREMENTAL-NEXT: "context-hash": "{{.*}}",
// CHECK-TU-INCREMENTAL-NEXT: "file-deps": [
// CHECK-TU-INCREMENTAL-NEXT: "[[PREFIX]]/module.modulemap",
// CHECK-TU-INCREMENTAL-NEXT: "[[PREFIX]]/mod_tu_extra.h"
// CHECK-TU-INCREMENTAL-NEXT: ],
// CHECK-TU-INCREMENTAL-NEXT: "link-libraries": [],
// CHECK-TU-INCREMENTAL-NEXT: "name": "mod_tu_extra"
// CHECK-TU-INCREMENTAL-NEXT: }
// CHECK-TU-INCREMENTAL-NEXT: ],
// CHECK-TU-INCREMENTAL-NEXT: "translation-units": [
// CHECK-TU-INCREMENTAL-NEXT: {
// CHECK-TU-INCREMENTAL-NEXT: "commands": [
// CHECK-TU-INCREMENTAL-NEXT: {
// CHECK-TU-INCREMENTAL-NEXT: "clang-context-hash": "{{.*}}",
// CHECK-TU-INCREMENTAL-NEXT: "clang-module-deps": [
// CHECK-TU-INCREMENTAL-NEXT: {
// CHECK-TU-INCREMENTAL-NEXT: "context-hash": "{{.*}}",
// CHECK-TU-INCREMENTAL-NEXT: "module-name": "mod_tu"
// CHECK-TU-INCREMENTAL-NEXT: }
// CHECK-TU-INCREMENTAL-NEXT: ],
// CHECK-TU-INCREMENTAL-NEXT: "command-line": [
// CHECK-TU-INCREMENTAL: ],
// CHECK-TU-INCREMENTAL-NEXT: "executable": "{{.*}}",
// CHECK-TU-INCREMENTAL-NEXT: "file-deps": [
// CHECK-TU-INCREMENTAL-NEXT: "[[PREFIX]]/tu.c",
// CHECK-TU-INCREMENTAL-NEXT: "[[PREFIX]]/prefix.h.pch"
// CHECK-TU-INCREMENTAL-NEXT: ],
// CHECK-TU-INCREMENTAL-NEXT: "input-file": "[[PREFIX]]/tu.c"
// CHECK-TU-INCREMENTAL-NEXT: }
// CHECK-TU-INCREMENTAL-NEXT: ]
// CHECK-TU-INCREMENTAL-NEXT: }
// CHECK-TU-INCREMENTAL: ]
// CHECK-TU-INCREMENTAL: }
// Incremental: build the TU.
// RUN: %deps-to-rsp %t/deps_tu_incremental.json --module-name mod_tu_extra > %t/mod_tu_extra.rsp
// RUN: %deps-to-rsp %t/deps_tu_incremental.json --module-name mod_tu > %t/mod_tu.rsp
// RUN: %deps-to-rsp %t/deps_tu_incremental.json --tu-index 0 > %t/tu.rsp
// RUN: %clang @%t/mod_tu_extra.rsp
// RUN: %clang @%t/mod_tu.rsp
// RUN: %clang @%t/tu.rsp
|