1 #include "foo.h" 2 #include "bar.h" 3 4 // Clear the module cache. 5 // RUN: rm -rf %t 6 // RUN: mkdir -p %t/Inputs 7 // RUN: mkdir -p %t/modules-to-compare 8 9 // === 10 // Create a module. We will use -I or -isystem to determine whether to treat 11 // foo.h as a system header. 12 // RUN: echo 'void meow(void);' > %t/Inputs/foo.h 13 // RUN: echo 'void woof(void);' > %t/Inputs/bar.h 14 // RUN: echo 'module Foo { header "foo.h" }' > %t/Inputs/module.modulemap 15 // RUN: echo 'extern module Bar "bar.modulemap"' >> %t/Inputs/module.modulemap 16 // RUN: echo 'module Bar { header "bar.h" }' > %t/Inputs/bar.modulemap 17 18 // === 19 // Compile the module. 20 // RUN: %clang_cc1 -cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -isystem %t/Inputs -fmodules-validate-system-headers -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s 21 // RUN: %clang_cc1 -cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t/modules-cache-user -fsyntax-only -I %t/Inputs -fmodules-validate-system-headers -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s 22 // RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp 23 // RUN: ls -R %t/modules-cache | grep Bar.pcm.timestamp 24 // RUN: ls -R %t/modules-cache-user | grep Foo.pcm.timestamp 25 // RUN: ls -R %t/modules-cache-user | grep Bar.pcm.timestamp 26 // RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-before.pcm 27 // RUN: cp %t/modules-cache/Bar.pcm %t/modules-to-compare/Bar-before.pcm 28 // RUN: cp %t/modules-cache-user/Foo.pcm %t/modules-to-compare/Foo-before-user.pcm 29 // RUN: cp %t/modules-cache-user/Bar.pcm %t/modules-to-compare/Bar-before-user.pcm 30 31 // === 32 // Use it, and make sure that we did not recompile it. 33 // RUN: %clang_cc1 -cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -isystem %t/Inputs -fmodules-validate-system-headers -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s 34 // RUN: %clang_cc1 -cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t/modules-cache-user -fsyntax-only -I %t/Inputs -fmodules-validate-system-headers -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s 35 // RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp 36 // RUN: ls -R %t/modules-cache | grep Bar.pcm.timestamp 37 // RUN: ls -R %t/modules-cache-user | grep Foo.pcm.timestamp 38 // RUN: ls -R %t/modules-cache-user | grep Bar.pcm.timestamp 39 // RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-after.pcm 40 // RUN: cp %t/modules-cache/Bar.pcm %t/modules-to-compare/Bar-after.pcm 41 // RUN: cp %t/modules-cache-user/Foo.pcm %t/modules-to-compare/Foo-after-user.pcm 42 // RUN: cp %t/modules-cache-user/Bar.pcm %t/modules-to-compare/Bar-after-user.pcm 43 44 // RUN: diff %t/modules-to-compare/Foo-before.pcm %t/modules-to-compare/Foo-after.pcm 45 // RUN: diff %t/modules-to-compare/Bar-before.pcm %t/modules-to-compare/Bar-after.pcm 46 // RUN: diff %t/modules-to-compare/Foo-before-user.pcm %t/modules-to-compare/Foo-after-user.pcm 47 // RUN: diff %t/modules-to-compare/Bar-before-user.pcm %t/modules-to-compare/Bar-after-user.pcm 48 49 // === 50 // Change the sources. 51 // RUN: echo 'void meow2(void);' > %t/Inputs/foo.h 52 // RUN: echo 'module Bar { header "bar.h" export * }' > %t/Inputs/bar.modulemap 53 54 // === 55 // Use the module, and make sure that we did not recompile it if foo.h or 56 // module.modulemap are system files, even though the sources changed. 57 // RUN: %clang_cc1 -cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -isystem %t/Inputs -fmodules-validate-system-headers -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s 58 // RUN: %clang_cc1 -cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t/modules-cache-user -fsyntax-only -I %t/Inputs -fmodules-validate-system-headers -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s 59 // RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp 60 // RUN: ls -R %t/modules-cache | grep Bar.pcm.timestamp 61 // RUN: ls -R %t/modules-cache-user | grep Foo.pcm.timestamp 62 // RUN: ls -R %t/modules-cache-user | grep Bar.pcm.timestamp 63 // RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-after.pcm 64 // RUN: cp %t/modules-cache/Bar.pcm %t/modules-to-compare/Bar-after.pcm 65 // RUN: cp %t/modules-cache-user/Foo.pcm %t/modules-to-compare/Foo-after-user.pcm 66 // RUN: cp %t/modules-cache-user/Bar.pcm %t/modules-to-compare/Bar-after-user.pcm 67 68 // RUN: diff %t/modules-to-compare/Foo-before.pcm %t/modules-to-compare/Foo-after.pcm 69 // RUN: diff %t/modules-to-compare/Bar-before.pcm %t/modules-to-compare/Bar-after.pcm 70 // When foo.h is a user header, we will always validate it. 71 // RUN: not diff %t/modules-to-compare/Foo-before-user.pcm %t/modules-to-compare/Foo-after-user.pcm 72 // RUN: not diff %t/modules-to-compare/Bar-before-user.pcm %t/modules-to-compare/Bar-after-user.pcm 73 74 // === 75 // Recompile the module if the today's date is before 01 January 2100. 76 // RUN: %clang_cc1 -cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -isystem %t/Inputs -fmodules-validate-system-headers -fbuild-session-timestamp=4102441200 -fmodules-validate-once-per-build-session %s 77 // RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp 78 // RUN: ls -R %t/modules-cache | grep Bar.pcm.timestamp 79 // RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-after.pcm 80 // RUN: cp %t/modules-cache/Bar.pcm %t/modules-to-compare/Bar-after.pcm 81 82 // RUN: not diff %t/modules-to-compare/Foo-before.pcm %t/modules-to-compare/Foo-after.pcm 83 // RUN: not diff %t/modules-to-compare/Bar-before.pcm %t/modules-to-compare/Bar-after.pcm 84