Rollup merge of #101598 - chriswailes:sanitizers, r=nagisa,eholk
Update rustc's information on Android's sanitizers This patch updates sanitizer support definitions for Android inside the compiler. It also adjusts the logic to make sure no pre-built sanitizer runtime libraries are emitted as these are instead provided dynamically on Android targets.
This commit is contained in:
commit
b36a10af7e
@ -1090,11 +1090,12 @@ fn add_sanitizer_libraries(sess: &Session, crate_type: CrateType, linker: &mut d
|
||||
// both executables and dynamic shared objects. Everywhere else the runtimes
|
||||
// are currently distributed as static libraries which should be linked to
|
||||
// executables only.
|
||||
let needs_runtime = match crate_type {
|
||||
CrateType::Executable => true,
|
||||
CrateType::Dylib | CrateType::Cdylib | CrateType::ProcMacro => sess.target.is_like_osx,
|
||||
CrateType::Rlib | CrateType::Staticlib => false,
|
||||
};
|
||||
let needs_runtime = !sess.target.is_like_android
|
||||
&& match crate_type {
|
||||
CrateType::Executable => true,
|
||||
CrateType::Dylib | CrateType::Cdylib | CrateType::ProcMacro => sess.target.is_like_osx,
|
||||
CrateType::Rlib | CrateType::Staticlib => false,
|
||||
};
|
||||
|
||||
if !needs_runtime {
|
||||
return;
|
||||
|
@ -1,10 +1,12 @@
|
||||
use crate::spec::TargetOptions;
|
||||
use crate::spec::{SanitizerSet, TargetOptions};
|
||||
|
||||
pub fn opts() -> TargetOptions {
|
||||
let mut base = super::linux_base::opts();
|
||||
base.os = "android".into();
|
||||
base.is_like_android = true;
|
||||
base.default_dwarf_version = 2;
|
||||
base.has_thread_local = false;
|
||||
base.supported_sanitizers = SanitizerSet::ADDRESS;
|
||||
// This is for backward compatibility, see https://github.com/rust-lang/rust/issues/49867
|
||||
// for context. (At that time, there was no `-C force-unwind-tables`, so the only solution
|
||||
// was to always emit `uwtable`).
|
||||
|
@ -1,9 +1,10 @@
|
||||
use crate::spec::{LinkerFlavor, StackProbeType, Target};
|
||||
use crate::spec::{LinkerFlavor, SanitizerSet, StackProbeType, Target};
|
||||
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::linux_gnu_base::opts();
|
||||
base.cpu = "pentium4".into();
|
||||
base.max_atomic_width = Some(64);
|
||||
base.supported_sanitizers = SanitizerSet::ADDRESS;
|
||||
base.add_pre_link_args(LinkerFlavor::Gcc, &["-m32"]);
|
||||
// don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
|
||||
base.stack_probes = StackProbeType::Call;
|
||||
|
@ -1381,6 +1381,8 @@ pub struct TargetOptions {
|
||||
pub is_like_msvc: bool,
|
||||
/// Whether a target toolchain is like WASM.
|
||||
pub is_like_wasm: bool,
|
||||
/// Whether a target toolchain is like Android, implying a Linux kernel and a Bionic libc
|
||||
pub is_like_android: bool,
|
||||
/// Default supported version of DWARF on this platform.
|
||||
/// Useful because some platforms (osx, bsd) only want up to DWARF2.
|
||||
pub default_dwarf_version: u32,
|
||||
@ -1673,6 +1675,7 @@ fn default() -> TargetOptions {
|
||||
is_like_windows: false,
|
||||
is_like_msvc: false,
|
||||
is_like_wasm: false,
|
||||
is_like_android: false,
|
||||
default_dwarf_version: 4,
|
||||
allows_weak_linkage: true,
|
||||
has_rpath: false,
|
||||
@ -2320,6 +2323,7 @@ macro_rules! key {
|
||||
key!(is_like_windows, bool);
|
||||
key!(is_like_msvc, bool);
|
||||
key!(is_like_wasm, bool);
|
||||
key!(is_like_android, bool);
|
||||
key!(default_dwarf_version, u32);
|
||||
key!(allows_weak_linkage, bool);
|
||||
key!(has_rpath, bool);
|
||||
@ -2570,6 +2574,7 @@ macro_rules! target_option_val {
|
||||
target_option_val!(is_like_windows);
|
||||
target_option_val!(is_like_msvc);
|
||||
target_option_val!(is_like_wasm);
|
||||
target_option_val!(is_like_android);
|
||||
target_option_val!(default_dwarf_version);
|
||||
target_option_val!(allows_weak_linkage);
|
||||
target_option_val!(has_rpath);
|
||||
|
@ -11,9 +11,15 @@
|
||||
pub const ASAN_SUPPORTED_TARGETS: &[&str] = &[
|
||||
"aarch64-apple-darwin",
|
||||
"aarch64-fuchsia",
|
||||
"aarch64-linux-android",
|
||||
"aarch64-unknown-linux-gnu",
|
||||
"arm-linux-androideabi",
|
||||
"armv7-linux-androideabi",
|
||||
"i686-linux-android",
|
||||
"i686-unknown-linux-gnu",
|
||||
"x86_64-apple-darwin",
|
||||
"x86_64-fuchsia",
|
||||
"x86_64-linux-android",
|
||||
"x86_64-unknown-freebsd",
|
||||
"x86_64-unknown-linux-gnu",
|
||||
];
|
||||
|
Loading…
Reference in New Issue
Block a user