Skip to content

Commit 09e40fd

Browse files
committed
[PackageCMO] Workaround for static witness thunk linker issue.
PR #74468 rolled back conformance serialized kind to IsNotSerialized for non-public decls. This caused static witness thunks to be removed while use site expects them, causing linker issues. This PR provides a workaround until a proper fix is made. rdar://130103572
1 parent 68b6c7e commit 09e40fd

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/SIL/IR/SILWitnessTable.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,20 @@ void SILWitnessTable::convertToDefinition(
169169

170170
SerializedKind_t SILWitnessTable::conformanceSerializedKind(
171171
const RootProtocolConformance *conformance) {
172+
173+
auto optInPackage = conformance->getDeclContext()->getParentModule()->serializePackageEnabled();
174+
auto accessLevelToCheck =
175+
optInPackage ? AccessLevel::Package : AccessLevel::Public;
176+
172177
auto normalConformance = dyn_cast<NormalProtocolConformance>(conformance);
173-
if (normalConformance && normalConformance->isResilient())
178+
if (normalConformance && normalConformance->isResilient() && !optInPackage)
174179
return IsNotSerialized;
175180

176-
if (conformance->getProtocol()->getEffectiveAccess() < AccessLevel::Public)
181+
if (conformance->getProtocol()->getEffectiveAccess() < accessLevelToCheck)
177182
return IsNotSerialized;
178183

179184
auto *nominal = conformance->getDeclContext()->getSelfNominalTypeDecl();
180-
if (nominal->getEffectiveAccess() >= AccessLevel::Public)
185+
if (nominal->getEffectiveAccess() >= accessLevelToCheck)
181186
return IsSerialized;
182187

183188
return IsNotSerialized;

0 commit comments

Comments
 (0)