Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 87ed884

Browse files
committedJan 9, 2015
Merge pull request #20699 from vhbit/ios-archs
Better iOS support Reviewed-by: alexcrichton
2 parents 2e2372c + 577d0db commit 87ed884

25 files changed

+746
-130
lines changed
 

‎mk/cfg/aarch64-apple-ios.mk

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# aarch64-apple-ios configuration
2+
CFG_SDK_NAME_aarch64-apple-ios := iphoneos
3+
CFG_SDK_ARCHS_aarch64-apple-ios := arm64
4+
ifneq ($(findstring darwin,$(CFG_OSTYPE)),)
5+
CFG_IOS_SDK_aarch64-apple-ios := $(shell xcrun --show-sdk-path -sdk iphoneos 2>/dev/null)
6+
CFG_IOS_SDK_FLAGS_aarch64-apple-ios := -target aarch64-apple-darwin -isysroot $(CFG_IOS_SDK_aarch64-apple-ios) -mios-version-min=7.0 -arch arm64
7+
CC_aarch64-apple-ios = $(shell xcrun -find -sdk iphoneos clang)
8+
CXX_aarch64-apple-ios = $(shell xcrun -find -sdk iphoneos clang++)
9+
CPP_aarch64-apple-ios = $(shell xcrun -find -sdk iphoneos clang++)
10+
AR_aarch64-apple-ios = $(shell xcrun -find -sdk iphoneos ar)
11+
endif
12+
CFG_LIB_NAME_aarch64-apple-ios = lib$(1).a
13+
CFG_LIB_GLOB_aarch64-apple-ios = lib$(1)-*.a
14+
CFG_LIB_SKIP_INSTALL_aarch64-apple-ios = 1 #lib$(1)-*.a
15+
CFG_STATIC_LIB_NAME_aarch64-apple-ios=lib$(1).a
16+
CFG_LIB_DSYM_GLOB_aarch64-apple-ios = lib$(1)-*.a.dSYM
17+
CFG_CFLAGS_aarch64-apple-ios := $(CFG_IOS_SDK_FLAGS_aarch64-apple-ios)
18+
CFG_JEMALLOC_CFLAGS_aarch64-apple-ios := $(CFG_IOS_SDK_FLAGS_aarch64-apple-ios)
19+
CFG_GCCISH_CFLAGS_aarch64-apple-ios := -Wall -Werror -fPIC $(CFG_IOS_SDK_FLAGS_aarch64-apple-ios)
20+
CFG_GCCISH_CXXFLAGS_aarch64-apple-ios := -fno-rtti $(CFG_IOS_SDK_FLAGS_aarch64-apple-ios) -I$(CFG_IOS_SDK_aarch64-apple-ios)/usr/include/c++/4.2.1
21+
CFG_GCCISH_LINK_FLAGS_aarch64-apple-ios := -lpthread -syslibroot $(CFG_IOS_SDK_aarch64-apple-ios) -Wl,-no_compact_unwind
22+
CFG_GCCISH_DEF_FLAG_aarch64-apple-ios := -Wl,-exported_symbols_list,
23+
CFG_GCCISH_PRE_LIB_FLAGS_aarch64-apple-ios :=
24+
CFG_GCCISH_POST_LIB_FLAGS_aarch64-apple-ios :=
25+
CFG_DEF_SUFFIX_aarch64-apple-ios := .darwin.def
26+
CFG_LLC_FLAGS_aarch64-apple-ios := -mattr=+neon,+cyclone,+fp-armv8
27+
CFG_INSTALL_NAME_aarch64-apple-ios = -Wl,-install_name,@rpath/$(1)
28+
CFG_LIBUV_LINK_FLAGS_aarch64-apple-ios =
29+
CFG_EXE_SUFFIX_aarch64-apple-ios :=
30+
CFG_WINDOWSY_aarch64-apple-ios :=
31+
CFG_UNIXY_aarch64-apple-ios := 1
32+
CFG_PATH_MUNGE_aarch64-apple-ios := true
33+
CFG_LDPATH_aarch64-apple-ios :=
34+
CFG_RUN_aarch64-apple-ios = $(2)
35+
CFG_RUN_TARG_aarch64-apple-ios = $(call CFG_RUN_aarch64-apple-ios,,$(2))
36+
CFG_GNU_TRIPLE_aarch64-apple-ios := aarch64-apple-ios

‎mk/cfg/arm-apple-ios.mk

-35
This file was deleted.

‎mk/cfg/armv7-apple-ios.mk

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# armv7-apple-ios configuration
2+
CFG_SDK_NAME_armv7-apple-ios := iphoneos
3+
CFG_SDK_ARCHS_armv7-apple-ios := armv7
4+
ifneq ($(findstring darwin,$(CFG_OSTYPE)),)
5+
CFG_IOS_SDK_armv7-apple-ios := $(shell xcrun --show-sdk-path -sdk iphoneos 2>/dev/null)
6+
CFG_IOS_SDK_FLAGS_armv7-apple-ios := -target armv7-apple-ios -isysroot $(CFG_IOS_SDK_armv7-apple-ios) -mios-version-min=7.0
7+
CC_armv7-apple-ios = $(shell xcrun -find -sdk iphoneos clang)
8+
CXX_armv7-apple-ios = $(shell xcrun -find -sdk iphoneos clang++)
9+
CPP_armv7-apple-ios = $(shell xcrun -find -sdk iphoneos clang++)
10+
AR_armv7-apple-ios = $(shell xcrun -find -sdk iphoneos ar)
11+
endif
12+
CFG_LIB_NAME_armv7-apple-ios = lib$(1).a
13+
CFG_LIB_GLOB_armv7-apple-ios = lib$(1)-*.a
14+
CFG_LIB_SKIP_INSTALL_armv7-apple-ios = 1 #lib$(1)-*.a
15+
CFG_STATIC_LIB_NAME_armv7-apple-ios=lib$(1).a
16+
CFG_LIB_DSYM_GLOB_armv7-apple-ios = lib$(1)-*.a.dSYM
17+
CFG_JEMALLOC_CFLAGS_armv7-apple-ios := -arch armv7 -mfpu=vfp3 $(CFG_IOS_SDK_FLAGS_armv7-apple-ios)
18+
CFG_GCCISH_CFLAGS_armv7-apple-ios := -Wall -Werror -g -fPIC $(CFG_IOS_SDK_FLAGS_armv7-apple-ios) -mfpu=vfp3 -arch armv7
19+
CFG_GCCISH_CXXFLAGS_armv7-apple-ios := -fno-rtti $(CFG_IOS_SDK_FLAGS_armv7-apple-ios) -I$(CFG_IOS_SDK_armv7-apple-ios)/usr/include/c++/4.2.1
20+
CFG_GCCISH_LINK_FLAGS_armv7-apple-ios := -lpthread -syslibroot $(CFG_IOS_SDK_armv7-apple-ios) -Wl,-no_compact_unwind
21+
CFG_GCCISH_DEF_FLAG_armv7-apple-ios := -Wl,-exported_symbols_list,
22+
CFG_GCCISH_PRE_LIB_FLAGS_armv7-apple-ios :=
23+
CFG_GCCISH_POST_LIB_FLAGS_armv7-apple-ios :=
24+
CFG_DEF_SUFFIX_armv7-apple-ios := .darwin.def
25+
CFG_LLC_FLAGS_armv7-apple-ios := -mattr=+vfp3,+v7,+neon -march=arm
26+
CFG_INSTALL_NAME_armv7-apple-ios = -Wl,-install_name,@rpath/$(1)
27+
CFG_EXE_SUFFIX_armv7-apple-ios :=
28+
CFG_WINDOWSY_armv7-apple-ios :=
29+
CFG_UNIXY_armv7-apple-ios := 1
30+
CFG_PATH_MUNGE_armv7-apple-ios := true
31+
CFG_LDPATH_armv7-apple-ios :=
32+
CFG_RUN_armv7-apple-ios = $(2)
33+
CFG_RUN_TARG_armv7-apple-ios = $(call CFG_RUN_armv7-apple-ios,,$(2))
34+
CFG_GNU_TRIPLE_armv7-apple-ios := armv7-apple-ios

