File: fmodule-file-cache-key-lazy.c

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (77 lines) | stat: -rw-r--r-- 2,560 bytes parent folder | download
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
// Tests for combining -fmodule-file-cache-key with lazy-loading modules via
// -fmodule-file=<NAME>=<PATH>.

// REQUIRES: ondisk_cas

// RUN: rm -rf %t %t.cas
// RUN: split-file %s %t

// RUN: llvm-cas --cas %t.cas --ingest %t > %t/casid

// == Build B

// RUN: %clang_cc1 -triple x86_64-apple-macos11 \
// RUN:   -fmodules -fmodule-name=B -fno-implicit-modules \
// RUN:   -emit-module %t/module.modulemap -o %t/B.pcm \
// RUN:   -fcas-path %t.cas -fcas-fs @%t/casid \
// RUN:   -fcache-compile-job -Rcompile-job-cache &> %t/B.out.txt
// RUN: cat %t/B.out.txt | FileCheck %s --check-prefix=CACHE-MISS
// RUN: cat %t/B.out.txt | sed -E "s:^.*cache [a-z]+ for '([^']+)'.*$:\1:" > %t/B.key

// == Build A, importing B

// RUN: echo -n '-fmodule-file-cache-key %t/B.pcm ' > %t/B.import.rsp
// RUN: cat %t/B.key >> %t/B.import.rsp

// RUN: %clang_cc1 -triple x86_64-apple-macos11 \
// RUN:   -fmodules -fmodule-name=A -fno-implicit-modules \
// RUN:   @%t/B.import.rsp -fmodule-file=B=%t/B.pcm \
// RUN:   -emit-module %t/module.modulemap -o %t/A.pcm \
// RUN:   -fcas-path %t.cas -fcas-fs @%t/casid \
// RUN:   -fcache-compile-job -Rcompile-job-cache &> %t/A.out.txt
// RUN: cat %t/A.out.txt | FileCheck %s --check-prefix=CACHE-MISS
// RUN: cat %t/A.out.txt | sed -E "s:^.*cache [a-z]+ for '([^']+)'.*$:\1:" > %t/A.key

// == Build tu, importing A (implicitly importing B)

// RUN: echo -n '-fmodule-file-cache-key %t/A.pcm ' > %t/A.import.rsp
// RUN: cat %t/A.key >> %t/A.import.rsp

// RUN: %clang_cc1 -triple x86_64-apple-macos11 \
// RUN:   -fmodules -fno-implicit-modules \
// RUN:   @%t/A.import.rsp -fmodule-file=A=%t/A.pcm \
// RUN:   -fsyntax-only %t/tu.c \
// RUN:   -fcas-path %t.cas -fcas-fs @%t/casid \
// RUN:   -fcache-compile-job -Rcompile-job-cache &> %t/tu.out.txt
// RUN: cat %t/tu.out.txt | FileCheck %s --check-prefix=CACHE-MISS

// == Ensure we're reading pcm from cache

// RUN: rm %t/*.pcm

// RUN: %clang_cc1 -triple x86_64-apple-macos11 \
// RUN:   -fmodules -fno-implicit-modules \
// RUN:   @%t/A.import.rsp -fmodule-file=A=%t/A.pcm \
// RUN:   -fsyntax-only %t/tu.c \
// RUN:   -fcas-path %t.cas -fcas-fs @%t/casid \
// RUN:   -fcache-compile-job -Rcompile-job-cache &> %t/tu.out.2.txt
// RUN: cat %t/tu.out.2.txt | FileCheck %s --check-prefix=CACHE-HIT

// CACHE-HIT: remark: compile job cache hit
// CACHE-MISS: remark: compile job cache miss

//--- module.modulemap
module A { header "A.h" export * }
module B { header "B.h" }

//--- A.h
#include "B.h"

//--- B.h
void B(void);

//--- tu.c
#include "A.h"
void tu(void) {
  B();
}