Skip to content

Commit e99a93b

Browse files
[Caching] Give swiftmodule loaded from CAS a path identifier
Assign the path returned from dependency scanner for the module to the buffer identifier when loading modules from CAS. This fixes a warning in module trace file generation about invariant violation and also an assertion when generating swiftdeps file. rdar://122905379
1 parent 7da4934 commit e99a93b

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

lib/Frontend/ModuleInterfaceLoader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2603,7 +2603,7 @@ bool ExplicitCASModuleLoader::findModule(
26032603
// that are not located on disk.
26042604
auto moduleBuf = loadCachedCompileResultFromCacheKey(
26052605
Impl.CAS, Impl.Cache, Ctx.Diags, moduleCASID,
2606-
file_types::ID::TY_SwiftModuleFile);
2606+
file_types::ID::TY_SwiftModuleFile, moduleInfo.modulePath);
26072607
if (!moduleBuf) {
26082608
// We cannot read the module content, diagnose.
26092609
Ctx.Diags.diagnose(SourceLoc(), diag::error_opening_explicit_module_file,

test/CAS/module_trace.swift

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: split-file %s %t
3+
4+
// RUN: %target-swift-frontend -emit-module -module-name B -o %t/B.swiftmodule -swift-version 5 \
5+
// RUN: -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import -parse-stdlib \
6+
// RUN: -emit-module-interface-path %t/ignore/B.swiftinterface -enable-library-evolution \
7+
// RUN: %t/B.swift
8+
9+
// RUN: %target-swift-frontend -emit-module -module-name A -o %t/ignore/A.swiftmodule -swift-version 5 \
10+
// RUN: -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import -parse-stdlib \
11+
// RUN: -emit-module-interface-path %t/A.swiftinterface -enable-library-evolution -I %t \
12+
// RUN: %t/A.swift
13+
14+
// RUN: %target-swift-frontend -scan-dependencies -module-name Test -module-cache-path %t/clang-module-cache %t/main.swift \
15+
// RUN: -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import -parse-stdlib \
16+
// RUN: -o %t/deps.json -I %t -cache-compile-job -cas-path %t/cas -swift-version 5
17+
18+
// RUN: %{python} %S/Inputs/BuildCommandExtractor.py %t/deps.json A > %t/A.cmd
19+
// RUN: %swift_frontend_plain @%t/A.cmd
20+
21+
// RUN: %FileCheck %s --input-file=%t/A.cmd
22+
23+
// CHECK-NOT: -candidate-module-file
24+
25+
// RUN: %{python} %S/Inputs/GenerateExplicitModuleMap.py %t/deps.json > %t/map.json
26+
// RUN: llvm-cas --cas %t/cas --make-blob --data %t/map.json > %t/map.casid
27+
28+
// RUN: %{python} %S/Inputs/BuildCommandExtractor.py %t/deps.json Test > %t/MyApp.cmd
29+
30+
// RUN: %target-swift-frontend \
31+
// RUN: -c -cache-compile-job -cas-path %t/cas \
32+
// RUN: -disable-implicit-swift-modules -o %t/test.o\
33+
// RUN: -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import -parse-stdlib \
34+
// RUN: -module-name Test -explicit-swift-module-map-file @%t/map.casid \
35+
// RUN: -emit-reference-dependencies-path %t/test.swiftdeps -emit-dependencies \
36+
// RUN: -primary-file %t/main.swift @%t/MyApp.cmd -emit-loaded-module-trace -emit-loaded-module-trace-path %t/test.trace.json 2>&1 \
37+
// RUN: | %FileCheck %s --check-prefix=WARNING --allow-empty
38+
39+
// WARNING-NOT: WARNING:
40+
41+
// RUN: %FileCheck %s --check-prefix=TRACE --input-file=%t/test.trace.json
42+
// TRACE-DAG: A.swiftinterface
43+
44+
// RUN: %{python} %S/../Inputs/process_fine_grained_swiftdeps_with_fingerprints.py %swift-dependency-tool %t/test.swiftdeps > %t/test-processed.swiftdeps
45+
// RUN: %FileCheck %s --check-prefix=SWIFTDEPS --input-file=%t/test-processed.swiftdeps
46+
// SWIFTDEPS: A.swiftinterface
47+
// SWIFTDEPS: B.swiftmdoule
48+
49+
50+
//--- main.swift
51+
import A
52+
53+
//--- A.swift
54+
import B
55+
func test() {}
56+
57+
//--- B.swift
58+
func b() {}

0 commit comments

Comments
 (0)