Skip to content

Commit a945f28

Browse files
committed
iOS: makefiles and runtime for new archs
1 parent ea045d2 commit a945f28

File tree

8 files changed

+336
-51
lines changed

8 files changed

+336
-51
lines changed

mk/cfg/arm-apple-ios.mk

Lines changed: 0 additions & 35 deletions
This file was deleted.

mk/cfg/armv7-apple-ios.mk

Lines changed: 34 additions & 0 deletions
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

Lines changed: 34 additions & 0 deletions
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

Lines changed: 16 additions & 16 deletions
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

src/rt/arch/armv7/morestack.S

Lines changed: 70 additions & 0 deletions
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

Lines changed: 56 additions & 0 deletions
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

Lines changed: 70 additions & 0 deletions
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

0 commit comments

Comments
 (0)