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 https://github.com/rust-lang/rust/pull/81866

r? `@nagisa`
This commit is contained in:
bors 2022-03-05 22:52:08 +00:00
commit 0cbef1c6a7
5 changed files with 10 additions and 7 deletions

View file

@ -16,7 +16,8 @@ pub fn target() -> Target {
features: "+neon,+fp-armv8".to_string(), features: "+neon,+fp-armv8".to_string(),
supported_sanitizers: SanitizerSet::CFI supported_sanitizers: SanitizerSet::CFI
| SanitizerSet::HWADDRESS | SanitizerSet::HWADDRESS
| SanitizerSet::MEMTAG, | SanitizerSet::MEMTAG
| SanitizerSet::ADDRESS,
..super::android_base::opts() ..super::android_base::opts()
}, },
} }

View file

@ -1,4 +1,4 @@
use crate::spec::{Target, TargetOptions}; use crate::spec::{SanitizerSet, Target, TargetOptions};
pub fn target() -> Target { pub fn target() -> Target {
Target { Target {
@ -10,6 +10,7 @@ pub fn target() -> Target {
abi: "eabi".to_string(), abi: "eabi".to_string(),
// https://developer.android.com/ndk/guides/abis.html#armeabi // https://developer.android.com/ndk/guides/abis.html#armeabi
features: "+strict-align,+v5te".to_string(), features: "+strict-align,+v5te".to_string(),
supported_sanitizers: SanitizerSet::ADDRESS,
max_atomic_width: Some(32), max_atomic_width: Some(32),
..super::android_base::opts() ..super::android_base::opts()
}, },

View file

@ -1,4 +1,4 @@
use crate::spec::{LinkerFlavor, Target, TargetOptions}; use crate::spec::{LinkerFlavor, SanitizerSet, Target, TargetOptions};
// This target if is for the baseline of the Android v7a ABI // This target if is for the baseline of the Android v7a ABI
// in thumb mode. It's named armv7-* instead of thumbv7-* // in thumb mode. It's named armv7-* instead of thumbv7-*
@ -19,6 +19,7 @@ pub fn target() -> Target {
options: TargetOptions { options: TargetOptions {
abi: "eabi".to_string(), abi: "eabi".to_string(),
features: "+v7,+thumb-mode,+thumb2,+vfp3,-d32,-neon".to_string(), features: "+v7,+thumb-mode,+thumb2,+vfp3,-d32,-neon".to_string(),
supported_sanitizers: SanitizerSet::ADDRESS,
max_atomic_width: Some(64), max_atomic_width: Some(64),
..base ..base
}, },

View file

@ -1,4 +1,4 @@
use crate::spec::{StackProbeType, Target}; use crate::spec::{SanitizerSet, StackProbeType, Target, TargetOptions};
// See https://developer.android.com/ndk/guides/abis.html#x86 // See https://developer.android.com/ndk/guides/abis.html#x86
// for target ABI requirements. // for target ABI requirements.
@ -21,6 +21,6 @@ pub fn target() -> Target {
f64:32:64-f80:32-n8:16:32-S128" f64:32:64-f80:32-n8:16:32-S128"
.to_string(), .to_string(),
arch: "x86".to_string(), arch: "x86".to_string(),
options: base, options: TargetOptions { supported_sanitizers: SanitizerSet::ADDRESS, ..base },
} }
} }

View file

@ -1,4 +1,4 @@
use crate::spec::{LinkerFlavor, StackProbeType, Target}; use crate::spec::{LinkerFlavor, SanitizerSet, StackProbeType, Target, TargetOptions};
pub fn target() -> Target { pub fn target() -> Target {
let mut base = super::android_base::opts(); let mut base = super::android_base::opts();
@ -16,6 +16,6 @@ pub fn target() -> Target {
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
.to_string(), .to_string(),
arch: "x86_64".to_string(), arch: "x86_64".to_string(),
options: base, options: TargetOptions { supported_sanitizers: SanitizerSet::ADDRESS, ..base },
} }
} }