File tree Expand file tree Collapse file tree 3 files changed +53
-1
lines changed Expand file tree Collapse file tree 3 files changed +53
-1
lines changed Original file line number Diff line number Diff line change @@ -324,6 +324,17 @@ void SILLinkerVisitor::visitProtocolConformance(
324
324
return ;
325
325
}
326
326
327
+ if (Mod.getASTContext ().LangOpts .hasFeature (Feature::Embedded) &&
328
+ isAvailableExternally (WT->getLinkage ()) &&
329
+ WT->getProtocol ()->requiresClass ()) {
330
+ // In embedded swift all the code is generated in the top-level module.
331
+ // De-serialized tables (= public_external) must be code-gen'd and
332
+ // therefore made non-external.
333
+ // Note: for functions we do that at the end of the pipeline in the
334
+ // IRGenPrepare pass to be able to eliminate dead functions.
335
+ WT->setLinkage (SILLinkage::Hidden);
336
+ }
337
+
327
338
auto maybeVisitRelatedConformance = [&](ProtocolConformanceRef c) {
328
339
// Formally all conformances referenced by a used conformance are used.
329
340
// However, eagerly visiting them all at this point leads to a large blowup
Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ class IRGenPrepare : public SILFunctionTransform {
92
92
// Even de-serialized functions must be code-gen'd.
93
93
SILLinkage linkage = F->getLinkage ();
94
94
if (isAvailableExternally (linkage)) {
95
- F->setLinkage (stripExternalFromLinkage (linkage) );
95
+ F->setLinkage (SILLinkage::Hidden );
96
96
}
97
97
}
98
98
Original file line number Diff line number Diff line change
1
+ // RUN: %empty-directory(%t)
2
+ // RUN: %{python} %utils/split_file.py -o %t %s
3
+
4
+ // RUN: %target-swift-frontend -emit-module -o %t/MyModule.swiftmodule %t/MyModule.swift -enable-experimental-feature Embedded -parse-as-library
5
+ // RUN: %target-swift-frontend -c -I %t %t/Main.swift -enable-experimental-feature Embedded -parse-as-library -o %t/a.o
6
+ // RUN: %target-clang -x c -c %S/Inputs/print.c -o %t/print.o
7
+ // RUN: %target-clang %t/a.o %t/print.o -o %t/a.out
8
+ // RUN: %target-run %t/a.out | %FileCheck %s
9
+
10
+ // REQUIRES: swift_in_compiler
11
+ // REQUIRES: executable_test
12
+ // REQUIRES: OS=macosx || OS=linux-gnu
13
+ // REQUIRES: swift_feature_Embedded
14
+
15
+ // BEGIN MyModule.swift
16
+
17
+ public protocol Foo : AnyObject {
18
+ func run( )
19
+ }
20
+
21
+ public class Hello : Foo {
22
+ public init ( ) { }
23
+ public func run( ) {
24
+ print ( " Hello from MyLibrary! " )
25
+ }
26
+ }
27
+
28
+ // BEGIN Main.swift
29
+
30
+ import MyModule
31
+
32
+ @main
33
+ struct MyApp {
34
+ static func main( ) {
35
+ let ex : Foo = Hello ( )
36
+ print ( " Hello from main! " )
37
+ ex. run ( )
38
+ }
39
+ }
40
+
41
+ // CHECK: Hello from main!
You can’t perform that action at this time.
0 commit comments