Skip to content

Commit

Permalink
Auto merge of #94601 - csmoe:android-asan, r=nagisa
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
bors committed Mar 5, 2022
2 parents c274e49 + 6d41565 commit 0cbef1c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion compiler/rustc_target/src/spec/aarch64_linux_android.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ pub fn target() -> Target {
features: "+neon,+fp-armv8".to_string(),
supported_sanitizers: SanitizerSet::CFI
| SanitizerSet::HWADDRESS
| SanitizerSet::MEMTAG,
| SanitizerSet::MEMTAG
| SanitizerSet::ADDRESS,
..super::android_base::opts()
},
}
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_target/src/spec/arm_linux_androideabi.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::spec::{Target, TargetOptions};
use crate::spec::{SanitizerSet, Target, TargetOptions};

pub fn target() -> Target {
Target {
Expand All @@ -10,6 +10,7 @@ pub fn target() -> Target {
abi: "eabi".to_string(),
// https://developer.android.com/ndk/guides/abis.html#armeabi
features: "+strict-align,+v5te".to_string(),
supported_sanitizers: SanitizerSet::ADDRESS,
max_atomic_width: Some(32),
..super::android_base::opts()
},
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_target/src/spec/armv7_linux_androideabi.rs
Original file line number Diff line number Diff line change
@@ -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
// in thumb mode. It's named armv7-* instead of thumbv7-*
Expand All @@ -19,6 +19,7 @@ pub fn target() -> Target {
options: TargetOptions {
abi: "eabi".to_string(),
features: "+v7,+thumb-mode,+thumb2,+vfp3,-d32,-neon".to_string(),
supported_sanitizers: SanitizerSet::ADDRESS,
max_atomic_width: Some(64),
..base
},
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_target/src/spec/i686_linux_android.rs
Original file line number Diff line number Diff line change
@@ -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
// for target ABI requirements.
Expand All @@ -21,6 +21,6 @@ pub fn target() -> Target {
f64:32:64-f80:32-n8:16:32-S128"
.to_string(),
arch: "x86".to_string(),
options: base,
options: TargetOptions { supported_sanitizers: SanitizerSet::ADDRESS, ..base },
}
}
4 changes: 2 additions & 2 deletions compiler/rustc_target/src/spec/x86_64_linux_android.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::spec::{LinkerFlavor, StackProbeType, Target};
use crate::spec::{LinkerFlavor, SanitizerSet, StackProbeType, Target, TargetOptions};

pub fn target() -> Target {
let mut base = super::android_base::opts();
Expand All @@ -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"
.to_string(),
arch: "x86_64".to_string(),
options: base,
options: TargetOptions { supported_sanitizers: SanitizerSet::ADDRESS, ..base },
}
}

0 comments on commit 0cbef1c

Please sign in to comment.