File tree Expand file tree Collapse file tree 3 files changed +90
-2
lines changed Expand file tree Collapse file tree 3 files changed +90
-2
lines changed Original file line number Diff line number Diff line change @@ -1666,7 +1666,8 @@ static void performParallelIRGeneration(IRGenDescriptor desc) {
16661666 llvm::Module *M = IGM->getModule ();
16671667 auto collectReference = [&](llvm::GlobalValue &G) {
16681668 if (G.isDeclaration ()
1669- && (G.getLinkage () == GlobalValue::LinkOnceODRLinkage ||
1669+ && (G.getLinkage () == GlobalValue::WeakODRLinkage ||
1670+ G.getLinkage () == GlobalValue::LinkOnceODRLinkage ||
16701671 G.getLinkage () == GlobalValue::ExternalLinkage)) {
16711672 referencedGlobals.insert (G.getName ());
16721673 G.setLinkage (GlobalValue::ExternalLinkage);
@@ -1693,7 +1694,8 @@ static void performParallelIRGeneration(IRGenDescriptor desc) {
16931694 // definition (if it's not referenced in the same file).
16941695 auto updateLinkage = [&](llvm::GlobalValue &G) {
16951696 if (!G.isDeclaration ()
1696- && G.getLinkage () == GlobalValue::LinkOnceODRLinkage
1697+ && (G.getLinkage () == GlobalValue::WeakODRLinkage ||
1698+ G.getLinkage () == GlobalValue::LinkOnceODRLinkage)
16971699 && referencedGlobals.count (G.getName ()) != 0 ) {
16981700 G.setLinkage (GlobalValue::WeakODRLinkage);
16991701 }
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 -mergeable-symbols -num-threads 2 -O -c -emit-module -o %t/MyModule.o %t/MyModule.swift -enable-experimental-feature Embedded -parse-as-library
5+ // RUN: %target-swift-frontend -mergeable-symbols -num-threads 2 -O -c -o %t/MainA.o -o %t/MainB.o %t/MainA.swift %t/MainB.swift -I %t -enable-experimental-feature Embedded -parse-as-library
6+ // RUN: %target-clang %t/MainA.o %t/MainB.o %t/MyModule.o -o %t/a.out
7+ // RUN: %target-run %t/a.out | %FileCheck %s
8+
9+ // REQUIRES: swift_in_compiler
10+ // REQUIRES: executable_test
11+ // REQUIRES: swift_feature_Embedded
12+
13+ // BEGIN MyModule.swift
14+
15+ public func module_func( n: Int ) {
16+ var a : [ Int ] = [ 1 , 2 , 3 ]
17+ print ( " module_func: \( a [ 0 ] ) " )
18+ }
19+
20+ // BEGIN MainA.swift
21+
22+ import MyModule
23+
24+ // BEGIN MainB.swift
25+
26+ import MyModule
27+
28+ @main
29+ struct Main {
30+ static func main( ) {
31+ module_func ( n: 5 )
32+ }
33+ }
34+
35+ // CHECK: module_func: 1
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 -mergeable-symbols -num-threads 2 -O -c -emit-module -o %t/MyModule.o %t/MyModule.swift -enable-experimental-feature Embedded -parse-as-library
5+ // RUN: %target-swift-frontend -mergeable-symbols -num-threads 2 -O -c -o %t/MainA.o -o %t/MainB.o %t/MainA.swift %t/MainB.swift -I %t -enable-experimental-feature Embedded -parse-as-library
6+ // RUN: %target-clang %t/MainA.o %t/MainB.o %t/MyModule.o -o %t/a.out
7+ // RUN: %target-run %t/a.out | %FileCheck %s
8+
9+ // REQUIRES: swift_in_compiler
10+ // REQUIRES: executable_test
11+ // REQUIRES: swift_feature_Embedded
12+
13+ // BEGIN MyModule.swift
14+
15+ var dict : [ Int : Int ] = [ 1 : 2 , 3 : 4 ]
16+
17+ public func module_func( ) {
18+ print ( " module_func: \( dict [ 1 ] !) " )
19+ }
20+
21+ // BEGIN MainA.swift
22+
23+ import MyModule
24+
25+ fileprivate var dict : [ Int : Int ] = [ 5 : 6 , 7 : 8 ]
26+
27+ func mainA_func( ) {
28+ print ( " main_func: \( dict [ 5 ] !) " )
29+ }
30+
31+ // BEGIN MainB.swift
32+
33+ import MyModule
34+
35+ fileprivate var dict : [ Int : Int ] = [ 5 : 6 , 7 : 8 ]
36+
37+ func mainB_func( ) {
38+ print ( " main_func: \( dict [ 5 ] !) " )
39+ }
40+
41+ @main
42+ struct Main {
43+ static func main( ) {
44+ module_func ( )
45+ mainA_func ( )
46+ mainB_func ( )
47+ }
48+ }
49+
50+ // CHECK: module_func: 2
51+ // CHECK: main_func: 6
You can’t perform that action at this time.
0 commit comments