IRGen: honour -static-libclosure in block creation

When creating a block, ensure that we correctly associate the DLL
Storage on the `_NSConcreteStackBlock` root object declaration based
upon whether we are generating code with `-static-libclosure` being
passed to the clang importer or not.
This commit is contained in:
Saleem Abdulrasool
2025-05-23 13:07:27 -07:00
parent cc2189bd05
commit c0993d466d
3 changed files with 23 additions and 4 deletions

View File

@@ -1170,10 +1170,15 @@ llvm::Constant *swift::getRuntimeFn(
if (IGM && useDllStorage(IGM->Triple) && IsExternal) {
bool bIsImported = true;
swift::ASTContext &Context = IGM->Context;
if (IGM->getSwiftModule()->getPublicModuleName(true).str() == ModuleName)
bIsImported = false;
else if (ModuleDecl *MD = IGM->Context.getModuleByName(ModuleName))
else if (ModuleDecl *MD = Context.getModuleByName(ModuleName))
bIsImported = !MD->isStaticLibrary();
else if (strcmp(ModuleName, "BlocksRuntime") == 0)
bIsImported =
!static_cast<ClangImporter *>(Context.getClangModuleLoader())
->getCodeGenOpts().StaticClosure;
if (bIsImported)
fn->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);