Skip to content

Commit 484f3be

Browse files
authored
Merge pull request #85015 from tshortli/never-weak-link-on-windows
AST: Skip weak linking on Windows consistently
2 parents 4eaf33f + f87aa53 commit 484f3be

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

lib/AST/Decl.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,12 +1525,15 @@ bool Decl::isAlwaysWeakImported() const {
15251525
return clangDecl->isWeakImported(
15261526
getASTContext().LangOpts.getMinPlatformVersion());
15271527

1528+
// FIXME: Weak linking on Windows is not yet supported
1529+
// https://github.com/apple/swift/issues/53303
1530+
if (getASTContext().LangOpts.Target.isOSWindows())
1531+
return false;
1532+
15281533
if (getAttrs().hasAttribute<WeakLinkedAttr>())
15291534
return true;
15301535

1531-
// FIXME: Weak linking on Windows is not yet supported
1532-
// https://github.com/apple/swift/issues/53303
1533-
if (isUnavailable() && !getASTContext().LangOpts.Target.isOSWindows())
1536+
if (isUnavailable())
15341537
return true;
15351538

15361539
if (auto *accessor = dyn_cast<AccessorDecl>(this))
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// RUN: %target-swift-emit-silgen %s -target %target-cpu-unknown-windows-msvc | %FileCheck %s
2+
// REQUIRES: OS=windows-msvc
3+
4+
@_silgen_name("windows10")
5+
@available(Windows 10, *)
6+
public func windows10()
7+
8+
@_silgen_name("unavailable")
9+
@available(Windows, unavailable)
10+
public func unavailable()
11+
12+
13+
// CHECK-LABEL: sil [ossa] @$s20availability_windows15testIfAvailableyyF : $@convention(thin) () -> ()
14+
// CHECK: cond_br
15+
// CHECK: function_ref @windows10
16+
public func testIfAvailable() {
17+
if #available(Windows 10, *) {
18+
windows10()
19+
}
20+
}
21+
// CHECK: sil [available 10] @windows10 : $@convention(thin) () -> ()
22+
23+
// CHECK-LABEL: sil [ossa] @$s20availability_windows15testUnavailableyyF : $@convention(thin) () -> ()
24+
// CHECK: function_ref @unavailable
25+
@available(*, unavailable)
26+
public func testUnavailable() {
27+
unavailable()
28+
}
29+
30+
// FIXME: Mark [weak_imported] when weak linking is supported on Windows (https://github.com/apple/swift/issues/53303)
31+
// CHECK: sil @unavailable : $@convention(thin) () -> ()

0 commit comments

Comments
 (0)