Skip to content

Commit ee09790

Browse files
Update swift compiler after clang gmodule CAS build update
Fix swift compiler build and test to work with new clang gmodule build with CAS, which encodes references to clang PCMs as CASIDs.
1 parent 1cf8d2e commit ee09790

File tree

6 files changed

+23
-19
lines changed

6 files changed

+23
-19
lines changed

lib/DependencyScan/ScanDependencies.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,12 @@ class ExplicitModuleDependencyResolver {
143143
auto &dep = cache.findKnownDependency(bridgingDep);
144144
auto *clangDep = dep.getAsClangModule();
145145
assert(clangDep && "wrong module dependency kind");
146+
auto pcmPath = llvm::sys::path::filename(clangDep->mappedPCMPath).str();
146147
if (!clangDep->moduleCacheKey.empty()) {
147148
bridgingHeaderBuildCmd.push_back("-Xcc");
148149
bridgingHeaderBuildCmd.push_back("-fmodule-file-cache-key");
149150
bridgingHeaderBuildCmd.push_back("-Xcc");
150-
bridgingHeaderBuildCmd.push_back(clangDep->mappedPCMPath);
151+
bridgingHeaderBuildCmd.push_back(pcmPath);
151152
bridgingHeaderBuildCmd.push_back("-Xcc");
152153
bridgingHeaderBuildCmd.push_back(clangDep->moduleCacheKey);
153154
}
@@ -277,17 +278,21 @@ class ExplicitModuleDependencyResolver {
277278
bool handleClangModuleDependency(
278279
ModuleDependencyID depModuleID,
279280
const ClangModuleDependencyStorage &clangDepDetails) {
281+
auto pcmPath =
282+
clangDepDetails.moduleCacheKey.empty()
283+
? clangDepDetails.mappedPCMPath
284+
: llvm::sys::path::filename(clangDepDetails.mappedPCMPath).str();
280285
if (!resolvingDepInfo.isSwiftSourceModule()) {
281286
if (!resolvingDepInfo.isClangModule()) {
282287
commandline.push_back("-Xcc");
283288
commandline.push_back("-fmodule-file=" + depModuleID.ModuleName + "=" +
284-
clangDepDetails.mappedPCMPath);
289+
pcmPath);
285290
}
286291
if (!clangDepDetails.moduleCacheKey.empty()) {
287292
commandline.push_back("-Xcc");
288293
commandline.push_back("-fmodule-file-cache-key");
289294
commandline.push_back("-Xcc");
290-
commandline.push_back(clangDepDetails.mappedPCMPath);
295+
commandline.push_back(pcmPath);
291296
commandline.push_back("-Xcc");
292297
commandline.push_back(clangDepDetails.moduleCacheKey);
293298
}

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -929,10 +929,10 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
929929
// Note: The implementation here assumes that all clang submodules
930930
// belong to the same PCM file.
931931
ASTSourceDescriptor ParentDescriptor(*ClangModule->Parent);
932-
Parent = getOrCreateModule({ParentDescriptor.getModuleName(),
933-
ParentDescriptor.getPath(),
934-
Desc.getASTFile(), Desc.getSignature()},
935-
ClangModule->Parent);
932+
Parent = getOrCreateModule(
933+
{ParentDescriptor.getModuleName(), ParentDescriptor.getPath(),
934+
Desc.getASTFile(), Desc.getSignature(), /*CASID=*/""},
935+
ClangModule->Parent);
936936
}
937937
return getOrCreateModule(ClangModule, Parent, Desc.getModuleName(),
938938
IncludePath, Signature, Desc.getASTFile());
@@ -2594,11 +2594,11 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
25942594
// Describe the submodule, but substitute the cached ASTFile from
25952595
// the toplevel module. The ASTFile pointer in SubModule may be
25962596
// dangling and cant be trusted.
2597-
Scope = getOrCreateModule({SubModuleDesc->getModuleName(),
2598-
SubModuleDesc->getPath(),
2599-
TopLevelModuleDesc->getASTFile(),
2600-
TopLevelModuleDesc->getSignature()},
2601-
SubModuleDesc->getModuleOrNull());
2597+
Scope = getOrCreateModule(
2598+
{SubModuleDesc->getModuleName(), SubModuleDesc->getPath(),
2599+
TopLevelModuleDesc->getASTFile(),
2600+
TopLevelModuleDesc->getSignature(), /*CASID=*/""},
2601+
SubModuleDesc->getModuleOrNull());
26022602
else if (SubModuleDesc->getModuleOrNull() == nullptr)
26032603
// This is (bridging header) PCH.
26042604
Scope = getOrCreateModule(*SubModuleDesc, nullptr);

test/CAS/bridging-header.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
// CHECK: "-dwarf-ext-refs"
1919
// CHECK: "-fmodule-file-cache-key",
2020
// CHECK-NEXT: "-Xcc",
21-
// CHECK-NEXT: "{{.*}}{{/|\\}}A-{{.*}}.pcm",
21+
// CHECK-NEXT: "A-{{.*}}.pcm",
2222
// CHECK-NEXT: "-Xcc",
2323
// CHECK-NEXT: "llvmcas://{{.*}}",
2424
// CHECK-NEXT: "-Xcc",
2525
// CHECK-NEXT: "-fmodule-file-cache-key",
2626
// CHECK-NEXT: "-Xcc",
27-
// CHECK-NEXT: "{{.*}}{{/|\\}}B-{{.*}}.pcm",
27+
// CHECK-NEXT: "B-{{.*}}.pcm",
2828
// CHECK-NEXT: "-Xcc",
2929
// CHECK-NEXT: "llvmcas://{{.*}}"
3030

test/CAS/debug_info_pcm.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616

1717
// RUN: dwarfdump --debug-info @%t/A.path | %FileCheck %s
1818

19-
// CHECK: DW_AT_GNU_dwo_name
20-
// CHECK-SAME: TMP_DIR
19+
// CHECK: DW_AT_GNU_dwo_name ("llvmcas://{{.*}}")
2120

2221
//--- test.swift
2322
import A

test/CAS/module_path_remap.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
// DEPS-FS: /^src/test/CAS/module_path_remap.swift
1515

1616
// RUN: %{python} %S/Inputs/SwiftDepsExtractor.py %t/deps.json deps bridgingHeader | %FileCheck %s -check-prefix DEPS-BRIDGING
17-
// DEPS-BRIDGING: -fmodule-file=F=/^tmp/clang-module-cache/F-{{.*}}.pcm
17+
// DEPS-BRIDGING: -fmodule-file=F=F-{{.*}}.pcm
1818

1919
// RUN: %{python} %S/Inputs/SwiftDepsExtractor.py %t/deps.json F casFSRootID > %t/F.fs.casid
2020
// RUN: %cache-tool -cas-path %t/cas -cache-tool-action print-include-tree-list @%t/F.fs.casid | %FileCheck %s -check-prefix F-FS
2121
// F-FS: /^src/test/CAS/../ScanDependencies/Inputs/Swift/F.swiftinterface
2222

2323
// RUN: %{python} %S/Inputs/SwiftDepsExtractor.py %t/deps.json F commandLine | %FileCheck %s -check-prefix F-CMD
2424
// F-CMD: /^src/test/CAS/../ScanDependencies/Inputs/Swift/F.swiftinterface
25-
// F-CMD: -fmodule-file=SwiftShims=/^tmp/clang-module-cache/SwiftShims-{{.*}}.pcm
25+
// F-CMD: -fmodule-file=SwiftShims=SwiftShims-{{.*}}.pcm
2626

2727
// RUN: %{python} %S/Inputs/SwiftDepsExtractor.py %t/deps.json clang:F clangIncludeTree > %t/tree.casid
2828
// RUN: clang-cas-test --cas %t/cas --print-include-tree @%t/tree.casid | %FileCheck %s -check-prefix TREE

test/ScanDependencies/clang_module_output_symlink.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// Check the contents of the JSON output
1313
// RUN: %validate-json %t/deps.json | %FileCheck %s
1414

15-
// CHECK: "-fmodule-file=C=[[PCM_PATH:.*symlink.*C-.*.pcm]]"
15+
// CHECK: "-fmodule-file=C=[[PCM_PATH:C-.*.pcm]]"
1616
// CHECK: "-fmodule-file-cache-key"
1717
// CHECK-NEXT: "-Xcc"
1818
// CHECK-NEXT: "[[PCM_PATH]]"

0 commit comments

Comments
 (0)