Skip to content

Commit 49c5487

Browse files
committed
Serialization: Auto-linking recursively walks modules imported from -sil-serialize-all modules
1 parent 56c67f9 commit 49c5487

File tree

249 files changed

+20
-1727
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

249 files changed

+20
-1727
lines changed

include/swift/Serialization/SerializedModuleLoader.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ class SerializedASTFile final : public LoadedFile {
106106
SerializedASTFile(Module &M, ModuleFile &file, bool isSIB = false)
107107
: LoadedFile(FileUnitKind::SerializedAST, M), File(file), IsSIB(isSIB) {}
108108

109+
void
110+
collectLinkLibrariesFromImports(Module::LinkLibraryCallback callback) const;
111+
109112
public:
110113
bool isSIB() const { return IsSIB; }
111114

lib/Serialization/SerializedModuleLoader.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -423,15 +423,24 @@ void SerializedASTFile::getImportedModules(
423423
File.getImportedModules(imports, filter);
424424
}
425425

426+
void SerializedASTFile::collectLinkLibrariesFromImports(
427+
Module::LinkLibraryCallback callback) const {
428+
llvm::SmallVector<Module::ImportedModule, 8> Imports;
429+
File.getImportedModules(Imports, Module::ImportFilter::All);
430+
431+
for (auto Import : Imports)
432+
Import.second->collectLinkLibraries(callback);
433+
}
434+
426435
void SerializedASTFile::collectLinkLibraries(
427436
Module::LinkLibraryCallback callback) const {
428437
if (isSIB()) {
429-
llvm::SmallVector<Module::ImportedModule, 8> Imports;
430-
File.getImportedModules(Imports, Module::ImportFilter::All);
431-
432-
for (auto Import : Imports)
433-
Import.second->collectLinkLibraries(callback);
438+
collectLinkLibrariesFromImports(callback);
434439
} else {
440+
if (File.getAssociatedModule()->getResilienceStrategy()
441+
== ResilienceStrategy::Fragile) {
442+
collectLinkLibrariesFromImports(callback);
443+
}
435444
File.collectLinkLibraries(callback);
436445
}
437446
}

stdlib/private/StdlibCollectionUnittest/StdlibCollectionUnittest.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,3 @@
1212

1313
import StdlibUnittest
1414

15-
// Also import modules which are used by StdlibUnittest internally. This
16-
// workaround is needed to link all required libraries in case we compile
17-
// StdlibUnittest with -sil-serialize-all.
18-
import SwiftPrivate
19-
#if _runtime(_ObjC)
20-
import ObjectiveC
21-
#endif

stdlib/private/StdlibUnittestFoundationExtras/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@ add_swift_library(swiftStdlibUnittestFoundationExtras SHARED IS_STDLIB
33
# filename.
44
StdlibUnittestFoundationExtras.swift
55

6-
# Cannot serialize StdlibUnittestFoundationExtras because of:
7-
# <rdar://problem/18917405> Compiling StdlibUnittest with -sil-serialize-all
8-
# crashes in SIL serializer
9-
#
10-
# SWIFT_COMPILE_FLAGS ${STDLIB_SIL_SERIALIZE_ALL}
11-
126
SWIFT_MODULE_DEPENDS Foundation
137
INSTALL_IN_COMPONENT stdlib-experimental)
148

test/1_stdlib/ArrayTraps.swift.gyb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@
1010

1111
import StdlibUnittest
1212

13-
// Also import modules which are used by StdlibUnittest internally. This
14-
// workaround is needed to link all required libraries in case we compile
15-
// StdlibUnittest with -sil-serialize-all.
16-
import SwiftPrivate
17-
#if _runtime(_ObjC)
18-
import ObjectiveC
19-
#endif
2013

2114
%{
2215
# We test for bounds-checking traps for both reading and writing

test/1_stdlib/ArrayTrapsObjC.swift.gyb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@
1111

1212
import StdlibUnittest
1313

14-
// Also import modules which are used by StdlibUnittest internally. This
15-
// workaround is needed to link all required libraries in case we compile
16-
// StdlibUnittest with -sil-serialize-all.
17-
import SwiftPrivate
18-
#if _runtime(_ObjC)
19-
import ObjectiveC
20-
#endif
2114

2215
import Foundation
2316

test/1_stdlib/BoolBridge.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@
55
import Foundation
66
import StdlibUnittest
77

8-
// Also import modules which are used by StdlibUnittest internally. This
9-
// workaround is needed to link all required libraries in case we compile
10-
// StdlibUnittest with -sil-serialize-all.
11-
import SwiftPrivate
12-
#if _runtime(_ObjC)
13-
import ObjectiveC
14-
#endif
158

169
let BoolTests = TestSuite("Bool")
1710

test/1_stdlib/Builtins.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,6 @@ import Swift
2121
import SwiftShims
2222
import StdlibUnittest
2323

24-
// Also import modules which are used by StdlibUnittest internally. This
25-
// workaround is needed to link all required libraries in case we compile
26-
// StdlibUnittest with -sil-serialize-all.
27-
import SwiftPrivate
28-
#if _runtime(_ObjC)
29-
import ObjectiveC
30-
#endif
3124

3225
#if _runtime(_ObjC)
3326
import Foundation

test/1_stdlib/CastTraps.swift.gyb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,6 @@
1212

1313
import StdlibUnittest
1414

15-
// Also import modules which are used by StdlibUnittest internally. This
16-
// workaround is needed to link all required libraries in case we compile
17-
// StdlibUnittest with -sil-serialize-all.
18-
import SwiftPrivate
19-
#if _runtime(_ObjC)
20-
import ObjectiveC
21-
#endif
2215

2316
import Foundation
2417

test/1_stdlib/Casts.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@
1818

1919
import StdlibUnittest
2020

21-
// Also import modules which are used by StdlibUnittest internally. This
22-
// workaround is needed to link all required libraries in case we compile
23-
// StdlibUnittest with -sil-serialize-all.
24-
#if _runtime(_ObjC)
25-
import ObjectiveC
26-
#endif
2721

2822
let CastsTests = TestSuite("Casts")
2923

test/1_stdlib/Character.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ import StdlibUnittest
77
import Swift
88
import SwiftPrivate
99

10-
// Also import modules which are used by StdlibUnittest internally. This
11-
// workaround is needed to link all required libraries in case we compile
12-
// StdlibUnittest with -sil-serialize-all.
13-
#if _runtime(_ObjC)
14-
import ObjectiveC
15-
#endif
1610

1711
//===---
1812
// Utilities.

test/1_stdlib/CharacterTraps.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,6 @@
99

1010
import StdlibUnittest
1111

12-
// Also import modules which are used by StdlibUnittest internally. This
13-
// workaround is needed to link all required libraries in case we compile
14-
// StdlibUnittest with -sil-serialize-all.
15-
import SwiftPrivate
16-
#if _runtime(_ObjC)
17-
import ObjectiveC
18-
#endif
19-
2012

2113
var CharacterTraps = TestSuite("CharacterTraps")
2214

test/1_stdlib/Collection.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@
66

77
import StdlibUnittest
88

9-
// Also import modules which are used by StdlibUnittest internally. This
10-
// workaround is needed to link all required libraries in case we compile
11-
// StdlibUnittest with -sil-serialize-all.
12-
#if _runtime(_ObjC)
13-
import ObjectiveC
14-
#endif
159

1610
var CollectionTests = TestSuite("CollectionTests")
1711

test/1_stdlib/DarwinAPI.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@
55

66
import StdlibUnittest
77

8-
// Also import modules which are used by StdlibUnittest internally. This
9-
// workaround is needed to link all required libraries in case we compile
10-
// StdlibUnittest with -sil-serialize-all.
11-
import SwiftPrivate
12-
#if _runtime(_ObjC)
13-
import ObjectiveC
14-
#endif
158

169
import Foundation
1710

test/1_stdlib/DictionaryLiteral.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@ import SwiftExperimental
1818
import Foundation
1919
import StdlibUnittest
2020

21-
// Also import modules which are used by StdlibUnittest internally. This
22-
// workaround is needed to link all required libraries in case we compile
23-
// StdlibUnittest with -sil-serialize-all.
24-
import SwiftPrivate
25-
#if _runtime(_ObjC)
26-
import ObjectiveC
27-
#endif
2821

2922
// Check that the generic parameters are called 'Key' and 'Value'.
3023
protocol TestProtocol1 {}

test/1_stdlib/DictionaryTraps.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,6 @@ public extension _ObjectiveCBridgeable {
2323
}
2424
}
2525

26-
// Also import modules which are used by StdlibUnittest internally. This
27-
// workaround is needed to link all required libraries in case we compile
28-
// StdlibUnittest with -sil-serialize-all.
29-
import SwiftPrivate
30-
#if _runtime(_ObjC)
31-
import ObjectiveC
32-
#endif
3326

3427
struct NotBridgedKeyTy : Equatable, Hashable {
3528
init(_ value: Int) {

test/1_stdlib/DictionaryUnchecked.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@
66

77
import StdlibUnittest
88

9-
// Also import modules which are used by StdlibUnittest internally. This
10-
// workaround is needed to link all required libraries in case we compile
11-
// StdlibUnittest with -sil-serialize-all.
12-
import SwiftPrivate
13-
#if _runtime(_ObjC)
14-
import ObjectiveC
15-
#endif
169

1710
var DictionaryUnchecked = TestSuite("DictionaryUnchecked")
1811

test/1_stdlib/Dispatch.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@ import Dispatch
77
import Foundation
88
import StdlibUnittest
99

10-
// Also import modules which are used by StdlibUnittest internally. This
11-
// workaround is needed to link all required libraries in case we compile
12-
// StdlibUnittest with -sil-serialize-all.
13-
import SwiftPrivate
14-
#if _runtime(_ObjC)
15-
import ObjectiveC
16-
#endif
1710

1811
defer { runAllTests() }
1912

test/1_stdlib/ErrorHandling.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@
77

88
import StdlibUnittest
99

10-
// Also import modules which are used by StdlibUnittest internally. This
11-
// workaround is needed to link all required libraries in case we compile
12-
// StdlibUnittest with -sil-serialize-all.
13-
import SwiftPrivate
14-
#if _runtime(_ObjC)
15-
import ObjectiveC
16-
#endif
1710

1811
var NoisyCount = 0
1912

test/1_stdlib/ErrorProtocol.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@
33

44
import StdlibUnittest
55

6-
// Also import modules which are used by StdlibUnittest internally. This
7-
// workaround is needed to link all required libraries in case we compile
8-
// StdlibUnittest with -sil-serialize-all.
9-
import SwiftPrivate
10-
#if _runtime(_ObjC)
11-
import ObjectiveC
12-
#endif
136

147
var ErrorProtocolTests = TestSuite("ErrorProtocol")
158

test/1_stdlib/ErrorProtocolBridging.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@
44

55
import StdlibUnittest
66

7-
// Also import modules which are used by StdlibUnittest internally. This
8-
// workaround is needed to link all required libraries in case we compile
9-
// StdlibUnittest with -sil-serialize-all.
10-
import SwiftPrivate
11-
#if _runtime(_ObjC)
12-
import ObjectiveC
13-
#endif
147

158
import Foundation
169
import CoreLocation

test/1_stdlib/Experimental.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@
44
import SwiftExperimental
55
import StdlibUnittest
66

7-
// Also import modules which are used by StdlibUnittest internally. This
8-
// workaround is needed to link all required libraries in case we compile
9-
// StdlibUnittest with -sil-serialize-all.
10-
import SwiftPrivate
11-
#if _runtime(_ObjC)
12-
import ObjectiveC
13-
#endif
147

158
var ExperimentalTestSuite = TestSuite("Experimental")
169

test/1_stdlib/Filter.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@
1414

1515
import StdlibUnittest
1616

17-
// Also import modules which are used by StdlibUnittest internally. This
18-
// workaround is needed to link all required libraries in case we compile
19-
// StdlibUnittest with -sil-serialize-all.
20-
import SwiftPrivate
21-
#if _runtime(_ObjC)
22-
import ObjectiveC
23-
#endif
2417

2518
let FilterTests = TestSuite("Filter")
2619

test/1_stdlib/FloatingPoint.swift.gyb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@
88
import Swift
99
import StdlibUnittest
1010

11-
// Also import modules which are used by StdlibUnittest internally. This
12-
// workaround is needed to link all required libraries in case we compile
13-
// StdlibUnittest with -sil-serialize-all.
14-
import SwiftPrivate
15-
#if _runtime(_ObjC)
16-
import ObjectiveC
17-
#endif
1811

1912
#if arch(i386) || arch(x86_64)
2013

test/1_stdlib/ImplicitlyUnwrappedOptional.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,6 @@ if c === nil {
3838

3939
import StdlibUnittest
4040

41-
// Also import modules which are used by StdlibUnittest internally. This
42-
// workaround is needed to link all required libraries in case we compile
43-
// StdlibUnittest with -sil-serialize-all.
44-
import SwiftPrivate
45-
#if _runtime(_ObjC)
46-
import ObjectiveC
47-
#endif
4841

4942
import Swift
5043

test/1_stdlib/InputStream.swift.gyb

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

2121
import StdlibUnittest
2222

23-
// Also import modules which are used by StdlibUnittest internally. This
24-
// workaround is needed to link all required libraries in case we compile
25-
// StdlibUnittest with -sil-serialize-all.
26-
import SwiftPrivate
27-
#if _runtime(_ObjC)
28-
import ObjectiveC
29-
#endif
3023

3124
import Swift
3225

test/1_stdlib/Interval.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@
1616

1717
import StdlibUnittest
1818

19-
// Also import modules which are used by StdlibUnittest internally. This
20-
// workaround is needed to link all required libraries in case we compile
21-
// StdlibUnittest with -sil-serialize-all.
22-
import SwiftPrivate
23-
#if _runtime(_ObjC)
24-
import ObjectiveC
25-
#endif
2619

2720
// Check that the generic parameter is called 'Bound'.
2821
protocol TestProtocol1 {}

test/1_stdlib/IntervalTraps.swift

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

2121
import StdlibUnittest
2222

23-
// Also import modules which are used by StdlibUnittest internally. This
24-
// workaround is needed to link all required libraries in case we compile
25-
// StdlibUnittest with -sil-serialize-all.
26-
import SwiftPrivate
27-
#if _runtime(_ObjC)
28-
import ObjectiveC
29-
#endif
3023

3124
var IntervalTraps = TestSuite("IntervalTraps")
3225

0 commit comments

Comments
 (0)