Skip to content

Commit 9133f02

Browse files
authored
Merge pull request #69480 from nkcsgexi/blocklistsupportforusingtextualinterface
ModuleInterface: allow blocklist to configure module names from SDKs that we use textual interfaces exclusively
2 parents 7e4fa78 + 09d6944 commit 9133f02

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,8 @@ NOTE(compiled_module_ignored_reason,none,
440440
"compiled module '%0' was ignored because %select{%error"
441441
"|it belongs to a framework in the SDK"
442442
"|loading from module interfaces is preferred"
443-
"|it's a compiler host module}1",
443+
"|it's a compiler host module"
444+
"|the module name is blocklisted}1",
444445
(StringRef, unsigned))
445446
NOTE(out_of_date_module_here,none,
446447
"%select{compiled|cached|forwarding|prebuilt}0 module is out of date: '%1'",

lib/Frontend/ModuleInterfaceLoader.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ struct ModuleRebuildInfo {
236236
PublicFramework,
237237
InterfacePreferred,
238238
CompilerHostModule,
239+
Blocklisted,
239240
};
240241
struct CandidateModule {
241242
std::string path;
@@ -758,6 +759,14 @@ class ModuleInterfaceLoaderImpl {
758759
// Should we attempt to load a swiftmodule adjacent to the swiftinterface?
759760
bool shouldLoadAdjacentModule = !ctx.IgnoreAdjacentModules;
760761

762+
if (modulePath.contains(".sdk")) {
763+
if (ctx.blockListConfig.hasBlockListAction(moduleName,
764+
BlockListKeyKind::ModuleName, BlockListAction::ShouldUseTextualModule)) {
765+
shouldLoadAdjacentModule = false;
766+
rebuildInfo.addIgnoredModule(modulePath, ReasonIgnored::Blocklisted);
767+
}
768+
}
769+
761770
// Don't use the adjacent swiftmodule for frameworks from the public
762771
// Frameworks folder of the SDK.
763772
if (isInSystemFrameworks(modulePath, /*publicFramework*/true)) {
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// REQUIRES: objc_interop
2+
// RUN: %empty-directory(%t)
3+
// RUN: %empty-directory(%t.sdk)
4+
// RUN: %empty-directory(%t/modulecache)
5+
// RUN: %target-swift-frontend -emit-module -o %t.sdk/Foo.swiftmodule -emit-module-interface-path %t.sdk/Foo.swiftinterface -module-name Foo %s -D FOO -enable-library-evolution
6+
// RUN: %target-swift-frontend -emit-module -o %t.sdk/Bar.swiftmodule -emit-module-interface-path %t.sdk/Bar.swiftinterface -module-name Bar %s -D BAR -enable-library-evolution -I %t.sdk
7+
8+
#if FOO
9+
10+
public func fooFunc() {}
11+
12+
#elseif BAR
13+
14+
import Foo
15+
public func barFunc() { fooFunc() }
16+
17+
#elseif BAZ
18+
19+
import Bar
20+
public func bazFunc() { barFunc() }
21+
22+
#endif
23+
24+
25+
// RUN: echo "---" > %t/blocklist.yml
26+
// RUN: echo "DowngradeInterfaceVerificationFailure:" >> %t/blocklist.yml
27+
// RUN: echo " ModuleName:" >> %t/blocklist.yml
28+
// RUN: echo " - TestBlocklistedModule # For tests" >> %t/blocklist.yml
29+
// RUN: echo "ShouldUseTextualModule:" >> %t/blocklist.yml
30+
// RUN: echo " ModuleName:" >> %t/blocklist.yml
31+
// RUN: echo " - Foo # for tests" >> %t/blocklist.yml
32+
33+
// RUN: %target-swift-frontend -typecheck %s -D BAZ -I %t.sdk -blocklist-file %t/blocklist.yml -module-cache-path %t/modulecache -Rmodule-interface-rebuild &> %t/notes.txt
34+
// RUN: %FileCheck -check-prefix CHECK-NOTES --input-file %t/notes.txt %s
35+
// CHECK-NOTES: Foo.swiftmodule' was ignored because the module name is blocklisted

0 commit comments

Comments
 (0)