PassWrapper: disable UseOdrIndicator for Asan Win32

As described here UseOdrIndicator should be disabled on Windows
since link.exe does not support duplicate weak definitions
(https://reviews.llvm.org/D137227).

Co-Authored-By: Bastian Kersting <bkersting@google.com>
This commit is contained in:
Jakob Koschel 2024-11-08 13:24:54 +00:00 committed by Jieyou Xu
parent a00df61387
commit 61013f040e
3 changed files with 40 additions and 4 deletions

View file

@ -882,10 +882,12 @@ extern "C" LLVMRustResult LLVMRustOptimize(
SanitizerOptions->SanitizeKernelAddress) {
OptimizerLastEPCallbacks.push_back(
#if LLVM_VERSION_GE(20, 0)
[SanitizerOptions](ModulePassManager &MPM, OptimizationLevel Level,
ThinOrFullLTOPhase phase) {
[SanitizerOptions, TM](ModulePassManager &MPM,
OptimizationLevel Level,
ThinOrFullLTOPhase phase) {
#else
[SanitizerOptions](ModulePassManager &MPM, OptimizationLevel Level) {
[SanitizerOptions, TM](ModulePassManager &MPM,
OptimizationLevel Level) {
#endif
auto CompileKernel = SanitizerOptions->SanitizeKernelAddress;
AddressSanitizerOptions opts = AddressSanitizerOptions{
@ -895,7 +897,12 @@ extern "C" LLVMRustResult LLVMRustOptimize(
/*UseAfterScope=*/true,
AsanDetectStackUseAfterReturnMode::Runtime,
};
MPM.addPass(AddressSanitizerPass(opts));
MPM.addPass(AddressSanitizerPass(
opts,
/*UseGlobalGC*/ true,
// UseOdrIndicator should be false on windows machines
// https://reviews.llvm.org/D137227
!TM->getTargetTriple().isOSWindows()));
});
}
if (SanitizerOptions->SanitizeHWAddress) {