Skip to content

Commit eebc983

Browse files
authored
Merge pull request #67406 from compnerd/static
Serialization: ensure that we deserialise IsStaticLibrary correctly
2 parents 7505457 + 79e7785 commit eebc983

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 -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)