‎mk/cfg/armv7s-apple-ios.mk

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# armv7s-apple-ios configuration
2+
CFG_SDK_NAME_armv7s-apple-ios := iphoneos
3+
CFG_SDK_ARCHS_armv7s-apple-ios := armv7s
4+
ifneq ($(findstring darwin,$(CFG_OSTYPE)),)
5+
CFG_IOS_SDK_armv7s-apple-ios := $(shell xcrun --show-sdk-path -sdk iphoneos 2>/dev/null)
6+
CFG_IOS_SDK_FLAGS_armv7s-apple-ios := -target armv7s-apple-ios -isysroot $(CFG_IOS_SDK_armv7s-apple-ios) -mios-version-min=7.0
7+
CC_armv7s-apple-ios = $(shell xcrun -find -sdk iphoneos clang)
8+
CXX_armv7s-apple-ios = $(shell xcrun -find -sdk iphoneos clang++)
9+
CPP_armv7s-apple-ios = $(shell xcrun -find -sdk iphoneos clang++)
10+
AR_armv7s-apple-ios = $(shell xcrun -find -sdk iphoneos ar)
11+
endif
12+
CFG_LIB_NAME_armv7s-apple-ios = lib$(1).a
13+
CFG_LIB_GLOB_armv7s-apple-ios = lib$(1)-*.a
14+
CFG_LIB_SKIP_INSTALL_armv7s-apple-ios = 1 #lib$(1)-*.a
15+
CFG_STATIC_LIB_NAME_armv7s-apple-ios=lib$(1).a
16+
CFG_LIB_DSYM_GLOB_armv7s-apple-ios = lib$(1)-*.a.dSYM
17+
CFG_JEMALLOC_CFLAGS_armv7s-apple-ios := -arch armv7s -mfpu=vfp4 $(CFG_IOS_SDK_FLAGS_armv7s-apple-ios)
18+
CFG_GCCISH_CFLAGS_armv7s-apple-ios := -Wall -Werror -g -fPIC $(CFG_IOS_SDK_FLAGS_armv7s-apple-ios) -mfpu=vfp4 -arch armv7s
19+
CFG_GCCISH_CXXFLAGS_armv7s-apple-ios := -fno-rtti $(CFG_IOS_SDK_FLAGS_armv7s-apple-ios) -I$(CFG_IOS_SDK_armv7s-apple-ios)/usr/include/c++/4.2.1
20+
CFG_GCCISH_LINK_FLAGS_armv7s-apple-ios := -lpthread -syslibroot $(CFG_IOS_SDK_armv7s-apple-ios) -Wl,-no_compact_unwind
21+
CFG_GCCISH_DEF_FLAG_armv7s-apple-ios := -Wl,-exported_symbols_list,
22+
CFG_GCCISH_PRE_LIB_FLAGS_armv7s-apple-ios :=
23+
CFG_GCCISH_POST_LIB_FLAGS_armv7s-apple-ios :=
24+
CFG_DEF_SUFFIX_armv7s-apple-ios := .darwin.def
25+
CFG_LLC_FLAGS_armv7s-apple-ios := -mattr=+vfp4,+v7,+neon
26+
CFG_INSTALL_NAME_armv7s-apple-ios = -Wl,-install_name,@rpath/$(1)
27+
CFG_EXE_SUFFIX_armv7s-apple-ios :=
28+
CFG_WINDOWSY_armv7s-apple-ios :=
29+
CFG_UNIXY_armv7s-apple-ios := 1
30+
CFG_PATH_MUNGE_armv7s-apple-ios := true
31+
CFG_LDPATH_armv7s-apple-ios :=
32+
CFG_RUN_armv7s-apple-ios = $(2)
33+
CFG_RUN_TARG_armv7s-apple-ios = $(call CFG_RUN_armv7s-apple-ios,,$(2))
34+
CFG_GNU_TRIPLE_armv7s-apple-ios := armv7s-apple-ios

