Skip to content

Commit 83d2a04

Browse files
committed
auto merge of #8220 : luqmana/rust/arm-linux, r=cmr
Update the arm linux support some more. We had a previous patch for the RasberryPi. This adds a new target `arm-unknown-linux-gnueabi` for more general arm linux support. Build/Host machine: x86_64 Debian testing (jessie) with the `gcc-4.4-arm-linux-gnueabi` package Tested on targets: - TS-7800 Feroceon (ARMv5TEJ) running Debian 7.0 wheezy - Beaglebone black (ARMv7) running Angstrom GNU/Linux v2012.12 - rustc flags: `--target=arm-unknown-linux-gnueabi --linker=arm-linux-gnueabi-gcc` - Samsung Galaxy S II (to make sure android still works) - rustc flags: `--target=arm-linux-androideabi --android-cross-path=[path to standalone toolchain]` Since not all arm devices (i.e. afaik anything older than armv6 like the ts-7800 i tested on) supported getting the tls address via the `mrc` instruction, I made it also try via the magic address the kernel maps into the address space (0xFFFF0FF0). One or the other should work (and on android it seems like both work). Also fixes a bug where rustc would always try to invoke the android assembler for any kind of arm target.
2 parents 6c12ca3 + 9c39992 commit 83d2a04

File tree

3 files changed

+46
-6
lines changed

3 files changed

+46
-6
lines changed

mk/platform.mk

+31-5
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ CFG_RUN_TARG_i686-apple-darwin=$(call CFG_RUN_i686-apple-darwin,,$(2))
241241
# arm-linux-androideabi configuration
242242
CC_arm-linux-androideabi=$(CFG_ANDROID_CROSS_PATH)/bin/arm-linux-androideabi-gcc
243243
CXX_arm-linux-androideabi=$(CFG_ANDROID_CROSS_PATH)/bin/arm-linux-androideabi-g++
244-
CPP_arm-linux-androideabi=$(CFG_ANDROID_CROSS_PATH)/bin/arm-linux-androideabi-gcc
244+
CPP_arm-linux-androideabi=$(CFG_ANDROID_CROSS_PATH)/bin/arm-linux-androideabi-gcc -E
245245
AR_arm-linux-androideabi=$(CFG_ANDROID_CROSS_PATH)/bin/arm-linux-androideabi-ar
246246
CFG_LIB_NAME_arm-linux-androideabi=lib$(1).so
247247
CFG_LIB_GLOB_arm-linux-androideabi=lib$(1)-*.so
@@ -272,7 +272,7 @@ AR_arm-unknown-linux-gnueabihf=arm-linux-gnueabihf-ar
272272
CFG_LIB_NAME_arm-unknown-linux-gnueabihf=lib$(1).so
273273
CFG_LIB_GLOB_arm-unknown-linux-gnueabihf=lib$(1)-*.so
274274
CFG_LIB_DSYM_GLOB_arm-unknown-linux-gnueabihf=lib$(1)-*.dylib.dSYM
275-
CFG_GCCISH_CFLAGS_arm-unknown-linux-gnueabihf := -Wall -g -fPIC
275+
CFG_GCCISH_CFLAGS_arm-unknown-linux-gnueabihf := -Wall -g -fPIC -D__arm__
276276
CFG_GCCISH_CXXFLAGS_arm-unknown-linux-gnueabihf := -fno-rtti
277277
CFG_GCCISH_LINK_FLAGS_arm-unknown-linux-gnueabihf := -shared -fPIC -g
278278
CFG_GCCISH_DEF_FLAG_arm-unknown-linux-gnueabihf := -Wl,--export-dynamic,--dynamic-list=
@@ -290,6 +290,32 @@ CFG_RUN_arm-unknown-linux-gnueabihf=
290290
CFG_RUN_TARG_arm-unknown-linux-gnueabihf=
291291
RUSTC_FLAGS_arm-unknown-linux-gnueabihf := --linker=$(CC_arm-unknown-linux-gnueabihf)
292292

