Skip to content

Commit 0d2a4a8

Browse files
committed
Serialization: ensure that we deserialise IsStaticLibrary correctly
We would previously fail to deserialise the IsStaticLibrary bit on certain declarations when they were imported implicitly. This would result in incorrect IRGen on Windows when building against a static swift module.
1 parent 19f4b6f commit 0d2a4a8

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lib/Serialization/DeserializeSIL.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,7 @@ SILDeserializer::readSILFunctionChecked(DeclID FID, SILFunction *existingFn,
678678
fn->setIsAlwaysWeakImported(isWeakImported);
679679
fn->setClassSubclassScope(SubclassScope(subclassScope));
680680
fn->setHasCReferences(bool(hasCReferences));
681+
fn->setIsStaticallyLinked(MF->getAssociatedModule()->isStaticLibrary());
681682

682683
llvm::VersionTuple available;
683684
DECODE_VER_TUPLE(available);

test/IRGen/static-serialization.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %swift-target-frontend -static -emit-module -emit-module-path %t/StaticLibrary.swiftmodule/%host_triple.swiftmodule -module-name StaticLibrary -DSTATIC_LIBRARY %s
3+
// RUN: %swift-target-frontend -I%t -S %s -emit-ir -o - | %FileCheck %s
4+
5+
#if STATIC_LIBRARY
6+
public final class S {
7+
public init() { }
8+
deinit {}
9+
}
10+
11+
@_transparent
12+
public func f() -> S { S() }
13+
#else
14+
import StaticLibrary
15+
internal let s = f()
16+
#endif
17+
18+
// CHECK-NOT: declare dllimport swiftcc ptr @"$s13StaticLibrary1SCACycfC"(ptr swiftself)
19+
// CHECK: declare swiftcc ptr @"$s13StaticLibrary1SCACycfC"(ptr swiftself)

0 commit comments

Comments
 (0)