‎mk/cfg/i386-apple-ios.mk

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# i386-apple-ios configuration
2-
CFG_SDK_NAME_i386-apple-ios = iphonesimulator
3-
CFG_SDK_ARCHS_i386-apple-ios = i386
2+
CFG_SDK_NAME_i386-apple-ios := iphonesimulator
3+
CFG_SDK_ARCHS_i386-apple-ios := i386
44
ifneq ($(findstring darwin,$(CFG_OSTYPE)),)
5-
CFG_IOSSIM_SDK = $(shell xcrun --show-sdk-path -sdk iphonesimulator 2>/dev/null)
6-
CFG_IOSSIM_FLAGS = -target i386-apple-ios -isysroot $(CFG_IOSSIM_SDK) -mios-simulator-version-min=7.0
5+
CFG_IOSSIM_SDK_i386-apple-ios := $(shell xcrun --show-sdk-path -sdk iphonesimulator 2>/dev/null)
6+
CFG_IOSSIM_FLAGS_i386-apple-ios := -m32 -target i386-apple-ios -isysroot $(CFG_IOSSIM_SDK_i386-apple-ios) -mios-simulator-version-min=7.0
77
CC_i386-apple-ios = $(shell xcrun -find -sdk iphonesimulator clang)
88
CXX_i386-apple-ios = $(shell xcrun -find -sdk iphonesimulator clang++)
99
CPP_i386-apple-ios = $(shell xcrun -find -sdk iphonesimulator clang++)
@@ -13,21 +13,21 @@ CFG_LIB_NAME_i386-apple-ios = lib$(1).a
1313
CFG_LIB_GLOB_i386-apple-ios = lib$(1)-*.dylib
1414
CFG_STATIC_LIB_NAME_i386-apple-ios=lib$(1).a
1515
CFG_LIB_DSYM_GLOB_i386-apple-ios = lib$(1)-*.dylib.dSYM
16-
CFG_GCCISH_CFLAGS_i386-apple-ios = -Wall -Werror -g -fPIC -m32 $(CFG_IOSSIM_FLAGS)
17-
CFG_GCCISH_CXXFLAGS_i386-apple-ios = -fno-rtti $(CFG_IOSSIM_FLAGS) -I$(CFG_IOSSIM_SDK)/usr/include/c++/4.2.1
18-
CFG_GCCISH_LINK_FLAGS_i386-apple-ios = -lpthread -Wl,-no_compact_unwind -m32 -Wl,-syslibroot $(CFG_IOSSIM_SDK)
19-
CFG_GCCISH_DEF_FLAG_i386-apple-ios = -Wl,-exported_symbols_list,
20-
CFG_GCCISH_PRE_LIB_FLAGS_i386-apple-ios =
21-
CFG_GCCISH_POST_LIB_FLAGS_i386-apple-ios =
22-
CFG_DEF_SUFFIX_i386-apple-ios = .darwin.def
16+
CFG_GCCISH_CFLAGS_i386-apple-ios := -Wall -Werror -g -fPIC -m32 $(CFG_IOSSIM_FLAGS_i386-apple-ios)
17+
CFG_GCCISH_CXXFLAGS_i386-apple-ios := -fno-rtti $(CFG_IOSSIM_FLAGS_i386-apple-ios) -I$(CFG_IOSSIM_SDK_i386-apple-ios)/usr/include/c++/4.2.1
18+
CFG_GCCISH_LINK_FLAGS_i386-apple-ios := -lpthread -m32 -Wl,-no_compact_unwind -m32 -Wl,-syslibroot $(CFG_IOSSIM_SDK_i386-apple-ios)
19+
CFG_GCCISH_DEF_FLAG_i386-apple-ios := -Wl,-exported_symbols_list,
20+
CFG_GCCISH_PRE_LIB_FLAGS_i386-apple-ios :=
21+
CFG_GCCISH_POST_LIB_FLAGS_i386-apple-ios :=
22+
CFG_DEF_SUFFIX_i386-apple-ios := .darwin.def
2323
CFG_LLC_FLAGS_i386-apple-ios =
2424
CFG_INSTALL_NAME_i386-apple-ios = -Wl,-install_name,@rpath/$(1)
25-
CFG_EXE_SUFFIX_i386-apple-ios =
26-
CFG_WINDOWSY_i386-apple-ios =
27-
CFG_UNIXY_i386-apple-ios = 1
28-
CFG_PATH_MUNGE_i386-apple-ios = true
25+
CFG_EXE_SUFFIX_i386-apple-ios :=
26+
CFG_WINDOWSY_i386-apple-ios :=
27+
CFG_UNIXY_i386-apple-ios := 1
28+
CFG_PATH_MUNGE_i386-apple-ios = :true
2929
CFG_LDPATH_i386-apple-ios =
3030
CFG_RUN_i386-apple-ios = $(2)
3131
CFG_RUN_TARG_i386-apple-ios = $(call CFG_RUN_i386-apple-ios,,$(2))
32-
CFG_JEMALLOC_CFLAGS_i386-apple-ios = $(CFG_IOSSIM_FLAGS) -target i386-apple-ios -Wl,-syslibroot $(CFG_IOSSIM_SDK) -Wl,-no_compact_unwind
32+
CFG_JEMALLOC_CFLAGS_i386-apple-ios = $(CFG_IOSSIM_FLAGS_i386-apple-ios) -target i386-apple-ios #-Wl,-syslibroot $(CFG_IOSSIM_SDK_i386-apple-ios) -Wl,-no_compact_unwind
3333
CFG_GNU_TRIPLE_i386-apple-ios := i386-apple-ios

‎mk/cfg/x86_64-apple-ios.mk

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# x86_64-apple-ios configuration
2+
CFG_SDK_NAME_x86_64-apple-ios := iphonesimulator
3+
CFG_SDK_ARCHS_x86_64-apple-ios := x86_64
4+
ifneq ($(findstring darwin,$(CFG_OSTYPE)),)
5+
CFG_IOSSIM_SDK_x86_64-apple-ios := $(shell xcrun --show-sdk-path -sdk iphonesimulator 2>/dev/null)
6+
CFG_IOSSIM_FLAGS_x86_64-apple-ios := -m64 -target x86_64-apple-ios -isysroot $(CFG_IOSSIM_SDK_x86_64-apple-ios) -mios-simulator-version-min=7.0
7+
CC_x86_64-apple-ios = $(shell xcrun -find -sdk iphonesimulator clang)
8+
CXX_x86_64-apple-ios = $(shell xcrun -find -sdk iphonesimulator clang++)
9+
CPP_x86_64-apple-ios = $(shell xcrun -find -sdk iphonesimulator clang++)
10+
AR_x86_64-apple-ios = $(shell xcrun -find -sdk iphonesimulator ar)
11+
endif
12+
CFG_LIB_NAME_x86_64-apple-ios = lib$(1).a
13+
CFG_LIB_GLOB_x86_64-apple-ios = lib$(1)-*.a
14+
CFG_LIB_SKIP_INSTALL_x86_64-apple-ios = 1 #lib$(1)-*.a
15+
CFG_STATIC_LIB_NAME_x86_64-apple-ios=lib$(1).a
16+
CFG_LIB_DSYM_GLOB_x86_64-apple-ios = lib$(1)-*.a.dSYM
17+
CFG_CFLAGS_x86_64-apple-ios := $(CFG_IOSSIM_FLAGS_x86_64-apple-ios)
18+
CFG_JEMALLOC_CFLAGS_x86_64-apple-ios := $(CFG_IOSSIM_FLAGS_x86_64-apple-ios)
19+
CFG_GCCISH_CFLAGS_x86_64-apple-ios := -Wall -Werror -fPIC $(CFG_IOSSIM_FLAGS_x86_64-apple-ios)
20+
CFG_GCCISH_CXXFLAGS_x86_64-apple-ios := -fno-rtti $(CFG_IOSSIM_FLAGS_x86_64-apple-ios) -I$(CFG_IOSSIM_SDK_x86_64-apple-ios)/usr/include/c++/4.2.1
21+
CFG_GCCISH_LINK_FLAGS_x86_64-apple-ios := -lpthread -Wl,-no_compact_unwind -m64 -Wl,-syslibroot $(CFG_IOSSIM_SDK_x86_64-apple-ios)
22+
CFG_GCCISH_DEF_FLAG_x86_64-apple-ios := -Wl,-exported_symbols_list,
23+
CFG_GCCISH_PRE_LIB_FLAGS_x86_64-apple-ios :=
24+
CFG_GCCISH_POST_LIB_FLAGS_x86_64-apple-ios :=
25+
CFG_DEF_SUFFIX_x86_64-apple-ios := .darwin.def
26+
CFG_LLC_FLAGS_x86_64-apple-ios :=
27+
CFG_INSTALL_NAME_x86_64-apple-ios = -Wl,-install_name,@rpath/$(1)
28+
CFG_LIBUV_LINK_FLAGS_x86_64-apple-ios :=
29+
CFG_EXE_SUFFIX_x86_64-apple-ios :=
30+
CFG_WINDOWSY_x86_64-apple-ios :=
31+
CFG_UNIXY_x86_64-apple-ios := 1
32+
CFG_PATH_MUNGE_x86_64-apple-ios := true
33+
CFG_LDPATH_x86_64-apple-ios :=
34+
CFG_RUN_x86_64-apple-ios = $(2)
35+
CFG_RUN_TARG_x86_64-apple-ios = $(call CFG_RUN_x86_64-apple-ios,,$(2))
36+
CFG_GNU_TRIPLE_i386-apple-ios := x86_64-apple-ios

‎src/liblibc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1969,7 +1969,7 @@ pub mod types {
19691969
}
19701970
}
19711971

