Skip to content

Commit 0fcbf76

Browse files
committed
[TEMP] MSVC: Try LLVM's built-in weak-any implementation starting with LLVM 13
1 parent 118e122 commit 0fcbf76

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

gen/functions.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -944,8 +944,9 @@ bool eraseDummyAfterReturnBB(llvm::BasicBlock *bb) {
944944
return false;
945945
}
946946

947+
#if LDC_LLVM_VER < 1300
947948
/**
948-
* LLVM doesn't really support weak linkage for MSVC targets, it just prevents
949+
* (Old) LLVM doesn't really support weak linkage for MSVC targets, it just prevents
949950
* inlining. We can emulate it though, by conceptually renaming the defined
950951
* function, only declaring the original function and embedding a linker
951952
* directive in the object file, instructing the linker to fall back to the weak
@@ -999,6 +1000,7 @@ void emulateWeakAnyLinkageForMSVC(LLFunction *func, LINK linkage) {
9991000
setLinkage({LLGlobalValue::ExternalLinkage, false}, func);
10001001
func->deleteBody();
10011002
}
1003+
#endif // LDC_LLVM_VER < 1300
10021004

10031005
} // anonymous namespace
10041006

@@ -1376,11 +1378,13 @@ void DtoDefineFunction(FuncDeclaration *fd, bool linkageAvailableExternally) {
13761378
gIR->dcomputetarget->addKernelMetadata(fd, fn);
13771379
}
13781380

1381+
#if LDC_LLVM_VER < 1300
13791382
if (func->getLinkage() == LLGlobalValue::WeakAnyLinkage &&
13801383
!func->hasDLLExportStorageClass() &&
13811384
global.params.targetTriple->isWindowsMSVCEnvironment()) {
13821385
emulateWeakAnyLinkageForMSVC(func, fd->linkage);
13831386
}
1387+
#endif
13841388
}
13851389

13861390
////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)