Skip to content

Commit d68c027

Browse files
committed
auto merge of #6249 : crabtw/rust/arm, r=brson
It uses the private field of TCB head to store stack limit. I tested on my Raspberry PI. A simple hello world program ran without any problem. However, for a more complex program, it segfaulted as #6231.
2 parents 2d28d64 + 48b6262 commit d68c027

File tree

5 files changed

+42
-1
lines changed

5 files changed

+42
-1
lines changed

mk/platform.mk

+26
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,32 @@ CFG_RUN_arm-linux-androideabi=
239239
CFG_RUN_TARG_arm-linux-androideabi=
240240
RUSTC_FLAGS_arm-linux-androideabi :=--android-cross-path=$(CFG_ANDROID_CROSS_PATH)
241241

242+
# arm-unknown-linux-gnueabihf configuration
243+
CC_arm-unknown-linux-gnueabihf=arm-linux-gnueabihf-gcc
244+
CXX_arm-unknown-linux-gnueabihf=arm-linux-gnueabihf-g++
245+
CPP_arm-unknown-linux-gnueabihf=arm-linux-gnueabihf-gcc -E
246+
AR_arm-unknown-linux-gnueabihf=arm-linux-gnueabihf-ar
247+
CFG_LIB_NAME_arm-unknown-linux-gnueabihf=lib$(1).so
248+
CFG_LIB_GLOB_arm-unknown-linux-gnueabihf=lib$(1)-*.so
249+
CFG_LIB_DSYM_GLOB_arm-unknown-linux-gnueabihf=lib$(1)-*.dylib.dSYM
250+
CFG_GCCISH_CFLAGS_arm-unknown-linux-gnueabihf := -Wall -g -fPIC
251+
CFG_GCCISH_CXXFLAGS_arm-unknown-linux-gnueabihf := -fno-rtti
252+
CFG_GCCISH_LINK_FLAGS_arm-unknown-linux-gnueabihf := -shared -fPIC -g
253+
CFG_GCCISH_DEF_FLAG_arm-unknown-linux-gnueabihf := -Wl,--export-dynamic,--dynamic-list=
254+
CFG_GCCISH_PRE_LIB_FLAGS_arm-unknown-linux-gnueabihf := -Wl,-whole-archive
255+
CFG_GCCISH_POST_LIB_FLAGS_arm-unknown-linux-gnueabihf := -Wl,-no-whole-archive
256+
CFG_DEF_SUFFIX_arm-unknown-linux-gnueabihf := .linux.def
257+
CFG_INSTALL_NAME_ar,-unknown-linux-gnueabihf =
258+
CFG_LIBUV_LINK_FLAGS_arm-unknown-linux-gnueabihf =
259+
CFG_EXE_SUFFIX_arm-unknown-linux-gnueabihf :=
260+
CFG_WINDOWSY_arm-unknown-linux-gnueabihf :=
261+
CFG_UNIXY_arm-unknown-linux-gnueabihf := 1
262+
CFG_PATH_MUNGE_arm-unknown-linux-gnueabihf := true
263+
CFG_LDPATH_arm-unknown-linux-gnueabihf :=
264+
CFG_RUN_arm-unknown-linux-gnueabihf=
265+
CFG_RUN_TARG_arm-unknown-linux-gnueabihf=
266+
RUSTC_FLAGS_arm-unknown-linux-gnueabihf := --linker=$(CC_arm-unknown-linux-gnueabihf)
267+
242268
# mips-unknown-linux-gnu configuration
243269
CC_mips-unknown-linux-gnu=mips-linux-gnu-gcc
244270
CXX_mips-unknown-linux-gnu=mips-linux-gnu-g++

mk/rt.mk

+4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@
2626
# Hack for passing flags into LIBUV, see below.
2727
LIBUV_FLAGS_i386 = -m32 -fPIC
2828
LIBUV_FLAGS_x86_64 = -m64 -fPIC
29+
ifeq ($(OSTYPE_$(1)), linux-androideabi)
2930
LIBUV_FLAGS_arm = -fPIC -DANDROID -std=gnu99
31+
else
32+
LIBUV_FLAGS_arm = -fPIC -std=gnu99
33+
endif
3034
LIBUV_FLAGS_mips = -fPIC -mips32r2 -msoft-float -mabi=32
3135

3236
# when we're doing a snapshot build, we intentionally degrade as many

src/librustc/back/arm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub fn get_target_strs(target_os: session::os) -> target_strs::t {
6464
target_triple: match target_os {
6565
session::os_macos => ~"arm-apple-darwin",
6666
session::os_win32 => ~"arm-pc-mingw32",
67-
session::os_linux => ~"arm-unknown-linux",
67+
session::os_linux => ~"arm-unknown-linux-gnueabihf",
6868
session::os_android => ~"arm-linux-androideabi",
6969
session::os_freebsd => ~"arm-unknown-freebsd"
7070
},

src/rt/arch/arm/record_sp.S

+8
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,21 @@
1515

1616
record_sp_limit:
1717
mrc p15, #0, r3, c13, c0, #3
18+
#if __ANDROID__
1819
add r3, r3, #252
20+
#elif __linux__
21+
add r3, r3, #4
22+
#endif
1923
str r0, [r3]
2024
mov pc, lr
2125

2226
get_sp_limit:
2327
mrc p15, #0, r3, c13, c0, #3
28+
#if __ANDROID__
2429
add r3, r3, #252
30+
#elif __linux__
31+
add r3, r3, #4
32+
#endif
2533
ldr r0, [r3]
2634
mov pc, lr
2735

src/rt/rust_task.h

+3
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@
146146
#ifdef __mips__
147147
#define RED_ZONE_SIZE RZ_MAC_32
148148
#endif
149+
#ifdef __arm__
150+
#define RED_ZONE_SIZE RZ_LINUX_32
151+
#endif
149152
#endif
150153
#ifdef __APPLE__
151154
#ifdef __i386__

0 commit comments

Comments
 (0)