293+
# arm-unknown-linux-gnueabi configuration
294+
CC_arm-unknown-linux-gnueabi=arm-linux-gnueabi-gcc
295+
CXX_arm-unknown-linux-gnueabi=arm-linux-gnueabi-g++
296+
CPP_arm-unknown-linux-gnueabi=arm-linux-gnueabi-gcc -E
297+
AR_arm-unknown-linux-gnueabi=arm-linux-gnueabi-ar
298+
CFG_LIB_NAME_arm-unknown-linux-gnueabi=lib$(1).so
299+
CFG_LIB_GLOB_arm-unknown-linux-gnueabi=lib$(1)-*.so
300+
CFG_LIB_DSYM_GLOB_arm-unknown-linux-gnueabi=lib$(1)-*.dylib.dSYM
301+
CFG_GCCISH_CFLAGS_arm-unknown-linux-gnueabi := -Wall -g -fPIC -D__arm__
302+
CFG_GCCISH_CXXFLAGS_arm-unknown-linux-gnueabi := -fno-rtti
303+
CFG_GCCISH_LINK_FLAGS_arm-unknown-linux-gnueabi := -shared -fPIC -g
304+
CFG_GCCISH_DEF_FLAG_arm-unknown-linux-gnueabi := -Wl,--export-dynamic,--dynamic-list=
305+
CFG_GCCISH_PRE_LIB_FLAGS_arm-unknown-linux-gnueabi := -Wl,-whole-archive
306+
CFG_GCCISH_POST_LIB_FLAGS_arm-unknown-linux-gnueabi := -Wl,-no-whole-archive
307+
CFG_DEF_SUFFIX_arm-unknown-linux-gnueabi := .linux.def
308+
CFG_INSTALL_NAME_ar,-unknown-linux-gnueabi =
309+
CFG_LIBUV_LINK_FLAGS_arm-unknown-linux-gnueabi =
310+
CFG_EXE_SUFFIX_arm-unknown-linux-gnueabi :=
311+
CFG_WINDOWSY_arm-unknown-linux-gnueabi :=
312+
CFG_UNIXY_arm-unknown-linux-gnueabi := 1
313+
CFG_PATH_MUNGE_arm-unknown-linux-gnueabi := true
314+
CFG_LDPATH_arm-unknown-linux-gnueabi :=
315+
CFG_RUN_arm-unknown-linux-gnueabi=
316+
CFG_RUN_TARG_arm-unknown-linux-gnueabi=
317+
RUSTC_FLAGS_arm-unknown-linux-gnueabi := --linker=$(CC_arm-unknown-linux-gnueabi)
318+
293319
# mips-unknown-linux-gnu configuration
294320
CC_mips-unknown-linux-gnu=mips-linux-gnu-gcc
295321
CXX_mips-unknown-linux-gnu=mips-linux-gnu-g++
@@ -450,7 +476,7 @@ define CFG_MAKE_TOOLCHAIN
450476
$$(CFG_GCCISH_DEF_FLAG_$(1))$$(3) $$(2) \
451477
$$(call CFG_INSTALL_NAME_$(1),$$(4))
452478

453-
ifneq ($(1),arm-linux-androideabi)
479+
ifneq ($(HOST_$(1)),arm)
454480

455481
# We're using llvm-mc as our assembler because it supports
456482
# .cfi pseudo-ops on mac
@@ -462,9 +488,9 @@ define CFG_MAKE_TOOLCHAIN
462488
-o=$$(1)
463489
else
464490

465-
# For the Android cross, use the Android assembler
491+
# For the ARM crosses, use the toolchain assembler
466492
# XXX: We should be able to use the LLVM assembler
467-
CFG_ASSEMBLE_$(1)=$$(CPP_$(1)) $$(CFG_DEPEND_FLAGS) $$(2) -c -o $$(1)
493+
CFG_ASSEMBLE_$(1)=$$(CC_$(1)) $$(CFG_DEPEND_FLAGS) $$(2) -c -o $$(1)
468494

469495
endif
470496

src/librustc/driver/driver.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ pub fn phase_5_run_llvm_passes(sess: Session,
335335
outputs: &OutputFilenames) {
336336

337337
// NB: Android hack
338-
if sess.targ_cfg.arch == abi::Arm &&
338+
if sess.targ_cfg.os == session::os_android &&
339339
(sess.opts.output_type == link::output_type_object ||
340340
sess.opts.output_type == link::output_type_exe) {
341341
let output_type = link::output_type_assembly;

src/rt/arch/arm/record_sp.S

+14
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,36 @@
1414
.globl get_sp
1515

1616
record_sp_limit:
17+
// First, try to read TLS address from coprocessor
1718
mrc p15, #0, r3, c13, c0, #3
19+
cmp r3, #0
20+
// Otherwise, try to read from magic address 0xFFFF0FF0
21+
mvneq r3, #0xF000
22+
ldreq r3, [r3, #-15]
23+
1824
#if __ANDROID__
1925
add r3, r3, #252
2026
#elif __linux__
2127
add r3, r3, #4
2228
#endif
29+
2330
str r0, [r3]
2431
mov pc, lr
2532

2633
get_sp_limit:
34+
// First, try to read TLS address from coprocessor
2735
mrc p15, #0, r3, c13, c0, #3
36+
cmp r3, #0
37+
// Otherwise, try to read from magic address 0xFFFF0FF0
38+
mvneq r3, #0xF000
39+
ldreq r3, [r3, #-15]
40+
2841
#if __ANDROID__
2942
add r3, r3, #252
3043
#elif __linux__
3144
add r3, r3, #4
3245
#endif
46+
3347
ldr r0, [r3]
3448
mov pc, lr
3549

0 commit comments

Comments
 (0)