File tree Expand file tree Collapse file tree 5 files changed +104
-2
lines changed Expand file tree Collapse file tree 5 files changed +104
-2
lines changed Original file line number Diff line number Diff line change @@ -1666,7 +1666,8 @@ static void performParallelIRGeneration(IRGenDescriptor desc) {
1666
1666
llvm::Module *M = IGM->getModule ();
1667
1667
auto collectReference = [&](llvm::GlobalValue &G) {
1668
1668
if (G.isDeclaration ()
1669
- && (G.getLinkage () == GlobalValue::LinkOnceODRLinkage ||
1669
+ && (G.getLinkage () == GlobalValue::WeakODRLinkage ||
1670
+ G.getLinkage () == GlobalValue::LinkOnceODRLinkage ||
1670
1671
G.getLinkage () == GlobalValue::ExternalLinkage)) {
1671
1672
referencedGlobals.insert (G.getName ());
1672
1673
G.setLinkage (GlobalValue::ExternalLinkage);
@@ -1693,7 +1694,8 @@ static void performParallelIRGeneration(IRGenDescriptor desc) {
1693
1694
// definition (if it's not referenced in the same file).
1694
1695
auto updateLinkage = [&](llvm::GlobalValue &G) {
1695
1696
if (!G.isDeclaration ()
1696
- && G.getLinkage () == GlobalValue::LinkOnceODRLinkage
1697
+ && (G.getLinkage () == GlobalValue::WeakODRLinkage ||
1698
+ G.getLinkage () == GlobalValue::LinkOnceODRLinkage)
1697
1699
&& referencedGlobals.count (G.getName ()) != 0 ) {
1698
1700
G.setLinkage (GlobalValue::WeakODRLinkage);
1699
1701
}
Original file line number Diff line number Diff line change 5
5
6
6
#ifdef __linux__
7
7
8
+ #ifdef __cplusplus
9
+ extern "C"
10
+ #endif
8
11
ssize_t getrandom (void * buf , size_t len , unsigned int flags );
9
12
13
+ #ifdef __cplusplus
14
+ extern "C"
15
+ #endif
16
+ void arc4random_buf (void * buf , size_t nbytes );
17
+
10
18
void arc4random_buf (void * buf , size_t nbytes ) {
11
19
while (nbytes > 0 ) {
12
20
ssize_t actual_nbytes = 0 ;
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 %linux_rng_support_c_if_needed %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
Original file line number Diff line number Diff line change @@ -28,3 +28,9 @@ if config.available_features.intersection(set(supported_test_os_list)) == set():
28
28
config.environment = dict(config.environment)
29
29
if ' SWIFT_USE_OLD_DRIVER' in config.environment: del config.environment[' SWIFT_USE_OLD_DRIVER' ]
30
30
if ' SWIFT_AVOID_WARNING_USING_OLD_DRIVER' in config.environment: del config.environment[' SWIFT_AVOID_WARNING_USING_OLD_DRIVER' ]
31
+
32
+ # (5) Provide some useful substitutions to simplify writing tests that work across platforms (macOS, Linux, etc.)
33
+ if " OS=linux-gnu" in config.available_features:
34
+ config.substitutions.append((" %linux_rng_support_c_if_needed" , " %S/Inputs/linux-rng-support.c" ))
35
+ else:
36
+ config.substitutions.append((" %linux_rng_support_c_if_needed" , " " ))
You can’t perform that action at this time.
0 commit comments