From 194d96e5c3b3bf069ff791813641b7d22f4f42e9 Mon Sep 17 00:00:00 2001 From: Eunji Jeong Date: Mon, 16 Feb 2015 17:48:50 +0900 Subject: [PATCH] Lower the default dwarf version for android --- src/librustc_back/target/aarch64_linux_android.rs | 1 + src/librustc_back/target/arm_linux_androideabi.rs | 1 + src/librustc_back/target/mod.rs | 4 ++++ src/librustc_trans/trans/debuginfo.rs | 4 +++- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/librustc_back/target/aarch64_linux_android.rs b/src/librustc_back/target/aarch64_linux_android.rs index 313c0dc2a6e..64b0e0cfd6b 100644 --- a/src/librustc_back/target/aarch64_linux_android.rs +++ b/src/librustc_back/target/aarch64_linux_android.rs @@ -13,6 +13,7 @@ use target::Target; pub fn target() -> Target { let mut base = super::linux_base::opts(); base.pre_link_args.push("-Wl,--allow-multiple-definition".to_string()); + base.is_like_android = true; base.position_independent_executables = true; Target { data_layout: "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\ diff --git a/src/librustc_back/target/arm_linux_androideabi.rs b/src/librustc_back/target/arm_linux_androideabi.rs index 6fc77a715a5..fad93441431 100644 --- a/src/librustc_back/target/arm_linux_androideabi.rs +++ b/src/librustc_back/target/arm_linux_androideabi.rs @@ -16,6 +16,7 @@ pub fn target() -> Target { // Many of the symbols defined in compiler-rt are also defined in libgcc. Android // linker doesn't like that by default. base.pre_link_args.push("-Wl,--allow-multiple-definition".to_string()); + base.is_like_android = true; // FIXME #17437 (and #17448): Android doesn't support position dependent executables anymore. base.position_independent_executables = false; diff --git a/src/librustc_back/target/mod.rs b/src/librustc_back/target/mod.rs index c15e18168e5..66a405ef54e 100644 --- a/src/librustc_back/target/mod.rs +++ b/src/librustc_back/target/mod.rs @@ -158,6 +158,9 @@ pub struct TargetOptions { /// only realy used for figuring out how to find libraries, since Windows uses its own /// library naming convention. Defaults to false. pub is_like_windows: bool, + /// Whether the target toolchain is like Android's. Only useful for compiling against Android. + /// Defaults to false. + pub is_like_android: bool, /// Whether the linker support GNU-like arguments such as -O. Defaults to false. pub linker_is_gnu: bool, /// Whether the linker support rpaths or not. Defaults to false. @@ -197,6 +200,7 @@ impl Default for TargetOptions { staticlib_suffix: ".a".to_string(), is_like_osx: false, is_like_windows: false, + is_like_android: false, linker_is_gnu: false, has_rpath: false, no_compiler_rt: false, diff --git a/src/librustc_trans/trans/debuginfo.rs b/src/librustc_trans/trans/debuginfo.rs index c10ff753936..23498089c58 100644 --- a/src/librustc_trans/trans/debuginfo.rs +++ b/src/librustc_trans/trans/debuginfo.rs @@ -736,7 +736,9 @@ pub fn finalize(cx: &CrateContext) { // instruct LLVM to emit an older version of dwarf, however, // for OS X to understand. For more info see #11352 // This can be overridden using --llvm-opts -dwarf-version,N. - if cx.sess().target.target.options.is_like_osx { + // Android has the same issue (#22398) + if cx.sess().target.target.options.is_like_osx || + cx.sess().target.target.options.is_like_android { llvm::LLVMRustAddModuleFlag(cx.llmod(), "Dwarf Version\0".as_ptr() as *const _, 2)