Skip to content

Commit c0b612c

Browse files
committed
IRGen: adjust addressability of the generic metadata
When building on Windows, if the nominal base type is in a non-static library, we cannot reference the type descriptor directly. As a load is required, we cannot statically initialise the pattern metadata. Account for this in the addressability computation.
1 parent 07b8f0a commit c0b612c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/IRGen/MetadataRequest.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,12 @@ bool irgen::isSpecializedNominalTypeMetadataStaticallyAddressable(
836836
if (IGM.getSwiftModule() == nominal->getModuleContext()) {
837837
return false;
838838
}
839+
// We cannot reference the type context across the module boundary on
840+
// PE/COFF without a load. This prevents us from statically initializing the
841+
// pattern.
842+
if (IGM.Triple.isOSWindows() &&
843+
!nominal->getModuleContext()->isStaticLibrary())
844+
return false;
839845
if (nominal->isResilient(IGM.getSwiftModule(),
840846
ResilienceExpansion::Maximal)) {
841847
return false;

0 commit comments

Comments
 (0)