[Serialization] Load indirect package dependencies from the current package

When loading a swiftmodule A, read its package information to tell if
the current client should load A's dependencies imports by a package
import. Only clients belonging to the same package as A should load
those dependencies, clients outside of the package likely don't have
access to those dependencies.

This is specific to swiftmodules as swiftinterfaces never display a
package-only import. Clients are unaware of package dependencies when
building against a swiftinterface.

rdar://106164813
This commit is contained in:
Alexis Laferrière
2023-03-02 14:37:15 -08:00
parent 6980cf211b
commit 5be7e2d1d5
4 changed files with 18 additions and 0 deletions

View File

@@ -426,6 +426,10 @@ llvm::ErrorOr<ModuleDependencyInfo> SerializedModuleLoaderBase::scanModuleFile(
if (dependency.isImplementationOnly())
continue;
if (dependency.isPackageOnly() &&
Ctx.LangOpts.PackageName != loadedModuleFile->getModulePackageName())
continue;
// Find the top-level module name.
auto modulePathStr = dependency.getPrettyPrintedPath();
StringRef moduleName = modulePathStr;