Skip to content

Commit e40481e

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 65b3877 commit e40481e

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

+11-4
Original file line numberDiff line numberDiff line change
@@ -882,10 +882,12 @@ extern "C" LLVMRustResult LLVMRustOptimize(
882882
SanitizerOptions->SanitizeKernelAddress) {
883883
OptimizerLastEPCallbacks.push_back(
884884
#if LLVM_VERSION_GE(20, 0)
885-
[SanitizerOptions](ModulePassManager &MPM, OptimizationLevel Level,
886-
ThinOrFullLTOPhase phase) {
885+
[SanitizerOptions, TM](ModulePassManager &MPM,
886+
OptimizationLevel Level,
887+
ThinOrFullLTOPhase phase) {
887888
#else
888-
[SanitizerOptions](ModulePassManager &MPM, OptimizationLevel Level) {
889+
[SanitizerOptions, TM](ModulePassManager &MPM,
890+
OptimizationLevel Level) {
889891
#endif
890892
auto CompileKernel = SanitizerOptions->SanitizeKernelAddress;
891893
AddressSanitizerOptions opts = AddressSanitizerOptions{
@@ -895,7 +897,12 @@ extern "C" LLVMRustResult LLVMRustOptimize(
895897
/*UseAfterScope=*/true,
896898
AsanDetectStackUseAfterReturnMode::Runtime,
897899
};
898-
MPM.addPass(AddressSanitizerPass(opts));
900+
MPM.addPass(AddressSanitizerPass(
901+
opts,
902+
/*UseGlobalGC*/ true,
903+
// UseOdrIndicator should be false on windows machines
904+
// https://reviews.llvm.org/D137227
905+
!TM->getTargetTriple().isOSWindows()));
899906
});
900907
}
901908
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-crate: othercrate=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,10 @@
1+
//@ no-prefer-dynamic
2+
//@ compile-flags:-Zsanitizer=address
3+
#![crate_type="rlib"]
4+
5+
pub fn exposed_func() {
6+
let result = std::panic::catch_unwind(|| {
7+
println!("hello!");
8+
});
9+
assert!(result.is_ok());
10+
}

0 commit comments

Comments
 (0)