[embedded] Add basics of module serialization, importing and validation in embedded Swift.

- Add a flag to the serialized module (IsEmbeddedSwiftModule)
- Check on import that the mode matches (don't allow importing non-embedded module in embedded mode and vice versa)
- Drop TBD support, it's not expected to work in embedded Swift for now
- Drop auto-linking backdeploy libraries, it's not expected to backdeploy embedded Swift for now
- Drop prespecializations, not expected to work in embedded Swift for now
- Use CMO to serialize everything when emitting an embedded Swift module
- Change SILLinker to deserialize/import everything when importing an embedded Swift module
- Add an IR test for importing modules
- Add a deserialization validation test
This commit is contained in:
Kuba Mracek
2023-09-02 11:55:17 -07:00
parent 74e22dc450
commit 25eb997a28
25 changed files with 188 additions and 21 deletions

View File

@@ -826,6 +826,7 @@ LoadedFile *SerializedModuleLoaderBase::loadAST(
fileUnit = new (Ctx) SerializedASTFile(M, *loadedModuleFile);
M.setStaticLibrary(loadedModuleFile->isStaticLibrary());
M.setHasHermeticSealAtLink(loadedModuleFile->hasHermeticSealAtLink());
M.setIsEmbeddedSwiftModule(loadedModuleFile->isEmbeddedSwiftModule());
if (loadedModuleFile->isTestable())
M.setTestingEnabled();
if (loadedModuleFile->arePrivateImportsEnabled())
@@ -916,6 +917,18 @@ LoadedFile *SerializedModuleLoaderBase::loadAST(
diag::need_hermetic_seal_to_import_module, M.getName());
}
if (M.isEmbeddedSwiftModule() &&
!Ctx.LangOpts.hasFeature(Feature::Embedded)) {
Ctx.Diags.diagnose(diagLoc.value_or(SourceLoc()),
diag::cannot_import_embedded_module, M.getName());
}
if (!M.isEmbeddedSwiftModule() &&
Ctx.LangOpts.hasFeature(Feature::Embedded)) {
Ctx.Diags.diagnose(diagLoc.value_or(SourceLoc()),
diag::cannot_import_non_embedded_module, M.getName());
}
// Non-resilient modules built with C++ interoperability enabled
// are typically incompatible with clients that do not enable
// C++ interoperability.