Skip to content

Commit 577d0db

Browse files
committed
iOS: preliminary 64-bit archs support
1 parent 3fbbc6e commit 577d0db

File tree

8 files changed

+161
-9
lines changed

8 files changed

+161
-9
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/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
@@ -1968,7 +1968,7 @@ pub mod types {
19681968
}
19691969
}
19701970

1971-
#[cfg(target_arch = "x86_64")]
1971+
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
19721972
pub mod arch {
19731973
pub mod c95 {
19741974
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+
}

src/librustc_back/target/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ mod i386_apple_ios;
6464
mod arm_linux_androideabi;
6565
mod arm_unknown_linux_gnueabi;
6666
mod arm_unknown_linux_gnueabihf;
67+
mod aarch64_apple_ios;
6768
mod aarch64_unknown_linux_gnu;
6869
mod i686_apple_darwin;
6970
mod i686_pc_windows_gnu;
@@ -72,6 +73,7 @@ mod i686_unknown_linux_gnu;
7273
mod mips_unknown_linux_gnu;
7374
mod mipsel_unknown_linux_gnu;
7475
mod x86_64_apple_darwin;
76+
mod x86_64_apple_ios;
7577
mod x86_64_pc_windows_gnu;
7678
mod x86_64_unknown_freebsd;
7779
mod x86_64_unknown_dragonfly;
@@ -351,6 +353,8 @@ impl Target {
351353
i686_apple_darwin,
352354

353355
i386_apple_ios,
356+
x86_64_apple_ios,
357+
aarch64_apple_ios,
354358
armv7_apple_ios,
355359
armv7s_apple_ios,
356360

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/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

0 commit comments

Comments
 (0)