mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Weak-Link the Immediate Re-Exports of a Weak-Linked Module
When a module is imported @_weakLinked, its re-exported peer modules have their definitions imported with strong linkage which can often defeat the point of weak linking the parent in the first place. Allow the weak-linkage to float to the immediate re-exports of the @_weakLinked module. Resolves rdar://117166194
This commit is contained in:
@@ -3441,6 +3441,17 @@ bool SourceFile::importsModuleAsWeakLinked(const ModuleDecl *module) const {
|
||||
importedModule->getUnderlyingModuleIfOverlay();
|
||||
if (module == clangModule)
|
||||
return true;
|
||||
|
||||
// Traverse the exported modules of this weakly-linked module to ensure
|
||||
// that we weak-link declarations from its exported peers.
|
||||
SmallVector<ImportedModule, 8> reexportedModules;
|
||||
importedModule->getImportedModules(reexportedModules,
|
||||
ModuleDecl::ImportFilterKind::Exported);
|
||||
for (const ImportedModule &reexportedModule : reexportedModules) {
|
||||
if (!module->isNonSwiftModule() &&
|
||||
module == reexportedModule.importedModule)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user