Skip to content

Commit 7e2b093

Browse files
committed
DRY Android targets
1 parent 551a74d commit 7e2b093

File tree

4 files changed

+32
-20
lines changed

4 files changed

+32
-20
lines changed

src/librustc_back/target/aarch64_linux_android.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
use target::Target;
1212

1313
pub fn target() -> Target {
14-
let mut base = super::linux_base::opts();
15-
base.pre_link_args.push("-Wl,--allow-multiple-definition".to_string());
16-
base.is_like_android = true;
17-
base.position_independent_executables = true;
1814
Target {
1915
data_layout: "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
2016
f32:32:32-f64:64:64-v64:64:64-v128:128:128-a:0:64-\
@@ -25,6 +21,6 @@ pub fn target() -> Target {
2521
arch: "aarch64".to_string(),
2622
target_os: "android".to_string(),
2723
target_env: "".to_string(),
28-
options: base,
24+
options: super::android_base::opts(),
2925
}
3026
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use target::TargetOptions;
12+
13+
pub fn opts() -> TargetOptions {
14+
let mut base = super::linux_base::opts();
15+
// Many of the symbols defined in compiler-rt are also defined in libgcc.
16+
// Android's linker doesn't like that by default.
17+
base.pre_link_args.push("-Wl,--allow-multiple-definition".to_string());
18+
base.is_like_android = true;
19+
base.position_independent_executables = true;
20+
base
21+
}

src/librustc_back/target/arm_linux_androideabi.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,15 @@
1111
use target::Target;
1212

1313
pub fn target() -> Target {
14-
let mut base = super::linux_base::opts();
14+
let mut base = super::android_base::opts();
1515
base.features = "+v7".to_string();
16-
// Many of the symbols defined in compiler-rt are also defined in libgcc. Android
17-
// linker doesn't like that by default.
18-
base.pre_link_args.push("-Wl,--allow-multiple-definition".to_string());
19-
base.is_like_android = true;
2016
// FIXME #17437 (and #17448): Android doesn't support position dependent executables anymore.
2117
base.position_independent_executables = false;
2218

2319
Target {
24-
data_layout: "e-p:32:32:32\
25-
-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
26-
-f32:32:32-f64:64:64\
27-
-v64:64:64-v128:64:128\
28-
-a:0:64-n32".to_string(),
20+
data_layout: "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
21+
f32:32:32-f64:64:64-v64:64:64-v128:64:128-a:0:64-\
22+
n32".to_string(),
2923
llvm_target: "arm-linux-androideabi".to_string(),
3024
target_endian: "little".to_string(),
3125
target_pointer_width: "32".to_string(),

src/librustc_back/target/mod.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,19 @@
4646
//! specified by the target, rather than replace.
4747
4848
use serialize::json::Json;
49-
use syntax::{diagnostic, abi};
5049
use std::default::Default;
5150
use std::io::prelude::*;
51+
use syntax::{diagnostic, abi};
5252

53-
mod windows_base;
54-
mod linux_base;
53+
mod android_base;
5554
mod apple_base;
5655
mod apple_ios_base;
57-
mod freebsd_base;
58-
mod dragonfly_base;
5956
mod bitrig_base;
57+
mod dragonfly_base;
58+
mod freebsd_base;
59+
mod linux_base;
6060
mod openbsd_base;
61+
mod windows_base;
6162

6263
/// Everything `rustc` knows about how to compile for a specific target.
6364
///

0 commit comments

Comments
 (0)