1972-
#[cfg(target_arch = "x86_64")]
1972+
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
19731973
pub mod arch {
19741974
pub mod c95 {
19751975
pub type c_char = i8;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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::{Target, TargetOptions};
12+
use super::apple_ios_base::{opts, Arch};
13+
14+
pub fn target() -> Target {
15+
Target {
16+
// reference layout: e-m:o-i64:64-i128:128-n32:64-S128
17+
data_layout: "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
18+
i128:128-f32:32:32-f64:64:64-v64:64:64-v128:128:128-\
19+
a:0:64-n32:64-S128".to_string(),
20+
llvm_target: "arm64-apple-ios".to_string(),
21+
target_endian: "little".to_string(),
22+
target_pointer_width: "64".to_string(),
23+
arch: "aarch64".to_string(),
24+
target_os: "ios".to_string(),
25+
options: TargetOptions {
26+
features: "+neon,+fp-armv8,+cyclone".to_string(),
27+
eliminate_frame_pointer: false,
28+
.. opts(Arch::Arm64)
29+
},
30+
}
31+
}
+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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 std::io::{Command, IoError, OtherIoError};
12+
use target::TargetOptions;
13+
14+
use self::Arch::*;
15+
16+
#[allow(non_camel_case_types)]
17+
pub enum Arch {
18+
Armv7,
19+
Armv7s,
20+
Arm64,
21+
I386,
22+
X86_64
23+
}
24+
25+
impl Arch {
26+
pub fn to_string(&self) -> &'static str {
27+
match self {
28+
&Armv7 => "armv7",
29+
&Armv7s => "armv7s",
30+
&Arm64 => "arm64",
31+
&I386 => "i386",
32+
&X86_64 => "x86_64"
33+
}
34+
}
35+
}
36+
37+
pub fn get_sdk_root(sdk_name: &str) -> String {
38+
let res = Command::new("xcrun")
39+
.arg("--show-sdk-path")
40+
.arg("-sdk")
41+
.arg(sdk_name)
42+
.spawn()
43+
.and_then(|c| c.wait_with_output())
44+
.and_then(|output| {
45+
if output.status.success() {
46+
Ok(String::from_utf8(output.output).unwrap())
47+
} else {
48+
Err(IoError {
49+
kind: OtherIoError,
50+
desc: "process exit with error",
51+
detail: String::from_utf8(output.error).ok()})
52+
}
53+
});
54+
55+
match res {
56+
Ok(output) => output.trim().to_string(),
57+
Err(e) => panic!("failed to get {} SDK path: {}", sdk_name, e)
58+
}
59+
}
60+
61+
fn pre_link_args(arch: Arch) -> Vec<String> {
62+
let sdk_name = match arch {
63+
Armv7 | Armv7s | Arm64 => "iphoneos",
64+
I386 | X86_64 => "iphonesimulator"
65+
};
66+
67+
let arch_name = arch.to_string();
68+
69+
vec!["-arch".to_string(), arch_name.to_string(),
70+
"-Wl,-syslibroot".to_string(), get_sdk_root(sdk_name)]
71+
}
72+
73+
pub fn opts(arch: Arch) -> TargetOptions {
74+
TargetOptions {
75+
dynamic_linking: false,
76+
executables: true,
77+
// Although there is an experimental implementation of LLVM which
78+
// supports SS on armv7 it wasn't approved by Apple, see:
79+
// http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140505/216350.html
80+
// It looks like it might be never accepted to upstream LLVM.
81+
//
82+
// SS might be also enabled on Arm64 as it has builtin support in LLVM
83+
// but I haven't tested it through yet
84+
morestack: false,
85+
pre_link_args: pre_link_args(arch),
86+
.. super::apple_base::opts()
87+
}
88+
}

‎src/librustc_back/target/arm_apple_ios.rs

-37
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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::{Target, TargetOptions};
12+
use super::apple_ios_base::{opts, Arch};
13+
14+
pub fn target() -> Target {
15+
Target {
16+
data_layout: "e-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32".to_string(),
17+
llvm_target: "armv7-apple-ios".to_string(),
18+
target_endian: "little".to_string(),
19+
target_pointer_width: "32".to_string(),
20+
arch: "arm".to_string(),
21+
target_os: "ios".to_string(),
22+
options: TargetOptions {
23+
features: "+v7,+vfp3,+neon".to_string(),
24+
.. opts(Arch::Armv7)
25+
}
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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::{Target, TargetOptions};
12+
use super::apple_ios_base::{opts, Arch};
13+
14+
pub fn target() -> Target {
15+
Target {
16+
data_layout: "e-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32".to_string(),
17+
llvm_target: "armv7s-apple-ios".to_string(),
18+
target_endian: "little".to_string(),
19+
target_pointer_width: "32".to_string(),
20+
arch: "arm".to_string(),
21+
target_os: "ios".to_string(),
22+
options: TargetOptions {
23+
features: "+v7,+vfp4,+neon".to_string(),
24+
.. opts(Arch::Armv7s)
25+
}
26+
}
27+
}

‎src/librustc_back/target/i386_apple_ios.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
use target::Target;
12+
use super::apple_ios_base::{opts, Arch};
1213

1314
pub fn target() -> Target {
1415
Target {
@@ -22,7 +23,6 @@ pub fn target() -> Target {
2223
target_pointer_width: "32".to_string(),
2324
arch: "x86".to_string(),
2425
target_os: "ios".to_string(),
25-
26-
options: super::apple_base::opts()
26+
options: opts(Arch::I386)
2727
}
2828
}

‎src/librustc_back/target/mod.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,27 @@ use std::io::fs::PathExtensions;
5353
mod windows_base;
5454
mod linux_base;
5555
mod apple_base;
56+
mod apple_ios_base;
5657
mod freebsd_base;
5758
mod dragonfly_base;
5859

59-
mod arm_apple_ios;
60+
mod armv7_apple_ios;
61+
mod armv7s_apple_ios;
62+
mod i386_apple_ios;
63+
6064
mod arm_linux_androideabi;
6165
mod arm_unknown_linux_gnueabi;
6266
mod arm_unknown_linux_gnueabihf;
67+
mod aarch64_apple_ios;
6368
mod aarch64_unknown_linux_gnu;
6469
mod i686_apple_darwin;
65-
mod i386_apple_ios;
6670
mod i686_pc_windows_gnu;
6771
mod i686_unknown_dragonfly;
6872
mod i686_unknown_linux_gnu;
6973
mod mips_unknown_linux_gnu;
7074
mod mipsel_unknown_linux_gnu;
7175
mod x86_64_apple_darwin;
76+
mod x86_64_apple_ios;
7277
mod x86_64_pc_windows_gnu;
7378
mod x86_64_unknown_freebsd;
7479
mod x86_64_unknown_dragonfly;
@@ -346,8 +351,12 @@ impl Target {
346351

347352
x86_64_apple_darwin,
348353
i686_apple_darwin,
354+
349355
i386_apple_ios,
350-
arm_apple_ios,
356+
x86_64_apple_ios,
357+
aarch64_apple_ios,
358+
armv7_apple_ios,
359+
armv7s_apple_ios,
351360

352361
x86_64_pc_windows_gnu,
353362
i686_pc_windows_gnu
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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::Target;
12+
use super::apple_ios_base::{opts, Arch};
13+
14+
pub fn target() -> Target {
15+
Target {
16+
data_layout: "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
17+
f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-\
18+
s0:64:64-f80:128:128-n8:16:32:64".to_string(),
19+
llvm_target: "x86_64-apple-ios".to_string(),
20+
target_endian: "little".to_string(),
21+
target_pointer_width: "64".to_string(),
22+
arch: "x86_64".to_string(),
23+
target_os: "ios".to_string(),
24+
options: opts(Arch::X86_64)
25+
}
26+
}

‎src/librustc_trans/trans/cabi.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,15 @@ pub fn compute_abi_info(ccx: &CrateContext,
115115
} else {
116116
cabi_x86_64::compute_abi_info(ccx, atys, rty, ret_def)
117117
},
118-
"arm" => cabi_arm::compute_abi_info(ccx, atys, rty, ret_def),
119118
"aarch64" => cabi_aarch64::compute_abi_info(ccx, atys, rty, ret_def),
119+
"arm" => {
120+
let flavor = if ccx.sess().target.target.target_os == "ios" {
121+
cabi_arm::Flavor::Ios
122+
} else {
123+
cabi_arm::Flavor::General
124+
};
125+
cabi_arm::compute_abi_info(ccx, atys, rty, ret_def, flavor)
126+
},
120127
"mips" => cabi_mips::compute_abi_info(ccx, atys, rty, ret_def),
121128
a => ccx.sess().fatal(&format!("unrecognized arch \"{}\" in target specification", a)
122129
[]),

‎src/librustc_trans/trans/cabi_arm.rs

+67-18
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,23 @@ use trans::type_::Type;
1919

2020
use std::cmp;
2121

22+
pub enum Flavor {
23+
General,
24+
Ios
25+
}
26+
27+
type TyAlignFn = fn(ty: Type) -> uint;
28+
2229
fn align_up_to(off: uint, a: uint) -> uint {
2330
return (off + a - 1u) / a * a;
2431
}
2532

26-
fn align(off: uint, ty: Type) -> uint {
27-
let a = ty_align(ty);
33+
fn align(off: uint, ty: Type, align_fn: TyAlignFn) -> uint {
34+
let a = align_fn(ty);
2835
return align_up_to(off, a);
2936
}
3037

31-
fn ty_align(ty: Type) -> uint {
38+
fn general_ty_align(ty: Type) -> uint {
3239
match ty.kind() {
3340
Integer => {
3441
unsafe {
@@ -43,18 +50,51 @@ fn ty_align(ty: Type) -> uint {
4350
1
4451
} else {
4552
let str_tys = ty.field_types();
46-
str_tys.iter().fold(1, |a, t| cmp::max(a, ty_align(*t)))
53+
str_tys.iter().fold(1, |a, t| cmp::max(a, general_ty_align(*t)))
54+
}
55+
}
56+
Array => {
57+
let elt = ty.element_type();
58+
general_ty_align(elt)
59+
}
60+
_ => panic!("ty_align: unhandled type")
61+
}
62+
}
63+
64+
// For more information see:
65+
// ARMv7
66+
// https://developer.apple.com/library/ios/documentation/Xcode/Conceptual
67+
// /iPhoneOSABIReference/Articles/ARMv7FunctionCallingConventions.html
68+
// ARMv6
69+
// https://developer.apple.com/library/ios/documentation/Xcode/Conceptual
70+
// /iPhoneOSABIReference/Articles/ARMv6FunctionCallingConventions.html
71+
fn ios_ty_align(ty: Type) -> uint {
72+
match ty.kind() {
73+
Integer => {
74+
unsafe {
75+
cmp::min(4, ((llvm::LLVMGetIntTypeWidth(ty.to_ref()) as uint) + 7) / 8)
76+
}
77+
}
78+
Pointer => 4,
79+
Float => 4,
80+
Double => 4,
81+
Struct => {
82+
if ty.is_packed() {
83+
1
84+
} else {
85+
let str_tys = ty.field_types();
86+
str_tys.iter().fold(1, |a, t| cmp::max(a, ios_ty_align(*t)))
4787
}
4888
}
4989
Array => {
5090
let elt = ty.element_type();
51-
ty_align(elt)
91+
ios_ty_align(elt)
5292
}
5393
_ => panic!("ty_align: unhandled type")
5494
}
5595
}
5696

57-
fn ty_size(ty: Type) -> uint {
97+
fn ty_size(ty: Type, align_fn: TyAlignFn) -> uint {
5898
match ty.kind() {
5999
Integer => {
60100
unsafe {
@@ -67,29 +107,32 @@ fn ty_size(ty: Type) -> uint {
67107
Struct => {
68108
if ty.is_packed() {
69109
let str_tys = ty.field_types();
70-
str_tys.iter().fold(0, |s, t| s + ty_size(*t))
110+
str_tys.iter().fold(0, |s, t| s + ty_size(*t, align_fn))
71111
} else {
72112
let str_tys = ty.field_types();
73-
let size = str_tys.iter().fold(0, |s, t| align(s, *t) + ty_size(*t));
74-
align(size, ty)
113+
let size = str_tys.iter()
114+
.fold(0, |s, t| {
115+
align(s, *t, align_fn) + ty_size(*t, align_fn)
116+
});
117+
align(size, ty, align_fn)
75118
}
76119
}
77120
Array => {
78121
let len = ty.array_length();
79122
let elt = ty.element_type();
80-
let eltsz = ty_size(elt);
123+
let eltsz = ty_size(elt, align_fn);
81124
len * eltsz
82125
}
83126
_ => panic!("ty_size: unhandled type")
84127
}
85128
}
86129

87-
fn classify_ret_ty(ccx: &CrateContext, ty: Type) -> ArgType {
130+
fn classify_ret_ty(ccx: &CrateContext, ty: Type, align_fn: TyAlignFn) -> ArgType {
88131
if is_reg_ty(ty) {
89132
let attr = if ty == Type::i1(ccx) { Some(ZExtAttribute) } else { None };
90133
return ArgType::direct(ty, None, None, attr);
91134
}
92-
let size = ty_size(ty);
135+
let size = ty_size(ty, align_fn);
93136
if size <= 4 {
94137
let llty = if size <= 1 {
95138
Type::i8(ccx)
@@ -103,13 +146,13 @@ fn classify_ret_ty(ccx: &CrateContext, ty: Type) -> ArgType {
103146
ArgType::indirect(ty, Some(StructRetAttribute))
104147
}
105148

106-
fn classify_arg_ty(ccx: &CrateContext, ty: Type) -> ArgType {
149+
fn classify_arg_ty(ccx: &CrateContext, ty: Type, align_fn: TyAlignFn) -> ArgType {
107150
if is_reg_ty(ty) {
108151
let attr = if ty == Type::i1(ccx) { Some(ZExtAttribute) } else { None };
109152
return ArgType::direct(ty, None, None, attr);
110153
}
111-
let align = ty_align(ty);
112-
let size = ty_size(ty);
154+
let align = align_fn(ty);
155+
let size = ty_size(ty, align_fn);
113156
let llty = if align <= 4 {
114157
Type::array(&Type::i32(ccx), ((size + 3) / 4) as u64)
115158
} else {
@@ -131,15 +174,21 @@ fn is_reg_ty(ty: Type) -> bool {
131174
pub fn compute_abi_info(ccx: &CrateContext,
132175
atys: &[Type],
133176
rty: Type,
134-
ret_def: bool) -> FnType {
177+
ret_def: bool,
178+
flavor: Flavor) -> FnType {
179+
let align_fn = match flavor {
180+
Flavor::General => general_ty_align as TyAlignFn,
181+
Flavor::Ios => ios_ty_align as TyAlignFn,
182+
};
183+
135184
let mut arg_tys = Vec::new();
136185
for &aty in atys.iter() {
137-
let ty = classify_arg_ty(ccx, aty);
186+
let ty = classify_arg_ty(ccx, aty, align_fn);
138187
arg_tys.push(ty);
139188
}
140189

141190
let ret_ty = if ret_def {
142-
classify_ret_ty(ccx, rty)
191+
classify_ret_ty(ccx, rty, align_fn)
143192
} else {
144193
ArgType::direct(Type::void(ccx), None, None, None)
145194
};

‎src/libstd/io/test.rs

+21-8
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,36 @@ pub fn next_test_port() -> u16 {
2323
base_port() + NEXT_OFFSET.fetch_add(1, Ordering::Relaxed) as u16
2424
}
2525

26-
/// Get a temporary path which could be the location of a unix socket
27-
pub fn next_test_unix() -> Path {
26+
// iOS has a pretty long tmpdir path which causes pipe creation
27+
// to like: invalid argument: path must be smaller than SUN_LEN
28+
fn next_test_unix_socket() -> String {
2829
static COUNT: AtomicUint = ATOMIC_UINT_INIT;
2930
// base port and pid are an attempt to be unique between multiple
3031
// test-runners of different configurations running on one
3132
// buildbot, the count is to be unique within this executable.
32-
let string = format!("rust-test-unix-path-{}-{}-{}",
33-
base_port(),
34-
unsafe {libc::getpid()},
35-
COUNT.fetch_add(1, Ordering::Relaxed));
33+
format!("rust-test-unix-path-{}-{}-{}",
34+
base_port(),
35+
unsafe {libc::getpid()},
36+
COUNT.fetch_add(1, Ordering::Relaxed))
37+
}
38+
39+
/// Get a temporary path which could be the location of a unix socket
40+
#[cfg(not(target_os = "ios"))]
41+
pub fn next_test_unix() -> Path {
42+
let string = next_test_unix_socket();
3643
if cfg!(unix) {
3744
os::tmpdir().join(string)
3845
} else {
3946
Path::new(format!("{}{}", r"\\.\pipe\", string))
4047
}
4148
}
4249

50+
/// Get a temporary path which could be the location of a unix socket
51+
#[cfg(target_os = "ios")]
52+
pub fn next_test_unix() -> Path {
53+
Path::new(format!("/var/tmp/{}", next_test_unix_socket()))
54+
}
55+
4356
/// Get a unique IPv4 localhost:port pair starting at 9600
4457
pub fn next_test_ip4() -> SocketAddr {
4558
SocketAddr { ip: Ipv4Addr(127, 0, 0, 1), port: next_test_port() }
@@ -99,7 +112,7 @@ pub fn raise_fd_limit() {
99112
/// multithreaded scheduler testing, depending on the number of cores available.
100113
///
101114
/// This fixes issue #7772.
102-
#[cfg(target_os="macos")]
115+
#[cfg(any(target_os = "macos", target_os = "ios"))]
103116
#[allow(non_camel_case_types)]
104117
mod darwin_fd_limit {
105118
use libc;
@@ -156,7 +169,7 @@ mod darwin_fd_limit {
156169
}
157170
}
158171

159-
#[cfg(not(target_os="macos"))]
172+
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
160173
mod darwin_fd_limit {
161174
pub unsafe fn raise_fd_limit() {}
162175
}

‎src/libstd/sys/unix/sync.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,22 @@ mod os {
6161
mod os {
6262
use libc;
6363

64-
#[cfg(target_arch = "x86_64")]
64+
#[cfg(any(target_arch = "x86_64",
65+
target_arch = "aarch64"))]
6566
const __PTHREAD_MUTEX_SIZE__: uint = 56;
6667
#[cfg(any(target_arch = "x86",
6768
target_arch = "arm"))]
6869
const __PTHREAD_MUTEX_SIZE__: uint = 40;
6970

70-
#[cfg(target_arch = "x86_64")]
71+
#[cfg(any(target_arch = "x86_64",
72+
target_arch = "aarch64"))]
7173
const __PTHREAD_COND_SIZE__: uint = 40;
7274
#[cfg(any(target_arch = "x86",
7375
target_arch = "arm"))]
7476
const __PTHREAD_COND_SIZE__: uint = 24;
7577

76-
#[cfg(target_arch = "x86_64")]
78+
#[cfg(any(target_arch = "x86_64",
79+
target_arch = "aarch64"))]
7780
const __PTHREAD_RWLOCK_SIZE__: uint = 192;
7881
#[cfg(any(target_arch = "x86",
7982
target_arch = "arm"))]

‎src/rt/arch/aarch64/morestack.S

+21-5
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,29 @@
77

88
/* See i386/morestack.S for the lengthy, general explanation. */
99

10-
.global rust_stack_exhausted
10+
#if defined(__APPLE__)
11+
#define MORESTACK ___morestack
12+
#define STACK_EXHAUSTED _rust_stack_exhausted
13+
#else
14+
#define MORESTACK __morestack
15+
#define STACK_EXHAUSTED rust_stack_exhausted
16+
#endif
17+
18+
.global STACK_EXHAUSTED
19+
20+
#if defined(__APPLE__)
21+
.private_extern MORESTACK
22+
#else
23+
.hidden MORESTACK
24+
#endif
25+
26+
#if !defined(__APPLE__)
27+
.type MORESTACK,%function
28+
#endif
1129

1230
// FIXME(AARCH64): this might not be perfectly right but works for now
13-
func __morestack
31+
MORESTACK:
1432
.cfi_startproc
15-
bl rust_stack_exhausted
33+
bl STACK_EXHAUSTED@plt
1634
// the above function ensures that it never returns
1735
.cfi_endproc
18-
endfunc __morestack
19-
.hidden __morestack

‎src/rt/arch/armv7/morestack.S

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Mark stack as non-executable
2+
#if defined(__linux__) && defined(__ELF__)
3+
.section .note.GNU-stack, "", %progbits
4+
#endif
5+
6+
/* See i386/morestack.S for the lengthy, general explanation. */
7+
8+
.text
9+
.code 32
10+
.arm
11+
#if defined(__APPLE__)
12+
.align 2
13+
#else
14+
.align
15+
#endif
16+
17+
#if defined(__APPLE__)
18+
#define MORESTACK ___morestack
19+
#define STACK_EXHAUSTED _rust_stack_exhausted
20+
#else
21+
#define MORESTACK __morestack
22+
#define STACK_EXHAUSTED rust_stack_exhausted
23+
#endif
24+
25+
.global STACK_EXHAUSTED
26+
.global MORESTACK
27+
28+
// Unfortunately LLVM yet doesn't support emitting correct debug
29+
// DWARF information for non-ELF targets so to make it compile
30+
// on iOS all that directives are simply commented out
31+
#if defined(__APPLE__)
32+
#define UNWIND @
33+
#else
34+
#define UNWIND
35+
#endif
36+
37+
#if defined(__APPLE__)
38+
.private_extern MORESTACK
39+
#else
40+
.hidden MORESTACK
41+
#endif
42+
43+
#if !defined(__APPLE__)
44+
.type MORESTACK,%function
45+
#endif
46+
47+
// r4 and r5 are scratch registers for __morestack due to llvm
48+
// ARMFrameLowering::adjustForSegmentedStacks() implementation.
49+
MORESTACK:
50+
UNWIND .fnstart
51+
52+
// Save frame pointer and return address
53+
UNWIND .save {r4, r5}
54+
UNWIND .save {lr}
55+
UNWIND .save {r6, fp, lr}
56+
push {r6, fp, lr}
57+
58+
UNWIND .movsp r6
59+
mov r6, sp
60+
UNWIND .setfp fp, sp, #4
61+
add fp, sp, #4
62+
63+
// Save argument registers of the original function
64+
push {r0, r1, r2, r3, lr}
65+
66+
// Create new stack
67+
bl STACK_EXHAUSTED@plt
68+
69+
// the above function ensures that it never returns
70+
UNWIND .fnend

‎src/rt/arch/armv7/record_sp.S

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Do not compile anything here for iOS because split stacks
2+
// are disabled at all and do not need any runtime support.
3+
//
4+
// See also comments in librustrt/stack.rs about why it was
5+
// disabled and how it could be implemented in case of need.
6+
#if !defined(__APPLE__)
7+
// Mark stack as non-executable
8+
#if defined(__linux__) && defined(__ELF__)
9+
.section .note.GNU-stack, "", %progbits
10+
#endif
11+
12+
.text
13+
.code 32
14+
.arm
15+
.align
16+
17+
#define RECORD_SP_LIMIT record_sp_limit
18+
#define GET_SP_LIMIT get_sp_limit
19+
20+
.globl RECORD_SP_LIMIT
21+
.globl GET_SP_LIMIT
22+
23+
RECORD_SP_LIMIT:
24+
// First, try to read TLS address from coprocessor
25+
mrc p15, #0, r3, c13, c0, #3
26+
cmp r3, #0
27+
// Otherwise, try to read from magic address 0xFFFF0FF0
28+
mvneq r3, #0xF000
29+
ldreq r3, [r3, #-15]
30+
31+
#if __ANDROID__
32+
add r3, r3, #252
33+
#elif __linux__
34+
add r3, r3, #4
35+
#endif // ANDROID
36+
37+
str r0, [r3]
38+
mov pc, lr
39+
40+
GET_SP_LIMIT:
41+
// First, try to read TLS address from coprocessor
42+
mrc p15, #0, r3, c13, c0, #3
43+
cmp r3, #0
44+
// Otherwise, try to read from magic address 0xFFFF0FF0
45+
mvneq r3, #0xF000
46+
ldreq r3, [r3, #-15]
47+
48+
#if __ANDROID__
49+
add r3, r3, #252
50+
#elif __linux__
51+
add r3, r3, #4
52+
#endif // __ANDROID__
53+
54+
ldr r0, [r3]
55+
mov pc, lr
56+
#endif

‎src/rt/arch/armv7s/morestack.S

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Mark stack as non-executable
2+
#if defined(__linux__) && defined(__ELF__)
3+
.section .note.GNU-stack, "", %progbits
4+
#endif
5+
6+
/* See i386/morestack.S for the lengthy, general explanation. */
7+
8+
.text
9+
.code 32
10+
.arm
11+
#if defined(__APPLE__)
12+
.align 2
13+
#else
14+
.align
15+
#endif
16+
17+
#if defined(__APPLE__)
18+
#define MORESTACK ___morestack
19+
#define STACK_EXHAUSTED _rust_stack_exhausted
20+
#else
21+
#define MORESTACK __morestack
22+
#define STACK_EXHAUSTED rust_stack_exhausted
23+
#endif
24+
25+
.global STACK_EXHAUSTED
26+
.global MORESTACK
27+
28+
// Unfortunately LLVM yet doesn't support emitting correct debug
29+
// DWARF information for non-ELF targets so to make it compile
30+
// on iOS all that directives are simply commented out
31+
#if defined(__APPLE__)
32+
#define UNWIND @
33+
#else
34+
#define UNWIND
35+
#endif
36+
37+
#if defined(__APPLE__)
38+
.private_extern MORESTACK
39+
#else
40+
.hidden MORESTACK
41+
#endif
42+
43+
#if !defined(__APPLE__)
44+
.type MORESTACK,%function
45+
#endif
46+
47+
// r4 and r5 are scratch registers for __morestack due to llvm
48+
// ARMFrameLowering::adjustForSegmentedStacks() implementation.
49+
MORESTACK:
50+
UNWIND .fnstart
51+
52+
// Save frame pointer and return address
53+
UNWIND .save {r4, r5}
54+
UNWIND .save {lr}
55+
UNWIND .save {r6, fp, lr}
56+
push {r6, fp, lr}
57+
58+
UNWIND .movsp r6
59+
mov r6, sp
60+
UNWIND .setfp fp, sp, #4
61+
add fp, sp, #4
62+
63+
// Save argument registers of the original function
64+
push {r0, r1, r2, r3, lr}
65+
66+
// Create new stack
67+
bl STACK_EXHAUSTED@plt
68+
69+
// the above function ensures that it never returns
70+
UNWIND .fnend

‎src/rt/arch/armv7s/record_sp.S

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Do not compile anything here for iOS because split stacks
2+
// are disabled at all and do not need any runtime support.
3+
//
4+
// See also comments in librustrt/stack.rs about why it was
5+
// disabled and how it could be implemented in case of need.
6+
#if !defined(__APPLE__)
7+
// Mark stack as non-executable
8+
#if defined(__linux__) && defined(__ELF__)
9+
.section .note.GNU-stack, "", %progbits
10+
#endif
11+
12+
.text
13+
.code 32
14+
.arm
15+
.align
16+
17+
#define RECORD_SP_LIMIT record_sp_limit
18+
#define GET_SP_LIMIT get_sp_limit
19+
20+
.globl RECORD_SP_LIMIT
21+
.globl GET_SP_LIMIT
22+
23+
RECORD_SP_LIMIT:
24+
// First, try to read TLS address from coprocessor
25+
mrc p15, #0, r3, c13, c0, #3
26+
cmp r3, #0
27+
// Otherwise, try to read from magic address 0xFFFF0FF0
28+
mvneq r3, #0xF000
29+
ldreq r3, [r3, #-15]
30+
31+
#if __ANDROID__
32+
add r3, r3, #252
33+
#elif __linux__
34+
add r3, r3, #4
35+
#endif // ANDROID
36+
37+
str r0, [r3]
38+
mov pc, lr
39+
40+
GET_SP_LIMIT:
41+
// First, try to read TLS address from coprocessor
42+
mrc p15, #0, r3, c13, c0, #3
43+
cmp r3, #0
44+
// Otherwise, try to read from magic address 0xFFFF0FF0
45+
mvneq r3, #0xF000
46+
ldreq r3, [r3, #-15]
47+
48+
#if __ANDROID__
49+
add r3, r3, #252
50+
#elif __linux__
51+
add r3, r3, #4
52+
#endif // __ANDROID__
53+
54+
ldr r0, [r3]
55+
mov pc, lr
56+
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.