iOS: updated targets
- target_word_size -> target_pointer_width - added armv7 and armv7s targets - enabled building binaries so tests could be run on a jailbroken device
This commit is contained in:
parent
5b3cd3900c
commit
1fb91dc1c2
6 changed files with 152 additions and 42 deletions
88
src/librustc_back/target/apple_ios_base.rs
Normal file
88
src/librustc_back/target/apple_ios_base.rs
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::io::{Command, IoError, OtherIoError};
|
||||
use target::TargetOptions;
|
||||
|
||||
use self::Arch::*;
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
pub enum Arch {
|
||||
Armv7,
|
||||
Armv7s,
|
||||
Arm64,
|
||||
I386,
|
||||
X86_64
|
||||
}
|
||||
|
||||
impl Arch {
|
||||
pub fn to_string(&self) -> &'static str {
|
||||
match self {
|
||||
&Armv7 => "armv7",
|
||||
&Armv7s => "armv7s",
|
||||
&Arm64 => "arm64",
|
||||
&I386 => "i386",
|
||||
&X86_64 => "x86_64"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_sdk_root(sdk_name: &str) -> String {
|
||||
let res = Command::new("xcrun")
|
||||
.arg("--show-sdk-path")
|
||||
.arg("-sdk")
|
||||
.arg(sdk_name)
|
||||
.spawn()
|
||||
.and_then(|c| c.wait_with_output())
|
||||
.and_then(|output| {
|
||||
if output.status.success() {
|
||||
Ok(String::from_utf8(output.output).unwrap())
|
||||
} else {
|
||||
Err(IoError {
|
||||
kind: OtherIoError,
|
||||
desc: "process exit with error",
|
||||
detail: String::from_utf8(output.error).ok()})
|
||||
}
|
||||
});
|
||||
|
||||
match res {
|
||||
Ok(output) => output.trim().to_string(),
|
||||
Err(e) => panic!("failed to get {} SDK path: {}", sdk_name, e)
|
||||
}
|
||||
}
|
||||
|
||||
fn pre_link_args(arch: Arch) -> Vec<String> {
|
||||
let sdk_name = match arch {
|
||||
Armv7 | Armv7s | Arm64 => "iphoneos",
|
||||
I386 | X86_64 => "iphonesimulator"
|
||||
};
|
||||
|
||||
let arch_name = arch.to_string();
|
||||
|
||||
vec!["-arch".to_string(), arch_name.to_string(),
|
||||
"-Wl,-syslibroot".to_string(), get_sdk_root(sdk_name)]
|
||||
}
|
||||
|
||||
pub fn opts(arch: Arch) -> TargetOptions {
|
||||
TargetOptions {
|
||||
dynamic_linking: false,
|
||||
executables: true,
|
||||
// Although there is an experimental implementation of LLVM which
|
||||
// supports SS on armv7 it wasn't approved by Apple, see:
|
||||
// http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140505/216350.html
|
||||
// It looks like it might be never accepted to upstream LLVM.
|
||||
//
|
||||
// SS might be also enabled on Arm64 as it has builtin support in LLVM
|
||||
// but I haven't tested it through yet
|
||||
morestack: false,
|
||||
pre_link_args: pre_link_args(arch),
|
||||
.. super::apple_base::opts()
|
||||
}
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use target::{Target, TargetOptions};
|
||||
|
||||
pub fn target() -> Target {
|
||||
Target {
|
||||
data_layout: "e-p:32:32:32\
|
||||
-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
|
||||
-f32:32:32-f64:64:64\
|
||||
-v64:64:64-v128:64:128\
|
||||
-a:0:64-n32".to_string(),
|
||||
llvm_target: "arm-apple-ios".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
arch: "arm".to_string(),
|
||||
target_os: "ios".to_string(),
|
||||
options: TargetOptions {
|
||||
features: "+v7,+thumb2,+vfp3,+neon".to_string(),
|
||||
executables: false,
|
||||
dynamic_linking: false,
|
||||
// Although there is an experimental implementation of LLVM which
|
||||
// supports SS on armv7 it wasn't approved by Apple, see:
|
||||
// http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140505/216350.html
|
||||
// It looks like it might be never accepted to upstream LLVM.
|
||||
morestack: false,
|
||||
.. super::apple_base::opts()
|
||||
}
|
||||
}
|
||||
}
|
||||
27
src/librustc_back/target/armv7_apple_ios.rs
Normal file
27
src/librustc_back/target/armv7_apple_ios.rs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use target::{Target, TargetOptions};
|
||||
use super::apple_ios_base::{opts, Arch};
|
||||
|
||||
pub fn target() -> Target {
|
||||
Target {
|
||||
data_layout: "e-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32".to_string(),
|
||||
llvm_target: "armv7-apple-ios".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
arch: "arm".to_string(),
|
||||
target_os: "ios".to_string(),
|
||||
options: TargetOptions {
|
||||
features: "+v7,+vfp3,+neon".to_string(),
|
||||
.. opts(Arch::Armv7)
|
||||
}
|
||||
}
|
||||
}
|
||||
27
src/librustc_back/target/armv7s_apple_ios.rs
Normal file
27
src/librustc_back/target/armv7s_apple_ios.rs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use target::{Target, TargetOptions};
|
||||
use super::apple_ios_base::{opts, Arch};
|
||||
|
||||
pub fn target() -> Target {
|
||||
Target {
|
||||
data_layout: "e-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32".to_string(),
|
||||
llvm_target: "armv7s-apple-ios".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "32".to_string(),
|
||||
arch: "arm".to_string(),
|
||||
target_os: "ios".to_string(),
|
||||
options: TargetOptions {
|
||||
features: "+v7,+vfp4,+neon".to_string(),
|
||||
.. opts(Arch::Armv7s)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
use target::Target;
|
||||
use super::apple_ios_base::{opts, Arch};
|
||||
|
||||
pub fn target() -> Target {
|
||||
Target {
|
||||
|
|
@ -22,7 +23,6 @@ pub fn target() -> Target {
|
|||
target_pointer_width: "32".to_string(),
|
||||
arch: "x86".to_string(),
|
||||
target_os: "ios".to_string(),
|
||||
|
||||
options: super::apple_base::opts()
|
||||
options: opts(Arch::I386)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,16 +53,19 @@ use std::io::fs::PathExtensions;
|
|||
mod windows_base;
|
||||
mod linux_base;
|
||||
mod apple_base;
|
||||
mod apple_ios_base;
|
||||
mod freebsd_base;
|
||||
mod dragonfly_base;
|
||||
|
||||
mod arm_apple_ios;
|
||||
mod armv7_apple_ios;
|
||||
mod armv7s_apple_ios;
|
||||
mod i386_apple_ios;
|
||||
|
||||
mod arm_linux_androideabi;
|
||||
mod arm_unknown_linux_gnueabi;
|
||||
mod arm_unknown_linux_gnueabihf;
|
||||
mod aarch64_unknown_linux_gnu;
|
||||
mod i686_apple_darwin;
|
||||
mod i386_apple_ios;
|
||||
mod i686_pc_windows_gnu;
|
||||
mod i686_unknown_dragonfly;
|
||||
mod i686_unknown_linux_gnu;
|
||||
|
|
@ -346,8 +349,10 @@ impl Target {
|
|||
|
||||
x86_64_apple_darwin,
|
||||
i686_apple_darwin,
|
||||
|
||||
i386_apple_ios,
|
||||
arm_apple_ios,
|
||||
armv7_apple_ios,
|
||||
armv7s_apple_ios,
|
||||
|
||||
x86_64_pc_windows_gnu,
|
||||
i686_pc_windows_gnu
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue