]>
Commit | Line | Data |
---|---|---|
c910f83b | 1 | SUITE_pch_PROBE() { |
0d06da78 JR |
2 | touch pch.h empty.c |
3 | mkdir dir | |
4 | ||
3c47a8a2 | 5 | if ! $COMPILER $SYSROOT -fpch-preprocess pch.h 2>/dev/null \ |
c910f83b | 6 | || [ ! -f pch.h.gch ]; then |
0d06da78 JR |
7 | echo "compiler ($($COMPILER --version | head -n 1)) doesn't support precompiled headers" |
8 | fi | |
9 | ||
3c47a8a2 JR |
10 | $COMPILER $SYSROOT -c pch.h -o dir/pch.h.gch 2>/dev/null |
11 | if ! $COMPILER $SYSROOT -c -include dir/pch.h empty.c 2>/dev/null; then | |
0d06da78 | 12 | echo "compiler ($($COMPILER --version | head -n 1)) seems to have broken support for precompiled headers" |
c910f83b JR |
13 | fi |
14 | } | |
15 | ||
16 | SUITE_pch_SETUP() { | |
17 | unset CCACHE_NODIRECT | |
18 | ||
19 | cat <<EOF >pch.c | |
20 | #include "pch.h" | |
21 | int main() | |
22 | { | |
23 | void *p = NULL; | |
24 | return 0; | |
25 | } | |
26 | EOF | |
27 | cat <<EOF >pch.h | |
28 | #include <stdlib.h> | |
29 | EOF | |
30 | backdate pch.h | |
31 | cat <<EOF >pch2.c | |
32 | int main() | |
33 | { | |
34 | void *p = NULL; | |
35 | return 0; | |
36 | } | |
37 | EOF | |
38 | } | |
39 | ||
40 | SUITE_pch() { | |
2f89ccfc LL |
41 | # Clang should generally be compatible with GCC and so most of the tests |
42 | # can be shared. There are some differences though: | |
30fdd670 JR |
43 | # |
44 | # - Both GCC and Clang keep an absolute path reference to the original file | |
45 | # except that Clang uses that reference to validate the pch and GCC | |
46 | # ignores the reference (i.e. the original file can be removed). | |
47 | # - Clang can only use pch headers on the command line and not as an | |
48 | # #include statement inside a source file, because it silently ignores | |
49 | # -fpch-preprocess and does not output pragma GCC pch_preprocess. | |
2f89ccfc | 50 | # - Clang has -include-pch to directly include a PCH file without any magic |
30fdd670 | 51 | # of searching for a .gch file. |
2f89ccfc | 52 | # |
30fdd670 JR |
53 | # Put tests that work with both compilers in pch_suite_common and put |
54 | # compiler-specific tests in pch_suite_clang/pch_suite_gcc. | |
2f89ccfc LL |
55 | |
56 | pch_suite_common | |
c910f83b | 57 | if $COMPILER_TYPE_CLANG; then |
de5778ac OS |
58 | if ! [ $COMPILER_BIN = "gcc" ] || $RUN_WIN_XFAIL; then |
59 | pch_suite_clang | |
60 | fi | |
c910f83b JR |
61 | else |
62 | pch_suite_gcc | |
63 | fi | |
64 | } | |
65 | ||
2f89ccfc | 66 | pch_suite_common() { |
c910f83b JR |
67 | # ------------------------------------------------------------------------- |
68 | TEST "Create .gch, -c, no -o, without opt-in" | |
69 | ||
70 | $CCACHE_COMPILE $SYSROOT -c pch.h | |
5620af79 JR |
71 | expect_stat direct_cache_hit 0 |
72 | expect_stat preprocessed_cache_hit 0 | |
73 | expect_stat cache_miss 0 | |
74 | expect_stat could_not_use_precompiled_header 1 | |
c910f83b JR |
75 | |
76 | # ------------------------------------------------------------------------- | |
77 | TEST "Create .gch, no -c, -o, without opt-in" | |
78 | ||
79 | $CCACHE_COMPILE pch.h -o pch.gch | |
5620af79 JR |
80 | expect_stat direct_cache_hit 0 |
81 | expect_stat preprocessed_cache_hit 0 | |
82 | expect_stat cache_miss 0 | |
83 | expect_stat could_not_use_precompiled_header 1 | |
c910f83b JR |
84 | |
85 | # ------------------------------------------------------------------------- | |
86 | TEST "Create .gch, -c, no -o, with opt-in" | |
87 | ||
88 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines" $CCACHE_COMPILE $SYSROOT -c pch.h | |
5620af79 JR |
89 | expect_stat direct_cache_hit 0 |
90 | expect_stat preprocessed_cache_hit 0 | |
91 | expect_stat cache_miss 1 | |
c910f83b JR |
92 | rm pch.h.gch |
93 | ||
94 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines" $CCACHE_COMPILE $SYSROOT -c pch.h | |
5620af79 JR |
95 | expect_stat direct_cache_hit 1 |
96 | expect_stat preprocessed_cache_hit 0 | |
97 | expect_stat cache_miss 1 | |
733f9880 | 98 | expect_exists pch.h.gch |
c910f83b | 99 | |
2f89ccfc LL |
100 | echo '#include <string.h> /*change pch*/' >>pch.h |
101 | backdate pch.h | |
102 | rm pch.h.gch | |
103 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines" $CCACHE_COMPILE $SYSROOT -c pch.h | |
5620af79 JR |
104 | expect_stat direct_cache_hit 1 |
105 | expect_stat preprocessed_cache_hit 0 | |
106 | expect_stat cache_miss 2 | |
733f9880 | 107 | expect_exists pch.h.gch |
2f89ccfc | 108 | |
c910f83b JR |
109 | # ------------------------------------------------------------------------- |
110 | TEST "Create .gch, no -c, -o, with opt-in" | |
111 | ||
2f89ccfc | 112 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines" $CCACHE_COMPILE $SYSROOT pch.h -o pch.gch |
5620af79 JR |
113 | expect_stat direct_cache_hit 0 |
114 | expect_stat preprocessed_cache_hit 0 | |
115 | expect_stat cache_miss 1 | |
c910f83b | 116 | |
2f89ccfc | 117 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines" $CCACHE_COMPILE $SYSROOT pch.h -o pch.gch |
5620af79 JR |
118 | expect_stat direct_cache_hit 1 |
119 | expect_stat preprocessed_cache_hit 0 | |
120 | expect_stat cache_miss 1 | |
733f9880 | 121 | expect_exists pch.gch |
c910f83b JR |
122 | |
123 | # ------------------------------------------------------------------------- | |
2f89ccfc | 124 | TEST "Use .gch, #include, remove pch.h" |
c910f83b | 125 | |
3c47a8a2 | 126 | $COMPILER $SYSROOT -c pch.h |
c910f83b JR |
127 | backdate pch.h.gch |
128 | rm pch.h | |
129 | ||
2f89ccfc | 130 | $CCACHE_COMPILE $SYSROOT -c pch.c 2>/dev/null |
5620af79 JR |
131 | expect_stat direct_cache_hit 0 |
132 | expect_stat preprocessed_cache_hit 0 | |
133 | expect_stat cache_miss 0 | |
c910f83b | 134 | # Preprocessor error because GCC can't find the real include file when |
2f89ccfc | 135 | # trying to preprocess (gcc -E will be called by ccache): |
5620af79 | 136 | expect_stat preprocessor_error 1 |
c910f83b JR |
137 | |
138 | # ------------------------------------------------------------------------- | |
53b1fef9 JR |
139 | include_pch_variants=( |
140 | "-include pch.h" | |
141 | "-includepch.h" | |
142 | ) | |
143 | for args in "${include_pch_variants[@]}"; do | |
144 | TEST "Use .gch, $args, no sloppiness" | |
145 | ||
146 | $COMPILER $SYSROOT -c pch.h | |
147 | backdate pch.h.gch | |
148 | ||
149 | $CCACHE_COMPILE $SYSROOT -c $args pch2.c | |
150 | expect_stat direct_cache_hit 0 | |
151 | expect_stat preprocessed_cache_hit 0 | |
152 | expect_stat cache_miss 0 | |
153 | # Must enable sloppy time macros: | |
154 | expect_stat could_not_use_precompiled_header 1 | |
155 | done | |
c910f83b JR |
156 | |
157 | # ------------------------------------------------------------------------- | |
2f89ccfc | 158 | TEST "Use .gch, -include" |
c910f83b | 159 | |
3c47a8a2 | 160 | $COMPILER $SYSROOT -c pch.h |
c910f83b | 161 | backdate pch.h.gch |
c910f83b JR |
162 | |
163 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c | |
5620af79 JR |
164 | expect_stat direct_cache_hit 0 |
165 | expect_stat preprocessed_cache_hit 0 | |
166 | expect_stat cache_miss 1 | |
c910f83b JR |
167 | |
168 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c | |
5620af79 JR |
169 | expect_stat direct_cache_hit 1 |
170 | expect_stat preprocessed_cache_hit 0 | |
171 | expect_stat cache_miss 1 | |
c910f83b | 172 | |
2f89ccfc LL |
173 | echo '#include <string.h> /*change pch*/' >>pch.h |
174 | backdate pch.h | |
3c47a8a2 | 175 | $COMPILER $SYSROOT -c pch.h |
2f89ccfc LL |
176 | backdate pch.h.gch |
177 | ||
de5778ac | 178 | if $RUN_WIN_XFAIL; then |
2f89ccfc | 179 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c |
5620af79 JR |
180 | expect_stat direct_cache_hit 1 |
181 | expect_stat preprocessed_cache_hit 0 | |
182 | expect_stat cache_miss 2 | |
2f89ccfc LL |
183 | |
184 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c | |
5620af79 JR |
185 | expect_stat direct_cache_hit 2 |
186 | expect_stat preprocessed_cache_hit 0 | |
187 | expect_stat cache_miss 2 | |
de5778ac | 188 | fi |
2f89ccfc | 189 | |
c910f83b | 190 | # ------------------------------------------------------------------------- |
2f89ccfc | 191 | TEST "Use .gch, preprocessor mode, -include" |
c910f83b | 192 | |
3c47a8a2 | 193 | $COMPILER $SYSROOT -c pch.h |
c910f83b | 194 | backdate pch.h.gch |
c910f83b | 195 | |
2f89ccfc | 196 | CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch.c |
5620af79 JR |
197 | expect_stat direct_cache_hit 0 |
198 | expect_stat preprocessed_cache_hit 0 | |
199 | expect_stat cache_miss 1 | |
2f89ccfc LL |
200 | |
201 | CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch.c | |
5620af79 JR |
202 | expect_stat direct_cache_hit 0 |
203 | expect_stat preprocessed_cache_hit 1 | |
204 | expect_stat cache_miss 1 | |
2f89ccfc LL |
205 | |
206 | echo '#include <string.h> /*change pch*/' >>pch.h | |
207 | backdate pch.h | |
3c47a8a2 | 208 | $COMPILER $SYSROOT -c pch.h |
2f89ccfc LL |
209 | backdate pch.h.gch |
210 | ||
211 | CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch.c | |
5620af79 JR |
212 | expect_stat direct_cache_hit 0 |
213 | expect_stat preprocessed_cache_hit 1 | |
214 | expect_stat cache_miss 2 | |
2f89ccfc LL |
215 | |
216 | CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch.c | |
5620af79 JR |
217 | expect_stat direct_cache_hit 0 |
218 | expect_stat preprocessed_cache_hit 2 | |
219 | expect_stat cache_miss 2 | |
2f89ccfc LL |
220 | |
221 | # ------------------------------------------------------------------------- | |
222 | TEST "Create .gch, -c, -o" | |
223 | ||
224 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines" $CCACHE_COMPILE $SYSROOT -c pch.h -o pch.h.gch | |
5620af79 JR |
225 | expect_stat direct_cache_hit 0 |
226 | expect_stat preprocessed_cache_hit 0 | |
227 | expect_stat cache_miss 1 | |
2f89ccfc LL |
228 | rm -f pch.h.gch |
229 | ||
230 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines" $CCACHE_COMPILE $SYSROOT -c pch.h -o pch.h.gch | |
5620af79 JR |
231 | expect_stat direct_cache_hit 1 |
232 | expect_stat preprocessed_cache_hit 0 | |
233 | expect_stat cache_miss 1 | |
733f9880 | 234 | expect_exists pch.h.gch |
2f89ccfc LL |
235 | |
236 | echo '#include <string.h> /*change pch*/' >>pch.h | |
237 | backdate pch.h | |
238 | rm pch.h.gch | |
239 | ||
240 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines" $CCACHE_COMPILE $SYSROOT -c pch.h -o pch.h.gch | |
5620af79 JR |
241 | expect_stat direct_cache_hit 1 |
242 | expect_stat preprocessed_cache_hit 0 | |
243 | expect_stat cache_miss 2 | |
733f9880 | 244 | expect_exists pch.h.gch |
c910f83b JR |
245 | |
246 | # ------------------------------------------------------------------------- | |
2f89ccfc | 247 | TEST "Use .gch, -include, PCH_EXTSUM=1" |
c910f83b | 248 | |
3c47a8a2 | 249 | $COMPILER $SYSROOT -c pch.h |
c910f83b | 250 | backdate pch.h.gch |
c910f83b | 251 | |
2f89ccfc LL |
252 | echo "original checksum" > pch.h.gch.sum |
253 | ||
254 | CCACHE_PCH_EXTSUM=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c | |
5620af79 JR |
255 | expect_stat direct_cache_hit 0 |
256 | expect_stat preprocessed_cache_hit 0 | |
257 | expect_stat cache_miss 1 | |
c910f83b | 258 | |
2f89ccfc | 259 | CCACHE_PCH_EXTSUM=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c |
5620af79 JR |
260 | expect_stat direct_cache_hit 1 |
261 | expect_stat preprocessed_cache_hit 0 | |
262 | expect_stat cache_miss 1 | |
c910f83b | 263 | |
2f89ccfc LL |
264 | echo "other checksum" > pch.h.gch.sum |
265 | CCACHE_PCH_EXTSUM=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c | |
5620af79 JR |
266 | expect_stat direct_cache_hit 1 |
267 | expect_stat preprocessed_cache_hit 0 | |
268 | expect_stat cache_miss 2 | |
2f89ccfc LL |
269 | |
270 | echo "original checksum" > pch.h.gch.sum | |
271 | CCACHE_PCH_EXTSUM=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c | |
5620af79 JR |
272 | expect_stat direct_cache_hit 2 |
273 | expect_stat preprocessed_cache_hit 0 | |
274 | expect_stat cache_miss 2 | |
2f89ccfc | 275 | |
30fdd670 JR |
276 | # With GCC, a newly generated PCH is always different, even if the contents |
277 | # should be exactly the same. And Clang stores file timestamps, so in this | |
278 | # case the PCH is different too. So without .sum a "changed" PCH would mean | |
279 | # a miss, but if the .sum doesn't change, it should be a hit. | |
2f89ccfc LL |
280 | |
281 | sleep 1 | |
282 | touch pch.h | |
3c47a8a2 | 283 | $COMPILER $SYSROOT -c pch.h |
2f89ccfc LL |
284 | backdate pch.h.gch |
285 | ||
286 | CCACHE_PCH_EXTSUM=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c | |
5620af79 JR |
287 | expect_stat direct_cache_hit 3 |
288 | expect_stat preprocessed_cache_hit 0 | |
289 | expect_stat cache_miss 2 | |
2f89ccfc | 290 | |
c910f83b | 291 | # ------------------------------------------------------------------------- |
2f89ccfc | 292 | TEST "Use .gch, -include, no PCH_EXTSUM" |
c910f83b | 293 | |
3c47a8a2 | 294 | $COMPILER $SYSROOT -c pch.h |
c910f83b | 295 | backdate pch.h.gch |
c910f83b | 296 | |
2f89ccfc LL |
297 | echo "original checksum" > pch.h.gch.sum |
298 | ||
299 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch.c | |
5620af79 JR |
300 | expect_stat direct_cache_hit 0 |
301 | expect_stat preprocessed_cache_hit 0 | |
302 | expect_stat cache_miss 1 | |
2f89ccfc LL |
303 | |
304 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch.c | |
5620af79 JR |
305 | expect_stat direct_cache_hit 1 |
306 | expect_stat preprocessed_cache_hit 0 | |
307 | expect_stat cache_miss 1 | |
2f89ccfc LL |
308 | |
309 | # external checksum not used, so no cache miss when changed | |
310 | echo "other checksum" > pch.h.gch.sum | |
311 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch.c | |
5620af79 JR |
312 | expect_stat direct_cache_hit 2 |
313 | expect_stat preprocessed_cache_hit 0 | |
314 | expect_stat cache_miss 1 | |
2f89ccfc LL |
315 | |
316 | # ------------------------------------------------------------------------- | |
317 | TEST "Use .gch, -include, other dir for .gch" | |
318 | ||
319 | mkdir -p dir | |
3c47a8a2 | 320 | $COMPILER $SYSROOT -c pch.h -o dir/pch.h.gch |
2f89ccfc LL |
321 | backdate dir/pch.h.gch |
322 | rm -f pch.h.gch | |
323 | ||
324 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include dir/pch.h pch2.c | |
5620af79 JR |
325 | expect_stat direct_cache_hit 0 |
326 | expect_stat preprocessed_cache_hit 0 | |
327 | expect_stat cache_miss 1 | |
2f89ccfc LL |
328 | |
329 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include dir/pch.h pch2.c | |
5620af79 JR |
330 | expect_stat direct_cache_hit 1 |
331 | expect_stat preprocessed_cache_hit 0 | |
332 | expect_stat cache_miss 1 | |
2f89ccfc LL |
333 | |
334 | echo '#include <string.h> /*change pch*/' >>pch.h | |
335 | backdate pch.h | |
3c47a8a2 | 336 | $COMPILER $SYSROOT -c pch.h -o dir/pch.h.gch |
2f89ccfc LL |
337 | backdate dir/pch.h.gch |
338 | ||
de5778ac | 339 | if $RUN_WIN_XFAIL; then |
2f89ccfc | 340 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include dir/pch.h pch2.c |
5620af79 JR |
341 | expect_stat direct_cache_hit 1 |
342 | expect_stat preprocessed_cache_hit 0 | |
343 | expect_stat cache_miss 2 | |
2f89ccfc LL |
344 | |
345 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include dir/pch.h pch2.c | |
5620af79 JR |
346 | expect_stat direct_cache_hit 2 |
347 | expect_stat preprocessed_cache_hit 0 | |
348 | expect_stat cache_miss 2 | |
de5778ac | 349 | fi |
2f89ccfc LL |
350 | rm -rf dir |
351 | ||
352 | # ------------------------------------------------------------------------- | |
353 | TEST "Use .gch, preprocessor mode, -include, other dir for .gch" | |
354 | ||
355 | mkdir -p dir | |
3c47a8a2 | 356 | $COMPILER $SYSROOT -c pch.h -o dir/pch.h.gch |
2f89ccfc LL |
357 | backdate dir/pch.h.gch |
358 | rm -f pch.h.gch | |
359 | ||
360 | CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include dir/pch.h pch.c | |
5620af79 JR |
361 | expect_stat direct_cache_hit 0 |
362 | expect_stat preprocessed_cache_hit 0 | |
363 | expect_stat cache_miss 1 | |
2f89ccfc LL |
364 | |
365 | CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include dir/pch.h pch.c | |
5620af79 JR |
366 | expect_stat direct_cache_hit 0 |
367 | expect_stat preprocessed_cache_hit 1 | |
368 | expect_stat cache_miss 1 | |
2f89ccfc LL |
369 | |
370 | echo '#include <string.h> /*change pch*/' >>pch.h | |
371 | backdate pch.h | |
3c47a8a2 | 372 | $COMPILER $SYSROOT -c pch.h -o dir/pch.h.gch |
2f89ccfc LL |
373 | backdate dir/pch.h.gch |
374 | ||
375 | CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include dir/pch.h pch.c | |
5620af79 JR |
376 | expect_stat direct_cache_hit 0 |
377 | expect_stat preprocessed_cache_hit 1 | |
378 | expect_stat cache_miss 2 | |
2f89ccfc LL |
379 | |
380 | CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include dir/pch.h pch.c | |
5620af79 JR |
381 | expect_stat direct_cache_hit 0 |
382 | expect_stat preprocessed_cache_hit 2 | |
383 | expect_stat cache_miss 2 | |
2f89ccfc LL |
384 | rm -rf dir |
385 | ||
386 | # ------------------------------------------------------------------------- | |
387 | TEST "Use .gch, depend mode, -include" | |
388 | ||
3c47a8a2 | 389 | $COMPILER $SYSROOT -c pch.h |
2f89ccfc LL |
390 | backdate pch.h.gch |
391 | ||
392 | CCACHE_DEPEND=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c -MD -MF pch.d | |
5620af79 JR |
393 | expect_stat direct_cache_hit 0 |
394 | expect_stat preprocessed_cache_hit 0 | |
395 | expect_stat cache_miss 1 | |
c910f83b | 396 | |
2f89ccfc | 397 | CCACHE_DEPEND=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c -MD -MF pch.d |
5620af79 JR |
398 | expect_stat direct_cache_hit 1 |
399 | expect_stat preprocessed_cache_hit 0 | |
400 | expect_stat cache_miss 1 | |
c910f83b | 401 | |
2f89ccfc LL |
402 | echo '#include <string.h> /*change pch*/' >>pch.h |
403 | backdate pch.h | |
3c47a8a2 | 404 | $COMPILER $SYSROOT -c pch.h |
c910f83b JR |
405 | backdate pch.h.gch |
406 | ||
2f89ccfc | 407 | CCACHE_DEPEND=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c -MD -MF pch.d |
5620af79 JR |
408 | expect_stat direct_cache_hit 1 |
409 | expect_stat preprocessed_cache_hit 0 | |
410 | expect_stat cache_miss 2 | |
c910f83b | 411 | |
2f89ccfc | 412 | CCACHE_DEPEND=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c -MD -MF pch.d |
5620af79 JR |
413 | expect_stat direct_cache_hit 2 |
414 | expect_stat preprocessed_cache_hit 0 | |
415 | expect_stat cache_miss 2 | |
2f89ccfc | 416 | } |
c910f83b | 417 | |
2f89ccfc | 418 | pch_suite_gcc() { |
c910f83b | 419 | # ------------------------------------------------------------------------- |
2f89ccfc | 420 | TEST "Use .gch, -include, remove pch.h" |
c910f83b | 421 | |
3c47a8a2 | 422 | $COMPILER $SYSROOT -c pch.h |
c910f83b JR |
423 | backdate pch.h.gch |
424 | rm pch.h | |
425 | ||
2f89ccfc | 426 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c |
5620af79 JR |
427 | expect_stat direct_cache_hit 0 |
428 | expect_stat preprocessed_cache_hit 0 | |
429 | expect_stat cache_miss 1 | |
c910f83b | 430 | |
2f89ccfc | 431 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c |
5620af79 JR |
432 | expect_stat direct_cache_hit 1 |
433 | expect_stat preprocessed_cache_hit 0 | |
434 | expect_stat cache_miss 1 | |
c910f83b JR |
435 | |
436 | # ------------------------------------------------------------------------- | |
2f89ccfc | 437 | TEST "Use .gch, #include, no sloppiness" |
c910f83b | 438 | |
3c47a8a2 | 439 | $COMPILER $SYSROOT -c pch.h |
c910f83b JR |
440 | backdate pch.h.gch |
441 | rm pch.h | |
442 | ||
2f89ccfc | 443 | $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c |
5620af79 JR |
444 | expect_stat direct_cache_hit 0 |
445 | expect_stat preprocessed_cache_hit 0 | |
2f89ccfc | 446 | # Must enable sloppy time macros: |
5620af79 | 447 | expect_stat could_not_use_precompiled_header 1 |
c910f83b | 448 | |
2f89ccfc LL |
449 | # ------------------------------------------------------------------------- |
450 | TEST "Use .gch, #include" | |
451 | ||
3c47a8a2 | 452 | $COMPILER $SYSROOT -c pch.h |
c910f83b | 453 | backdate pch.h.gch |
2f89ccfc | 454 | rm pch.h |
c910f83b | 455 | |
2f89ccfc | 456 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c |
5620af79 JR |
457 | expect_stat direct_cache_hit 0 |
458 | expect_stat preprocessed_cache_hit 0 | |
459 | expect_stat cache_miss 1 | |
2f89ccfc LL |
460 | |
461 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c | |
5620af79 JR |
462 | expect_stat direct_cache_hit 1 |
463 | expect_stat preprocessed_cache_hit 0 | |
464 | expect_stat cache_miss 1 | |
2f89ccfc LL |
465 | |
466 | echo '#include <string.h> /*change pch*/' >>pch.h | |
467 | backdate pch.h | |
3c47a8a2 | 468 | $COMPILER $SYSROOT -c pch.h |
2f89ccfc LL |
469 | backdate pch.h.gch |
470 | ||
de5778ac | 471 | if $RUN_WIN_XFAIL; then |
2f89ccfc | 472 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c |
5620af79 JR |
473 | expect_stat direct_cache_hit 1 |
474 | expect_stat preprocessed_cache_hit 0 | |
475 | expect_stat cache_miss 2 | |
2f89ccfc LL |
476 | |
477 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c | |
5620af79 JR |
478 | expect_stat direct_cache_hit 2 |
479 | expect_stat preprocessed_cache_hit 0 | |
480 | expect_stat cache_miss 2 | |
de5778ac | 481 | fi |
c910f83b | 482 | |
2f89ccfc LL |
483 | # ------------------------------------------------------------------------- |
484 | TEST "Use .gch, preprocessor mode, #include" | |
485 | ||
3c47a8a2 | 486 | $COMPILER $SYSROOT -c pch.h |
2f89ccfc LL |
487 | backdate pch.h.gch |
488 | rm pch.h | |
489 | ||
490 | CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c | |
5620af79 JR |
491 | expect_stat direct_cache_hit 0 |
492 | expect_stat preprocessed_cache_hit 0 | |
493 | expect_stat cache_miss 1 | |
2f89ccfc LL |
494 | |
495 | CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c | |
5620af79 JR |
496 | expect_stat direct_cache_hit 0 |
497 | expect_stat preprocessed_cache_hit 1 | |
498 | expect_stat cache_miss 1 | |
2f89ccfc LL |
499 | |
500 | echo '#include <string.h> /*change pch*/' >>pch.h | |
501 | backdate pch.h | |
3c47a8a2 | 502 | $COMPILER $SYSROOT -c pch.h |
2f89ccfc LL |
503 | backdate pch.h.gch |
504 | ||
de5778ac | 505 | if $RUN_WIN_XFAIL; then |
2f89ccfc | 506 | CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c |
5620af79 JR |
507 | expect_stat direct_cache_hit 0 |
508 | expect_stat preprocessed_cache_hit 1 | |
509 | expect_stat cache_miss 2 | |
2f89ccfc LL |
510 | |
511 | CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c | |
5620af79 JR |
512 | expect_stat direct_cache_hit 0 |
513 | expect_stat preprocessed_cache_hit 2 | |
514 | expect_stat cache_miss 2 | |
de5778ac | 515 | fi |
a2280c55 JR |
516 | |
517 | # ------------------------------------------------------------------------- | |
518 | TEST "Create and use .gch directory" | |
519 | ||
520 | mkdir pch.h.gch | |
521 | ||
2f89ccfc | 522 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines" $CCACHE_COMPILE $SYSROOT -x c-header -c pch.h -o pch.h.gch/foo |
5620af79 JR |
523 | expect_stat direct_cache_hit 0 |
524 | expect_stat preprocessed_cache_hit 0 | |
525 | expect_stat cache_miss 1 | |
a2280c55 JR |
526 | rm pch.h.gch/foo |
527 | ||
2f89ccfc | 528 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines" $CCACHE_COMPILE $SYSROOT -x c-header -c pch.h -o pch.h.gch/foo |
5620af79 JR |
529 | expect_stat direct_cache_hit 1 |
530 | expect_stat preprocessed_cache_hit 0 | |
531 | expect_stat cache_miss 1 | |
733f9880 | 532 | expect_exists pch.h.gch/foo |
a2280c55 JR |
533 | |
534 | backdate pch.h.gch/foo | |
535 | ||
2f89ccfc | 536 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c |
5620af79 JR |
537 | expect_stat direct_cache_hit 1 |
538 | expect_stat preprocessed_cache_hit 0 | |
539 | expect_stat cache_miss 2 | |
a2280c55 | 540 | |
2f89ccfc | 541 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c |
5620af79 JR |
542 | expect_stat direct_cache_hit 2 |
543 | expect_stat preprocessed_cache_hit 0 | |
544 | expect_stat cache_miss 2 | |
a2280c55 JR |
545 | |
546 | echo "updated" >>pch.h.gch/foo # GCC seems to cope with this... | |
547 | backdate pch.h.gch/foo | |
548 | ||
de5778ac | 549 | if $RUN_WIN_XFAIL; then |
2f89ccfc | 550 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c |
5620af79 JR |
551 | expect_stat direct_cache_hit 2 |
552 | expect_stat preprocessed_cache_hit 0 | |
553 | expect_stat cache_miss 3 | |
a2280c55 | 554 | |
2f89ccfc | 555 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c |
5620af79 JR |
556 | expect_stat direct_cache_hit 3 |
557 | expect_stat preprocessed_cache_hit 0 | |
558 | expect_stat cache_miss 3 | |
de5778ac | 559 | fi |
27cac6ff GK |
560 | |
561 | # ------------------------------------------------------------------------- | |
2f89ccfc | 562 | TEST "Use .gch, #include, PCH_EXTSUM=1" |
27cac6ff | 563 | |
3c47a8a2 | 564 | $COMPILER $SYSROOT -c pch.h |
27cac6ff GK |
565 | backdate pch.h.gch |
566 | ||
567 | echo "original checksum" > pch.h.gch.sum | |
568 | ||
2f89ccfc | 569 | CCACHE_PCH_EXTSUM=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c |
5620af79 JR |
570 | expect_stat direct_cache_hit 0 |
571 | expect_stat preprocessed_cache_hit 0 | |
572 | expect_stat cache_miss 1 | |
27cac6ff | 573 | |
2f89ccfc | 574 | CCACHE_PCH_EXTSUM=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c |
5620af79 JR |
575 | expect_stat direct_cache_hit 1 |
576 | expect_stat preprocessed_cache_hit 0 | |
577 | expect_stat cache_miss 1 | |
27cac6ff GK |
578 | |
579 | echo "other checksum" > pch.h.gch.sum | |
2f89ccfc | 580 | CCACHE_PCH_EXTSUM=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c |
5620af79 JR |
581 | expect_stat direct_cache_hit 1 |
582 | expect_stat preprocessed_cache_hit 0 | |
583 | expect_stat cache_miss 2 | |
27cac6ff GK |
584 | |
585 | echo "original checksum" > pch.h.gch.sum | |
2f89ccfc | 586 | CCACHE_PCH_EXTSUM=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c |
5620af79 JR |
587 | expect_stat direct_cache_hit 2 |
588 | expect_stat preprocessed_cache_hit 0 | |
589 | expect_stat cache_miss 2 | |
27cac6ff | 590 | |
30fdd670 JR |
591 | # With GCC, a newly generated PCH is always different, even if the contents |
592 | # should be exactly the same. And Clang stores file timestamps, so in this | |
593 | # case the PCH is different too. So without .sum a "changed" PCH would mean | |
594 | # a miss, but if the .sum doesn't change, it should be a hit. | |
2f89ccfc LL |
595 | |
596 | sleep 1 | |
597 | touch pch.h | |
3c47a8a2 | 598 | $COMPILER $SYSROOT -c pch.h |
2f89ccfc LL |
599 | backdate pch.h.gch |
600 | ||
601 | CCACHE_PCH_EXTSUM=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c | |
5620af79 JR |
602 | expect_stat direct_cache_hit 3 |
603 | expect_stat preprocessed_cache_hit 0 | |
604 | expect_stat cache_miss 2 | |
2f89ccfc | 605 | |
27cac6ff | 606 | # ------------------------------------------------------------------------- |
2f89ccfc | 607 | TEST "Use .gch, #include, no PCH_EXTSUM" |
27cac6ff | 608 | |
3c47a8a2 | 609 | $COMPILER $SYSROOT -c pch.h |
27cac6ff GK |
610 | backdate pch.h.gch |
611 | ||
612 | echo "original checksum" > pch.h.gch.sum | |
613 | ||
2f89ccfc | 614 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c |
5620af79 JR |
615 | expect_stat direct_cache_hit 0 |
616 | expect_stat preprocessed_cache_hit 0 | |
617 | expect_stat cache_miss 1 | |
27cac6ff | 618 | |
2f89ccfc | 619 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c |
5620af79 JR |
620 | expect_stat direct_cache_hit 1 |
621 | expect_stat preprocessed_cache_hit 0 | |
622 | expect_stat cache_miss 1 | |
27cac6ff GK |
623 | |
624 | # external checksum not used, so no cache miss when changed | |
625 | echo "other checksum" > pch.h.gch.sum | |
2f89ccfc | 626 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c |
5620af79 JR |
627 | expect_stat direct_cache_hit 2 |
628 | expect_stat preprocessed_cache_hit 0 | |
629 | expect_stat cache_miss 1 | |
5796e9b5 JR |
630 | |
631 | # ------------------------------------------------------------------------- | |
632 | TEST "Too new PCH file" | |
633 | ||
5796e9b5 JR |
634 | touch lib.h |
635 | touch main.c | |
636 | ||
3c47a8a2 | 637 | $COMPILER $SYSROOT -c lib.h |
5796e9b5 JR |
638 | touch -d "@$(($(date +%s) + 60))" lib.h.gch # 1 minute in the future |
639 | ||
640 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines,time_macros" $CCACHE_COMPILE -include lib.h -c main.c | |
d75dbe26 | 641 | expect_stat modified_input_file 1 |
c910f83b JR |
642 | } |
643 | ||
644 | pch_suite_clang() { | |
c910f83b | 645 | # ------------------------------------------------------------------------- |
3ec58dbc | 646 | TEST "Create .pch, include file mtime changed" |
c910f83b JR |
647 | |
648 | backdate test.h | |
649 | cat <<EOF >pch2.h | |
650 | #include <stdlib.h> | |
651 | #include "test.h" | |
652 | EOF | |
653 | ||
654 | # Make sure time_of_compilation is at least one second larger than the ctime | |
655 | # of the test.h include, otherwise we might not cache its ctime/mtime. | |
656 | sleep 1 | |
657 | ||
2f89ccfc | 658 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines" $CCACHE_COMPILE $SYSROOT -c pch2.h |
5620af79 JR |
659 | expect_stat direct_cache_hit 0 |
660 | expect_stat preprocessed_cache_hit 0 | |
661 | expect_stat cache_miss 1 | |
c910f83b JR |
662 | |
663 | touch test.h | |
664 | sleep 1 | |
665 | ||
2f89ccfc | 666 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines" $CCACHE_COMPILE $SYSROOT -c pch2.h |
5620af79 JR |
667 | expect_stat direct_cache_hit 0 |
668 | expect_stat preprocessed_cache_hit 0 | |
669 | expect_stat cache_miss 2 | |
c910f83b | 670 | |
3c47a8a2 | 671 | $COMPILER $SYSROOT -c -include pch2.h pch2.c |
733f9880 | 672 | expect_exists pch2.o |
c910f83b | 673 | |
2f89ccfc | 674 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines" $CCACHE_COMPILE $SYSROOT -c pch2.h |
5620af79 JR |
675 | expect_stat direct_cache_hit 1 |
676 | expect_stat preprocessed_cache_hit 0 | |
677 | expect_stat cache_miss 2 | |
c910f83b JR |
678 | |
679 | # ------------------------------------------------------------------------- | |
2f89ccfc | 680 | TEST "Use .pch, -include, no sloppiness" |
c910f83b | 681 | |
3c47a8a2 | 682 | $COMPILER $SYSROOT -c pch.h -o pch.h.pch |
2f89ccfc | 683 | backdate pch.h.pch |
c910f83b | 684 | |
2f89ccfc | 685 | $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c |
5620af79 JR |
686 | expect_stat direct_cache_hit 0 |
687 | expect_stat preprocessed_cache_hit 0 | |
688 | expect_stat cache_miss 0 | |
c910f83b | 689 | # Must enable sloppy time macros: |
5620af79 | 690 | expect_stat could_not_use_precompiled_header 1 |
c910f83b JR |
691 | |
692 | # ------------------------------------------------------------------------- | |
2f89ccfc | 693 | TEST "Use .pch, -include" |
c910f83b | 694 | |
3c47a8a2 | 695 | $COMPILER $SYSROOT -c pch.h -o pch.h.pch |
2f89ccfc | 696 | backdate pch.h.pch |
c910f83b | 697 | |
2f89ccfc | 698 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c |
5620af79 JR |
699 | expect_stat direct_cache_hit 0 |
700 | expect_stat preprocessed_cache_hit 0 | |
701 | expect_stat cache_miss 1 | |
c910f83b | 702 | |
2f89ccfc | 703 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c |
5620af79 JR |
704 | expect_stat direct_cache_hit 1 |
705 | expect_stat preprocessed_cache_hit 0 | |
706 | expect_stat cache_miss 1 | |
c910f83b | 707 | |
2f89ccfc LL |
708 | echo '#include <string.h> /*change pch*/' >>pch.h |
709 | backdate pch.h | |
3c47a8a2 | 710 | $COMPILER $SYSROOT -c pch.h -o pch.h.pch |
2f89ccfc | 711 | backdate pch.h.pch |
c910f83b | 712 | |
2f89ccfc | 713 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c |
5620af79 JR |
714 | expect_stat direct_cache_hit 1 |
715 | expect_stat preprocessed_cache_hit 0 | |
716 | expect_stat cache_miss 2 | |
c910f83b JR |
717 | |
718 | # ------------------------------------------------------------------------- | |
2f89ccfc | 719 | TEST "Use .pch, preprocessor mode, -include" |
c910f83b | 720 | |
3c47a8a2 | 721 | $COMPILER $SYSROOT -c pch.h -o pch.h.pch |
2f89ccfc | 722 | backdate pch.h.pch |
c910f83b | 723 | |
2f89ccfc | 724 | CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch.c |
5620af79 JR |
725 | expect_stat direct_cache_hit 0 |
726 | expect_stat preprocessed_cache_hit 0 | |
727 | expect_stat cache_miss 1 | |
c910f83b | 728 | |
2f89ccfc | 729 | CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch.c |
5620af79 JR |
730 | expect_stat direct_cache_hit 0 |
731 | expect_stat preprocessed_cache_hit 1 | |
732 | expect_stat cache_miss 1 | |
c910f83b | 733 | |
2f89ccfc LL |
734 | echo '#include <string.h> /*change pch*/' >>pch.h |
735 | backdate pch.h | |
3c47a8a2 | 736 | $COMPILER $SYSROOT -c pch.h -o pch.h.pch |
2f89ccfc | 737 | backdate pch.h.pch |
c910f83b | 738 | |
2f89ccfc | 739 | CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch.c |
5620af79 JR |
740 | expect_stat direct_cache_hit 0 |
741 | expect_stat preprocessed_cache_hit 1 | |
742 | expect_stat cache_miss 2 | |
c910f83b | 743 | |
2f89ccfc | 744 | CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch.c |
5620af79 JR |
745 | expect_stat direct_cache_hit 0 |
746 | expect_stat preprocessed_cache_hit 2 | |
747 | expect_stat cache_miss 2 | |
c910f83b JR |
748 | |
749 | # ------------------------------------------------------------------------- | |
2f89ccfc | 750 | TEST "Use .pch, -include-pch" |
c910f83b | 751 | |
3c47a8a2 | 752 | $COMPILER $SYSROOT -c pch.h -o pch.h.pch |
2f89ccfc | 753 | backdate pch.h.pch |
c910f83b | 754 | |
2f89ccfc | 755 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include-pch pch.h.pch pch2.c |
5620af79 JR |
756 | expect_stat direct_cache_hit 0 |
757 | expect_stat preprocessed_cache_hit 0 | |
758 | expect_stat cache_miss 1 | |
c910f83b | 759 | |
2f89ccfc | 760 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include-pch pch.h.pch pch2.c |
5620af79 JR |
761 | expect_stat direct_cache_hit 1 |
762 | expect_stat preprocessed_cache_hit 0 | |
763 | expect_stat cache_miss 1 | |
c910f83b | 764 | |
2f89ccfc LL |
765 | echo '#include <string.h> /*change pch*/' >>pch.h |
766 | backdate pch.h | |
3c47a8a2 | 767 | $COMPILER $SYSROOT -c pch.h -o pch.h.pch |
2f89ccfc | 768 | backdate pch.h.pch |
c910f83b | 769 | |
2f89ccfc | 770 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include-pch pch.h.pch pch2.c |
5620af79 JR |
771 | expect_stat direct_cache_hit 1 |
772 | expect_stat preprocessed_cache_hit 0 | |
773 | expect_stat cache_miss 2 | |
c910f83b JR |
774 | |
775 | # ------------------------------------------------------------------------- | |
2f89ccfc | 776 | TEST "Use .pch, preprocessor mode, -include-pch" |
c910f83b | 777 | |
3c47a8a2 | 778 | $COMPILER $SYSROOT -c pch.h -o pch.h.pch |
2f89ccfc | 779 | backdate pch.h.pch |
c910f83b | 780 | |
2f89ccfc | 781 | CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include-pch pch.h.pch pch.c |
5620af79 JR |
782 | expect_stat direct_cache_hit 0 |
783 | expect_stat preprocessed_cache_hit 0 | |
784 | expect_stat cache_miss 1 | |
c910f83b | 785 | |
2f89ccfc | 786 | CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include-pch pch.h.pch pch.c |
5620af79 JR |
787 | expect_stat direct_cache_hit 0 |
788 | expect_stat preprocessed_cache_hit 1 | |
789 | expect_stat cache_miss 1 | |
c910f83b | 790 | |
2f89ccfc LL |
791 | echo '#include <string.h> /*change pch*/' >>pch.h |
792 | backdate pch.h | |
3c47a8a2 | 793 | $COMPILER $SYSROOT -c pch.h -o pch.h.pch |
2f89ccfc | 794 | backdate pch.h.pch |
c910f83b | 795 | |
2f89ccfc | 796 | CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include-pch pch.h.pch pch.c |
5620af79 JR |
797 | expect_stat direct_cache_hit 0 |
798 | expect_stat preprocessed_cache_hit 1 | |
799 | expect_stat cache_miss 2 | |
c910f83b | 800 | |
2f89ccfc | 801 | CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include-pch pch.h.pch pch.c |
5620af79 JR |
802 | expect_stat direct_cache_hit 0 |
803 | expect_stat preprocessed_cache_hit 2 | |
804 | expect_stat cache_miss 2 | |
3ec58dbc AH |
805 | |
806 | # ------------------------------------------------------------------------- | |
807 | TEST "Create .pch with -Xclang options" | |
808 | ||
809 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines" $CCACHE_COMPILE $SYSROOT -Xclang -emit-pch -o pch.h.pch -c pch.h | |
5620af79 JR |
810 | expect_stat direct_cache_hit 0 |
811 | expect_stat preprocessed_cache_hit 0 | |
812 | expect_stat cache_miss 1 | |
3ec58dbc AH |
813 | rm pch.h.pch |
814 | ||
815 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines" $CCACHE_COMPILE $SYSROOT -Xclang -emit-pch -o pch.h.pch -c pch.h | |
5620af79 JR |
816 | expect_stat direct_cache_hit 1 |
817 | expect_stat preprocessed_cache_hit 0 | |
818 | expect_stat cache_miss 1 | |
733f9880 | 819 | expect_exists pch.h.pch |
3ec58dbc AH |
820 | |
821 | echo '#include <string.h> /*change pch*/' >>pch.h | |
822 | backdate pch.h | |
823 | rm pch.h.pch | |
824 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines" $CCACHE_COMPILE $SYSROOT -Xclang -emit-pch -o pch.h.pch -c pch.h | |
5620af79 JR |
825 | expect_stat direct_cache_hit 1 |
826 | expect_stat preprocessed_cache_hit 0 | |
827 | expect_stat cache_miss 2 | |
733f9880 | 828 | expect_exists pch.h.pch |
3ec58dbc AH |
829 | |
830 | # ------------------------------------------------------------------------- | |
831 | TEST "Use .pch the with -Xclang options" | |
832 | ||
3c47a8a2 | 833 | $COMPILER $SYSROOT -Xclang -emit-pch -o pch.h.pch -c pch.h |
3ec58dbc AH |
834 | backdate pch.h.pch |
835 | ||
836 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -Xclang -include-pch -Xclang pch.h.pch -Xclang -include -Xclang pch.h -c pch.c | |
5620af79 JR |
837 | expect_stat direct_cache_hit 0 |
838 | expect_stat preprocessed_cache_hit 0 | |
839 | expect_stat cache_miss 1 | |
3ec58dbc AH |
840 | |
841 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -Xclang -include-pch -Xclang pch.h.pch -Xclang -include -Xclang pch.h -c pch.c | |
5620af79 JR |
842 | expect_stat direct_cache_hit 1 |
843 | expect_stat preprocessed_cache_hit 0 | |
844 | expect_stat cache_miss 1 | |
3ec58dbc AH |
845 | |
846 | echo '#include <string.h> /*change pch*/' >>pch.h | |
847 | backdate pch.h | |
3c47a8a2 | 848 | $COMPILER $SYSROOT -Xclang -emit-pch -o pch.h.pch -c pch.h |
3ec58dbc AH |
849 | backdate pch.h.pch |
850 | ||
851 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -Xclang -include-pch -Xclang pch.h.pch -Xclang -include -Xclang pch.h -c pch.c | |
5620af79 JR |
852 | expect_stat direct_cache_hit 1 |
853 | expect_stat preprocessed_cache_hit 0 | |
854 | expect_stat cache_miss 2 | |
3ec58dbc AH |
855 | |
856 | CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -Xclang -include-pch -Xclang pch.h.pch -Xclang -include -Xclang pch.h -c pch.c | |
5620af79 JR |
857 | expect_stat direct_cache_hit 2 |
858 | expect_stat preprocessed_cache_hit 0 | |
859 | expect_stat cache_miss 2 | |
c910f83b | 860 | } |