Skip to content

Commit 15011f0

Browse files
committed
IRGen: fix DLL storage for runtime functions
The runtime functions should not have DLLImport storage for the runtime functions. Without this change, we would see `swift_unexpectedError` be given DLL Import DLL Storage. It should probably be given DLLExport DLL Storage. This is needed to repair the Windows build. The problem is that the ExternalLinkage does not indicate whether the function is internally available or externally available, merely that it participates in linkage resolution. Ensure that we only give import storage to declarations with ExternalLinkage.
1 parent bcb9571 commit 15011f0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/IRGen/IRGenModule.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,8 @@ llvm::Constant *swift::getRuntimeFn(llvm::Module &Module,
472472
fn->setCallingConv(cc);
473473

474474
if (::useDllStorage(llvm::Triple(Module.getTargetTriple())) &&
475-
(fn->getLinkage() == llvm::GlobalValue::ExternalLinkage ||
475+
((fn->getLinkage() == llvm::GlobalValue::ExternalLinkage &&
476+
fn->isDeclaration()) ||
476477
fn->getLinkage() == llvm::GlobalValue::AvailableExternallyLinkage))
477478
fn->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
478479

0 commit comments

Comments
 (0)