1*0a6a1f1dSLionel Sambuc #include "foo.h" 2*0a6a1f1dSLionel Sambuc 3*0a6a1f1dSLionel Sambuc // Clear the module cache. 4*0a6a1f1dSLionel Sambuc // RUN: rm -rf %t 5*0a6a1f1dSLionel Sambuc // RUN: mkdir -p %t/Inputs 6*0a6a1f1dSLionel Sambuc // RUN: mkdir -p %t/modules-to-compare 7*0a6a1f1dSLionel Sambuc 8*0a6a1f1dSLionel Sambuc // === 9*0a6a1f1dSLionel Sambuc // Create a module. We will use -I or -isystem to determine whether to treat 10*0a6a1f1dSLionel Sambuc // foo.h as a system header. 11*0a6a1f1dSLionel Sambuc // RUN: echo 'void meow(void);' > %t/Inputs/foo.h 12*0a6a1f1dSLionel Sambuc // RUN: echo 'module Foo { header "foo.h" }' > %t/Inputs/module.map 13*0a6a1f1dSLionel Sambuc 14*0a6a1f1dSLionel Sambuc // === 15*0a6a1f1dSLionel Sambuc // Compile the module. 16*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -isystem %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s 17*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache-user -fsyntax-only -I %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s 18*0a6a1f1dSLionel Sambuc // RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp 19*0a6a1f1dSLionel Sambuc // RUN: ls -R %t/modules-cache-user | grep Foo.pcm.timestamp 20*0a6a1f1dSLionel Sambuc // RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-before.pcm 21*0a6a1f1dSLionel Sambuc // RUN: cp %t/modules-cache-user/Foo.pcm %t/modules-to-compare/Foo-before-user.pcm 22*0a6a1f1dSLionel Sambuc 23*0a6a1f1dSLionel Sambuc // === 24*0a6a1f1dSLionel Sambuc // Use it, and make sure that we did not recompile it. 25*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -isystem %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s 26*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache-user -fsyntax-only -I %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s 27*0a6a1f1dSLionel Sambuc // RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp 28*0a6a1f1dSLionel Sambuc // RUN: ls -R %t/modules-cache-user | grep Foo.pcm.timestamp 29*0a6a1f1dSLionel Sambuc // RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-after.pcm 30*0a6a1f1dSLionel Sambuc // RUN: cp %t/modules-cache-user/Foo.pcm %t/modules-to-compare/Foo-after-user.pcm 31*0a6a1f1dSLionel Sambuc 32*0a6a1f1dSLionel Sambuc // RUN: diff %t/modules-to-compare/Foo-before.pcm %t/modules-to-compare/Foo-after.pcm 33*0a6a1f1dSLionel Sambuc // RUN: diff %t/modules-to-compare/Foo-before-user.pcm %t/modules-to-compare/Foo-after-user.pcm 34*0a6a1f1dSLionel Sambuc 35*0a6a1f1dSLionel Sambuc // === 36*0a6a1f1dSLionel Sambuc // Change the sources. 37*0a6a1f1dSLionel Sambuc // RUN: echo 'void meow2(void);' > %t/Inputs/foo.h 38*0a6a1f1dSLionel Sambuc 39*0a6a1f1dSLionel Sambuc // === 40*0a6a1f1dSLionel Sambuc // Use the module, and make sure that we did not recompile it if foo.h is a 41*0a6a1f1dSLionel Sambuc // system header, even though the sources changed. 42*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -isystem %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s 43*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache-user -fsyntax-only -I %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s 44*0a6a1f1dSLionel Sambuc // RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp 45*0a6a1f1dSLionel Sambuc // RUN: ls -R %t/modules-cache-user | grep Foo.pcm.timestamp 46*0a6a1f1dSLionel Sambuc // RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-after.pcm 47*0a6a1f1dSLionel Sambuc // RUN: cp %t/modules-cache-user/Foo.pcm %t/modules-to-compare/Foo-after-user.pcm 48*0a6a1f1dSLionel Sambuc 49*0a6a1f1dSLionel Sambuc // RUN: diff %t/modules-to-compare/Foo-before.pcm %t/modules-to-compare/Foo-after.pcm 50*0a6a1f1dSLionel Sambuc // When foo.h is a user header, we will always validate it. 51*0a6a1f1dSLionel Sambuc // RUN: not diff %t/modules-to-compare/Foo-before-user.pcm %t/modules-to-compare/Foo-after-user.pcm 52*0a6a1f1dSLionel Sambuc 53*0a6a1f1dSLionel Sambuc // === 54*0a6a1f1dSLionel Sambuc // Recompile the module if the today's date is before 01 January 2030. 55*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -isystem %t/Inputs -fbuild-session-timestamp=1893456000 -fmodules-validate-once-per-build-session %s 56*0a6a1f1dSLionel Sambuc // RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp 57*0a6a1f1dSLionel Sambuc // RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-after.pcm 58*0a6a1f1dSLionel Sambuc 59*0a6a1f1dSLionel Sambuc // RUN: not diff %t/modules-to-compare/Foo-before.pcm %t/modules-to-compare/Foo-after.pcm 60