Skip to content

Commit d53f4fc

Browse files
Merge pull request #76088 from cachemeifyoucan/eng/PR-134593841
[Caching] CASFS need to include blocklist
2 parents eb88991 + fd6707e commit d53f4fc

File tree

4 files changed

+70
-10
lines changed

4 files changed

+70
-10
lines changed

include/swift/AST/ModuleDependencies.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
#include "swift/AST/Import.h"
2222
#include "swift/AST/LinkLibrary.h"
23-
#include "swift/AST/SearchPathOptions.h"
2423
#include "swift/Basic/CXXStdlibKind.h"
2524
#include "swift/Basic/LLVM.h"
2625
#include "clang/CAS/CASOptions.h"
@@ -53,6 +52,7 @@ class ASTContext;
5352
class Identifier;
5453
class CompilerInstance;
5554
class IRGenOptions;
55+
class CompilerInvocation;
5656

5757
/// Which kind of module dependencies we are looking for.
5858
enum class ModuleDependencyKind : int8_t {
@@ -945,7 +945,7 @@ class SwiftDependencyTracker {
945945
: FS(FS.createProxyFS()), Mapper(Mapper) {}
946946

947947
void startTracking();
948-
void addCommonSearchPathDeps(const SearchPathOptions &Opts);
948+
void addCommonSearchPathDeps(const CompilerInvocation &CI);
949949
void trackFile(const Twine &path) { (void)FS->status(path); }
950950
llvm::Expected<llvm::cas::ObjectProxy> createTreeFromDependencies();
951951

lib/AST/ModuleDependencies.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -612,10 +612,11 @@ swift::dependencies::registerBackDeployLibraries(
612612
}
613613

614614
void SwiftDependencyTracker::addCommonSearchPathDeps(
615-
const SearchPathOptions &Opts) {
615+
const CompilerInvocation &CI) {
616+
auto &SearchPathOpts = CI.getSearchPathOptions();
616617
// Add SDKSetting file.
617618
SmallString<256> SDKSettingPath;
618-
llvm::sys::path::append(SDKSettingPath, Opts.getSDKPath(),
619+
llvm::sys::path::append(SDKSettingPath, SearchPathOpts.getSDKPath(),
619620
"SDKSettings.json");
620621
FS->status(SDKSettingPath);
621622

@@ -624,7 +625,7 @@ void SwiftDependencyTracker::addCommonSearchPathDeps(
624625
"arm64", "arm64e", "x86_64", "i386",
625626
"armv7", "armv7s", "armv7k", "arm64_32"};
626627

627-
for (auto RuntimeLibPath : Opts.RuntimeLibraryPaths) {
628+
for (auto RuntimeLibPath : SearchPathOpts.RuntimeLibraryPaths) {
628629
std::error_code EC;
629630
for (auto &Arch : AllSupportedArches) {
630631
SmallString<256> LayoutFile(RuntimeLibPath);
@@ -634,8 +635,12 @@ void SwiftDependencyTracker::addCommonSearchPathDeps(
634635
}
635636

636637
// Add VFSOverlay file.
637-
for (auto &Overlay: Opts.VFSOverlayFiles)
638+
for (auto &Overlay: SearchPathOpts.VFSOverlayFiles)
638639
FS->status(Overlay);
640+
641+
// Add blocklist file.
642+
for (auto &File: CI.getFrontendOptions().BlocklistConfigFilePaths)
643+
FS->status(File);
639644
}
640645

641646
void SwiftDependencyTracker::startTracking() {

lib/DependencyScan/ScanDependencies.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,7 @@ static llvm::Error resolveExplicitModuleInputs(
338338
// Compute the CASFS root ID for the resolving dependency.
339339
if (auto *sourceDep = resolvingDepInfo.getAsSwiftSourceModule()) {
340340
tracker->startTracking();
341-
tracker->addCommonSearchPathDeps(
342-
instance.getInvocation().getSearchPathOptions());
341+
tracker->addCommonSearchPathDeps(instance.getInvocation());
343342
llvm::for_each(
344343
sourceDep->sourceFiles,
345344
[&tracker](const std::string &file) { tracker->trackFile(file); });
@@ -359,8 +358,7 @@ static llvm::Error resolveExplicitModuleInputs(
359358
} else if (auto *textualDep =
360359
resolvingDepInfo.getAsSwiftInterfaceModule()) {
361360
tracker->startTracking();
362-
tracker->addCommonSearchPathDeps(
363-
instance.getInvocation().getSearchPathOptions());
361+
tracker->addCommonSearchPathDeps(instance.getInvocation());
364362
tracker->trackFile(textualDep->swiftInterfaceFile);
365363
llvm::for_each(
366364
textualDep->auxiliaryFiles,

test/CAS/block-list.swift

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: split-file %s %t
3+
4+
// RUN: %target-swift-frontend -scan-dependencies -module-name Test -O \
5+
// RUN: -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import \
6+
// RUN: -blocklist-file %t/blocklist.yml -blocklist-file %t/empty.yml \
7+
// RUN: %t/main.swift -o %t/deps.json -cache-compile-job -cas-path %t/cas
8+
9+
// RUN: %{python} %S/Inputs/BuildCommandExtractor.py %t/deps.json clang:SwiftShims > %t/shim.cmd
10+
// RUN: %swift_frontend_plain @%t/shim.cmd
11+
12+
// RUN: %{python} %S/Inputs/SwiftDepsExtractor.py %t/deps.json Test casFSRootID > %t/fs.casid
13+
// DISABLE: llvm-cas --cas %t/cas --ls-tree-recursive @%t/fs.casid | %FileCheck %s -check-prefix FS
14+
15+
// FS-DAG: blocklist.yml
16+
// FS-DAG: empty.yml
17+
18+
// RUN: %{python} %S/Inputs/GenerateExplicitModuleMap.py %t/deps.json > %t/map.json
19+
// RUN: llvm-cas --cas %t/cas --make-blob --data %t/map.json > %t/map.casid
20+
21+
// RUN: %{python} %S/Inputs/BuildCommandExtractor.py %t/deps.json Test > %t/MyApp.cmd
22+
23+
// RUN: %target-swift-frontend \
24+
// RUN: -emit-ir -o - -cache-compile-job -cas-path %t/cas -O \
25+
// RUN: -swift-version 5 -disable-implicit-swift-modules \
26+
// RUN: -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import \
27+
// RUN: -module-name Test -explicit-swift-module-map-file @%t/map.casid \
28+
// RUN: -blocklist-file %t/blocklist.yml -blocklist-file %t/empty.yml \
29+
// RUN: -enable-layout-string-value-witnesses -enable-layout-string-value-witnesses-instantiation \
30+
// RUN: -enable-experimental-feature LayoutStringValueWitnesses -enable-experimental-feature LayoutStringValueWitnessesInstantiation \
31+
// RUN: %t/main.swift @%t/MyApp.cmd 2>&1 | %FileCheck %s --check-prefix CHECK-BLOCKED
32+
33+
// CHECK-BLOCKED: note: Layout string value witnesses have been disabled for module 'Test' through block list entry
34+
// CHECK-BLOCKED-NOT: type_layout_string
35+
36+
//--- main.swift
37+
public struct Bar {
38+
let x: Int
39+
let y: AnyObject
40+
}
41+
42+
public enum Foo {
43+
case a(AnyObject)
44+
case b(Int, AnyObject)
45+
case c
46+
}
47+
48+
//--- blocklist.yml
49+
---
50+
ShouldUseLayoutStringValueWitnesses:
51+
ModuleName:
52+
- Test
53+
//--- empty.yml
54+
---
55+
PlaceHolder:
56+
ModuleName:
57+
- A

0 commit comments

Comments
 (0)