AST: Skip weak linking on Windows consistently.

Always special-case Windows targets in `isAlwaysWeakImported()` instead of
limiting the special case to declarations that are marked unavailable.
This commit is contained in:
Allan Shortlidge
2025-10-20 12:08:09 -07:00
parent 25af94495c
commit f87aa5323f
2 changed files with 37 additions and 3 deletions

View File

@@ -1525,12 +1525,15 @@ bool Decl::isAlwaysWeakImported() const {
return clangDecl->isWeakImported(
getASTContext().LangOpts.getMinPlatformVersion());
// FIXME: Weak linking on Windows is not yet supported
// https://github.com/apple/swift/issues/53303
if (getASTContext().LangOpts.Target.isOSWindows())
return false;
if (getAttrs().hasAttribute<WeakLinkedAttr>())
return true;
// FIXME: Weak linking on Windows is not yet supported
// https://github.com/apple/swift/issues/53303
if (isUnavailable() && !getASTContext().LangOpts.Target.isOSWindows())
if (isUnavailable())
return true;
if (auto *accessor = dyn_cast<AccessorDecl>(this))

View File

@@ -0,0 +1,31 @@
// RUN: %target-swift-emit-silgen %s -target %target-cpu-unknown-windows-msvc | %FileCheck %s
// REQUIRES: OS=windows-msvc
@_silgen_name("windows10")
@available(Windows 10, *)
public func windows10()
@_silgen_name("unavailable")
@available(Windows, unavailable)
public func unavailable()
// CHECK-LABEL: sil [ossa] @$s20availability_windows15testIfAvailableyyF : $@convention(thin) () -> ()
// CHECK: cond_br
// CHECK: function_ref @windows10
public func testIfAvailable() {
if #available(Windows 10, *) {
windows10()
}
}
// CHECK: sil [available 10] @windows10 : $@convention(thin) () -> ()
// CHECK-LABEL: sil [ossa] @$s20availability_windows15testUnavailableyyF : $@convention(thin) () -> ()
// CHECK: function_ref @unavailable
@available(*, unavailable)
public func testUnavailable() {
unavailable()
}
// FIXME: Mark [weak_imported] when weak linking is supported on Windows (https://github.com/apple/swift/issues/53303)
// CHECK: sil @unavailable : $@convention(thin) () -> ()