Skip to content

Commit 592eea6

Browse files
Jakob-Koschel1c3t3a
andcommitted
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 <[email protected]>
1 parent a1c5b5a commit 592eea6

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
lines changed

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

+11-4
Original file line numberDiff line numberDiff line change
@@ -883,10 +883,12 @@ extern "C" LLVMRustResult LLVMRustOptimize(
883883
SanitizerOptions->SanitizeKernelAddress) {
884884
OptimizerLastEPCallbacks.push_back(
885885
#if LLVM_VERSION_GE(20, 0)
886-
[SanitizerOptions](ModulePassManager &MPM, OptimizationLevel Level,
887-
ThinOrFullLTOPhase phase) {
886+
[SanitizerOptions, TM](ModulePassManager &MPM,
887+
OptimizationLevel Level,
888+
ThinOrFullLTOPhase phase) {
888889
#else
889-
[SanitizerOptions](ModulePassManager &MPM, OptimizationLevel Level) {
890+
[SanitizerOptions, TM](ModulePassManager &MPM,
891+
OptimizationLevel Level) {
890892
#endif
891893
auto CompileKernel = SanitizerOptions->SanitizeKernelAddress;
892894
AddressSanitizerOptions opts = AddressSanitizerOptions{
@@ -896,7 +898,12 @@ extern "C" LLVMRustResult LLVMRustOptimize(
896898
/*UseAfterScope=*/true,
897899
AsanDetectStackUseAfterReturnMode::Runtime,
898900
};
899-
MPM.addPass(AddressSanitizerPass(opts));
901+
MPM.addPass(AddressSanitizerPass(
902+
opts,
903+
/*UseGlobalGC*/ true,
904+
// UseOdrIndicator should be false on windows machines
905+
// https://reviews.llvm.org/D137227
906+
!TM->getTargetTriple().isOSWindows()));
900907
});
901908
}
902909
if (SanitizerOptions->SanitizeHWAddress) {
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@ run-pass
2+
//@ compile-flags:-Zsanitizer=address
3+
//@ aux-build:asan_odr_win-2.rs
4+
//@ only-windows
5+
6+
extern crate othercrate;
7+
8+
fn main() {
9+
let result = std::panic::catch_unwind(|| {
10+
println!("hello!");
11+
});
12+
assert!(result.is_ok());
13+
14+
othercrate::exposed_func();
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@ no-prefer-dynamic
2+
//@ compile-flags:-Zsanitizer=address
3+
#![crate_type="rlib"]
4+
#![crate_name = "othercrate"]
5+
6+
pub fn exposed_func() {
7+
let result = std::panic::catch_unwind(|| {
8+
println!("hello!");
9+
});
10+
assert!(result.is_ok());
11+
}

0 commit comments

Comments
 (0)