Skip to content

Commit 0cbef1c

Browse files
committed
Auto merge of #94601 - csmoe:android-asan, r=nagisa
add address sanitizer fo android We have been being using asan to debug the rust/cpp/c mixed android application in production for months: recompile the rust library with a patched rustc, everything just works fine. The patch is really small thanks to `@nagisa` 's refactoring in #81866 r? `@nagisa`
2 parents c274e49 + 6d41565 commit 0cbef1c

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

compiler/rustc_target/src/spec/aarch64_linux_android.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ pub fn target() -> Target {
1616
features: "+neon,+fp-armv8".to_string(),
1717
supported_sanitizers: SanitizerSet::CFI
1818
| SanitizerSet::HWADDRESS
19-
| SanitizerSet::MEMTAG,
19+
| SanitizerSet::MEMTAG
20+
| SanitizerSet::ADDRESS,
2021
..super::android_base::opts()
2122
},
2223
}

compiler/rustc_target/src/spec/arm_linux_androideabi.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::spec::{Target, TargetOptions};
1+
use crate::spec::{SanitizerSet, Target, TargetOptions};
22

33
pub fn target() -> Target {
44
Target {
@@ -10,6 +10,7 @@ pub fn target() -> Target {
1010
abi: "eabi".to_string(),
1111
// https://developer.android.com/ndk/guides/abis.html#armeabi
1212
features: "+strict-align,+v5te".to_string(),
13+
supported_sanitizers: SanitizerSet::ADDRESS,
1314
max_atomic_width: Some(32),
1415
..super::android_base::opts()
1516
},

compiler/rustc_target/src/spec/armv7_linux_androideabi.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::spec::{LinkerFlavor, Target, TargetOptions};
1+
use crate::spec::{LinkerFlavor, SanitizerSet, Target, TargetOptions};
22

33
// This target if is for the baseline of the Android v7a ABI
44
// in thumb mode. It's named armv7-* instead of thumbv7-*
@@ -19,6 +19,7 @@ pub fn target() -> Target {
1919
options: TargetOptions {
2020
abi: "eabi".to_string(),
2121
features: "+v7,+thumb-mode,+thumb2,+vfp3,-d32,-neon".to_string(),
22+
supported_sanitizers: SanitizerSet::ADDRESS,
2223
max_atomic_width: Some(64),
2324
..base
2425
},

compiler/rustc_target/src/spec/i686_linux_android.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::spec::{StackProbeType, Target};
1+
use crate::spec::{SanitizerSet, StackProbeType, Target, TargetOptions};
22

33
// See https://developer.android.com/ndk/guides/abis.html#x86
44
// for target ABI requirements.
@@ -21,6 +21,6 @@ pub fn target() -> Target {
2121
f64:32:64-f80:32-n8:16:32-S128"
2222
.to_string(),
2323
arch: "x86".to_string(),
24-
options: base,
24+
options: TargetOptions { supported_sanitizers: SanitizerSet::ADDRESS, ..base },
2525
}
2626
}

compiler/rustc_target/src/spec/x86_64_linux_android.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::spec::{LinkerFlavor, StackProbeType, Target};
1+
use crate::spec::{LinkerFlavor, SanitizerSet, StackProbeType, Target, TargetOptions};
22

33
pub fn target() -> Target {
44
let mut base = super::android_base::opts();
@@ -16,6 +16,6 @@ pub fn target() -> Target {
1616
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
1717
.to_string(),
1818
arch: "x86_64".to_string(),
19-
options: base,
19+
options: TargetOptions { supported_sanitizers: SanitizerSet::ADDRESS, ..base },
2020
}
2121
}

0 commit comments

Comments
 (0)