Skip to content

Commit 5fb4a66

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 cadae7d commit 5fb4a66

File tree

5 files changed

+60
-16
lines changed

5 files changed

+60
-16
lines changed

lib/DependencyScan/ScanDependencies.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ class ExplicitModuleDependencyResolver {
146146
bridgingHeaderBuildCmd.push_back("-Xcc");
147147
bridgingHeaderBuildCmd.push_back("-fmodule-file-cache-key");
148148
bridgingHeaderBuildCmd.push_back("-Xcc");
149-
bridgingHeaderBuildCmd.push_back(clangDep->mappedPCMPath);
149+
bridgingHeaderBuildCmd.push_back(
150+
llvm::sys::path::filename(clangDep->mappedPCMPath).str());
150151
bridgingHeaderBuildCmd.push_back("-Xcc");
151152
bridgingHeaderBuildCmd.push_back(clangDep->moduleCacheKey);
152153
}
@@ -276,17 +277,19 @@ class ExplicitModuleDependencyResolver {
276277
bool handleClangModuleDependency(
277278
ModuleDependencyID depModuleID,
278279
const ClangModuleDependencyStorage &clangDepDetails) {
280+
auto pcmPath =
281+
llvm::sys::path::filename(clangDepDetails.mappedPCMPath).str();
279282
if (!resolvingDepInfo.isSwiftSourceModule()) {
280283
if (!resolvingDepInfo.isClangModule()) {
281284
commandline.push_back("-Xcc");
282285
commandline.push_back("-fmodule-file=" + depModuleID.ModuleName + "=" +
283-
clangDepDetails.mappedPCMPath);
286+
pcmPath);
284287
}
285288
if (!clangDepDetails.moduleCacheKey.empty()) {
286289
commandline.push_back("-Xcc");
287290
commandline.push_back("-fmodule-file-cache-key");
288291
commandline.push_back("-Xcc");
289-
commandline.push_back(clangDepDetails.mappedPCMPath);
292+
commandline.push_back(pcmPath);
290293
commandline.push_back("-Xcc");
291294
commandline.push_back(clangDepDetails.moduleCacheKey);
292295
}

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -913,10 +913,10 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
913913
// Note: The implementation here assumes that all clang submodules
914914
// belong to the same PCM file.
915915
ASTSourceDescriptor ParentDescriptor(*ClangModule->Parent);
916-
Parent = getOrCreateModule({ParentDescriptor.getModuleName(),
917-
ParentDescriptor.getPath(),
918-
Desc.getASTFile(), Desc.getSignature()},
919-
ClangModule->Parent);
916+
Parent = getOrCreateModule(
917+
{ParentDescriptor.getModuleName(), ParentDescriptor.getPath(),
918+
Desc.getASTFile(), Desc.getSignature(), /*CASID=*/""},
919+
ClangModule->Parent);
920920
}
921921
return getOrCreateModule(ClangModule, Parent, Desc.getModuleName(),
922922
IncludePath, Signature, Desc.getASTFile());
@@ -2565,11 +2565,11 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
25652565
// Describe the submodule, but substitute the cached ASTFile from
25662566
// the toplevel module. The ASTFile pointer in SubModule may be
25672567
// dangling and cant be trusted.
2568-
Scope = getOrCreateModule({SubModuleDesc->getModuleName(),
2569-
SubModuleDesc->getPath(),
2570-
TopLevelModuleDesc->getASTFile(),
2571-
TopLevelModuleDesc->getSignature()},
2572-
SubModuleDesc->getModuleOrNull());
2568+
Scope = getOrCreateModule(
2569+
{SubModuleDesc->getModuleName(), SubModuleDesc->getPath(),
2570+
TopLevelModuleDesc->getASTFile(),
2571+
TopLevelModuleDesc->getSignature(), /*CASID=*/""},
2572+
SubModuleDesc->getModuleOrNull());
25732573
else if (SubModuleDesc->getModuleOrNull() == nullptr)
25742574
// This is (bridging header) PCH.
25752575
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: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: split-file %s %t
3+
4+
// RUN: %target-swift-frontend -scan-dependencies -module-name Test -module-cache-path %t/clang-module-cache -O \
5+
// RUN: -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import \
6+
// RUN: %t/test.swift -o %t/deps.json -cache-compile-job -cas-path %t/cas -I %t/include
7+
8+
// RUN: %{python} %S/Inputs/BuildCommandExtractor.py %t/deps.json clang:SwiftShims > %t/shim.cmd
9+
// RUN: %swift_frontend_plain @%t/shim.cmd
10+
// RUN: %{python} %S/Inputs/BuildCommandExtractor.py %t/deps.json clang:B > %t/B.cmd
11+
// RUN: %swift_frontend_plain @%t/B.cmd
12+
// RUN: %{python} %S/Inputs/BuildCommandExtractor.py %t/deps.json clang:A > %t/A.cmd
13+
// RUN: %swift_frontend_plain @%t/A.cmd
14+
// RUN: %{python} %S/Inputs/SwiftDepsExtractor.py %t/deps.json clang:A modulePath > %t/A.path
15+
16+
// RUN: dwarfdump --debug-info @%t/A.path | %FileCheck %s
17+
18+
// CHECK: DW_AT_GNU_dwo_name ("llvmcas://{{.*}}")
19+
20+
//--- test.swift
21+
import A
22+
23+
//--- include/a.h
24+
#include "b.h"
25+
struct A {
26+
int a;
27+
};
28+
29+
//--- include/b.h
30+
void b(void);
31+
32+
//--- include/module.modulemap
33+
module A {
34+
header "a.h"
35+
export *
36+
}
37+
38+
module B {
39+
header "b.h"
40+
export *
41+
}

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

0 commit comments

Comments
 (0)