Skip to content

Commit 7bd87c1

Browse files
committed
Auto merge of #30948 - fabricedesre:rpi2, r=alexcrichton
This adds support for the armv7 crosstool-ng toolchain for the Raspberry Pi 2. Getting the toolchain ready: Checkout crosstool-ng from https://github.com/crosstool-ng/crosstool-ng Build crosstool-ng Configure the rpi2 target with |ct-ng armv7-rpi2-linux-gnueabihf| Build the toolchain with |ct-build| and add the path to $toolchain_install_dir/bin to your $PATH Then, on the rust side: configure --target=armv7-rpi2-linux-gnueabihf && make && make install To cross compile for the rpi2, add $rust_install_path/lib to your $LD_LIBRARY_PATH, then use rustc --target=armv7-rpi2-linux-gnueabihf -C linker=armv7-rpi2-linux-gnueabihf-g++ hello.rs
2 parents 53c2933 + 63b4639 commit 7bd87c1

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# armv7-unknown-linux-gnueabihf configuration
2+
CROSS_PREFIX_armv7-unknown-linux-gnueabihf=armv7-unknown-linux-gnueabihf-
3+
CC_armv7-unknown-linux-gnueabihf=gcc
4+
CXX_armv7-unknown-linux-gnueabihf=g++
5+
CPP_armv7-unknown-linux-gnueabihf=gcc -E
6+
AR_armv7-unknown-linux-gnueabihf=ar
7+
CFG_LIB_NAME_armv7-unknown-linux-gnueabihf=lib$(1).so
8+
CFG_STATIC_LIB_NAME_armv7-unknown-linux-gnueabihf=lib$(1).a
9+
CFG_LIB_GLOB_armv7-unknown-linux-gnueabihf=lib$(1)-*.so
10+
CFG_LIB_DSYM_GLOB_armv7-unknown-linux-gnueabihf=lib$(1)-*.dylib.dSYM
11+
CFG_JEMALLOC_CFLAGS_armv7-unknown-linux-gnueabihf := -D__arm__ $(CFLAGS)
12+
CFG_GCCISH_CFLAGS_armv7-unknown-linux-gnueabihf := -Wall -g -fPIC -D__arm__ $(CFLAGS)
13+
CFG_GCCISH_CXXFLAGS_armv7-unknown-linux-gnueabihf := -fno-rtti $(CXXFLAGS)
14+
CFG_GCCISH_LINK_FLAGS_armv7-unknown-linux-gnueabihf := -shared -fPIC -g
15+
CFG_GCCISH_DEF_FLAG_armv7-unknown-linux-gnueabihf := -Wl,--export-dynamic,--dynamic-list=
16+
CFG_LLC_FLAGS_armv7-unknown-linux-gnueabihf :=
17+
CFG_INSTALL_NAME_ar,-unknown-linux-gnueabihf =
18+
CFG_EXE_SUFFIX_armv7-unknown-linux-gnueabihf :=
19+
CFG_WINDOWSY_armv7-unknown-linux-gnueabihf :=
20+
CFG_UNIXY_armv7-unknown-linux-gnueabihf := 1
21+
CFG_LDPATH_armv7-unknown-linux-gnueabihf :=
22+
CFG_RUN_armv7-unknown-linux-gnueabihf=$(2)
23+
CFG_RUN_TARG_armv7-unknown-linux-gnueabihf=$(call CFG_RUN_armv7-unknown-linux-gnueabihf,,$(2))
24+
RUSTC_FLAGS_armv7-unknown-linux-gnueabihf := -C target-feature=+v7,+vfp2,+neon
25+
RUSTC_CROSS_FLAGS_armv7-unknown-linux-gnueabihf :=
26+
CFG_GNU_TRIPLE_armv7-unknown-linux-gnueabihf := armv7-unknown-linux-gnueabihf
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2016 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+
13+
pub fn target() -> Target {
14+
let base = super::linux_base::opts();
15+
Target {
16+
llvm_target: "armv7-unknown-linux-gnueabihf".to_string(),
17+
target_endian: "little".to_string(),
18+
target_pointer_width: "32".to_string(),
19+
arch: "arm".to_string(),
20+
target_os: "linux".to_string(),
21+
target_env: "gnueabihf".to_string(),
22+
target_vendor: "unknown".to_string(),
23+
24+
options: TargetOptions {
25+
features: "+v7,+vfp2,+neon".to_string(),
26+
cpu: "cortex-a7".to_string(),
27+
.. base
28+
}
29+
}
30+
}
31+

src/librustc_back/target/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ impl Target {
417417
powerpc64le_unknown_linux_gnu,
418418
arm_unknown_linux_gnueabi,
419419
arm_unknown_linux_gnueabihf,
420+
armv7_unknown_linux_gnueabihf,
420421
aarch64_unknown_linux_gnu,
421422
x86_64_unknown_linux_musl,
422423

0 commit comments

Comments
 (0)