mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Enforce consistent usage of -experimental-hermetic-seat-at-link flag (#39986)
We've recently added the -experimental-hermetic-seal-at-link compiler flag, which turns on aggressive dead-stripping optimizations and assumes that library code can be optimized against client code because all users of the library code/types are present at link/LTO time. This means that any module that's built with -experimental-hermetic-seal-at-link requires all clients of this module to also use -experimental-hermetic-seal-at-link. This PR enforces that by storing a bit in the serialized module, and checking the bit when importing modules.
This commit is contained in:
committed by
GitHub
parent
775c632d03
commit
c89eca6c34
@@ -741,6 +741,7 @@ LoadedFile *SerializedModuleLoaderBase::loadAST(
|
||||
// We've loaded the file. Now try to bring it into the AST.
|
||||
fileUnit = new (Ctx) SerializedASTFile(M, *loadedModuleFile);
|
||||
M.setStaticLibrary(loadedModuleFile->isStaticLibrary());
|
||||
M.setHasHermeticSealAtLink(loadedModuleFile->hasHermeticSealAtLink());
|
||||
if (loadedModuleFile->isTestable())
|
||||
M.setTestingEnabled();
|
||||
if (loadedModuleFile->arePrivateImportsEnabled())
|
||||
@@ -801,6 +802,15 @@ LoadedFile *SerializedModuleLoaderBase::loadAST(
|
||||
OrphanedModuleFiles.push_back(std::move(loadedModuleFile));
|
||||
}
|
||||
|
||||
// The -experimental-hermetic-seal-at-link flag turns on dead-stripping
|
||||
// optimizations assuming library code can be optimized against client code.
|
||||
// If the imported module was built with -experimental-hermetic-seal-at-link
|
||||
// but the current module isn't, error out.
|
||||
if (M.hasHermeticSealAtLink() && !Ctx.LangOpts.HermeticSealAtLink) {
|
||||
Ctx.Diags.diagnose(diagLoc.getValueOr(SourceLoc()),
|
||||
diag::need_hermetic_seal_to_import_module, M.getName());
|
||||
}
|
||||
|
||||
return fileUnit;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user