Skip to content

Commit 694e105

Browse files
authored
Merge pull request #77861 from compnerd/static-serialisation
Frontend: re-serialise static library status
2 parents 669930e + b660d20 commit 694e105

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

lib/Frontend/ModuleInterfaceBuilder.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ std::error_code ExplicitModuleInterfaceBuilder::buildSwiftModuleFromInterface(
279279
// optimization pipeline.
280280
SerializationOptions SerializationOpts;
281281
std::string OutPathStr = OutputPath.str();
282+
SerializationOpts.StaticLibrary = FEOpts.Static;
282283
SerializationOpts.OutputPath = OutPathStr.c_str();
283284
SerializationOpts.ModuleLinkName = FEOpts.ModuleLinkName;
284285
SerializationOpts.AutolinkForceLoad =
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// swift-interface-format-version: 1.0
2+
// swift-module-flags: -module-name dynamic
3+
4+
import Swift
5+
6+
public func f() {}
7+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// swift-interface-format-version: 1.0
2+
// swift-module-flags: -static -module-name static
3+
4+
import Swift
5+
6+
public func f() {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -module-cache-path %t/mcp -I %S/Inputs/SR77756 -c %s -o /dev/null -D STATIC
3+
// RUN: llvm-bcanalyzer -dump %t/mcp/static-*.swiftmodule | %FileCheck %s -check-prefix CHECK-STATIC
4+
// RUN: %target-swift-frontend -module-cache-path %t/mcp -I %S/Inputs/SR77756 -c %s -o /dev/null
5+
// RUN: llvm-bcanalyzer -dump %t/mcp/dynamic-*.swiftmodule | %FileCheck %s -check-prefix CHECK-DYNAMIC
6+
7+
#if STATIC
8+
import `static`
9+
#else
10+
import `dynamic`
11+
#endif
12+
13+
// CHECK-STATIC: IS_STATIC
14+
// CHECK-DYNAMIC-NOT: IS_STATIC

0 commit comments

Comments
 (0)