Skip to content

Commit 7f33444

Browse files
jrose-appleNathan Hawes
authored andcommitted
[ParseableInterface] Honor -track-system-dependencies when caching
One interesting thing here is that the decision of whether or not to track system dependencies ends up going into the cache key for a swiftmodule built from a parseable interface, because it affects that module's up-to-date check. If we didn't include -track-system-dependencies in the cache key, we could end up tracking system dependencies for some modules but not others in the same build. There's a bit of a bug here where they're /not/ honored if the top-level invocation isn't tracking /any/ dependencies, but given how uncommon this flag is in practice that's probably okay for now. Still TODO: honor this for -build-swiftmodule-from-parseable-interface as well. That's currently not tracking dependencies at all and it probably should.
1 parent c023e0f commit 7f33444

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extern int x;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module SomeCModule {
2+
header "SomeCModule.h"
3+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// swift-interface-format-version: 1.0
2+
// swift-module-flags: -module-name SystemDependencies
3+
4+
// RUN: %empty-directory(%t)
5+
// RUN: cp -r %S/Inputs/mock-sdk %t/mock-sdk
6+
7+
// RUN: echo 'import SystemDependencies' | %target-swift-frontend -typecheck - -I %S -sdk %t/mock-sdk -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d
8+
// RUN: test -f %t/MCP/SystemDependencies*.swiftmodule
9+
// RUN: %FileCheck -check-prefix NEGATIVE %s < %t/dummy.d
10+
// RUN: %{python} %S/Inputs/make-old.py %t/MCP/SystemDependencies*.swiftmodule
11+
12+
// Baseline: running the same command again doesn't rebuild the cached module.
13+
// RUN: echo 'import SystemDependencies' | %target-swift-frontend -typecheck - -I %S -sdk %t/mock-sdk -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d
14+
// RUN: %{python} %S/Inputs/check-is-old.py %t/MCP/SystemDependencies*.swiftmodule
15+
16+
// Now try changing the contents.
17+
// RUN: echo "// size change" >> %t/mock-sdk/usr/include/SomeCModule.h
18+
// RUN: echo 'import SystemDependencies' | %target-swift-frontend -typecheck - -I %S -sdk %t/mock-sdk -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d
19+
// RUN: %{python} %S/Inputs/check-is-old.py %t/MCP/SystemDependencies*.swiftmodule
20+
21+
// Okay, now let's try again with system dependency tracking on.
22+
// RUN: echo 'import SystemDependencies' | %target-swift-frontend -typecheck - -I %S -sdk %t/mock-sdk -module-cache-path %t/MCP-system -emit-dependencies-path %t/dummy.d -track-system-dependencies
23+
// RUN: test -f %t/MCP-system/SystemDependencies*.swiftmodule
24+
// RUN: %FileCheck -check-prefix CHECK %s < %t/dummy.d
25+
// RUN: %{python} %S/Inputs/make-old.py %t/MCP-system/SystemDependencies*.swiftmodule
26+
27+
// Baseline: running the same command again doesn't rebuild the cached module.
28+
// RUN: echo 'import SystemDependencies' | %target-swift-frontend -typecheck - -I %S -sdk %t/mock-sdk -module-cache-path %t/MCP-system -emit-dependencies-path %t/dummy.d -track-system-dependencies
29+
// RUN: %{python} %S/Inputs/check-is-old.py %t/MCP-system/SystemDependencies*.swiftmodule
30+
31+
// Now try changing the contents.
32+
// RUN: echo "// size change" >> %t/mock-sdk/usr/include/SomeCModule.h
33+
// RUN: echo 'import SystemDependencies' | %target-swift-frontend -typecheck - -I %S -sdk %t/mock-sdk -module-cache-path %t/MCP-system -emit-dependencies-path %t/dummy.d -track-system-dependencies
34+
// RUN: %{python} %S/Inputs/check-is-new.py %t/MCP-system/SystemDependencies*.swiftmodule
35+
36+
// Check that it picked a different cache key.
37+
// RUN: %empty-directory(%t/MCP-combined)
38+
// RUN: cp -n %t/MCP/SystemDependencies*.swiftmodule %t/MCP-combined
39+
// RUN: cp -n %t/MCP-system/SystemDependencies*.swiftmodule %t/MCP-combined
40+
41+
// NEGATIVE-NOT: SomeCModule.h
42+
// CHECK: SomeCModule.h
43+
44+
import SomeCModule

0 commit comments

Comments
 (0)