Skip to content

Commit 7f1ed70

Browse files
authored
Rollup merge of rust-lang#60135 - Gilnaa:arm-none-eabi, r=nagisa
Added arm-none-eabi target Hello, This PR adds a new target for compiling bare-metal ARM Cortex-A programs. I've managed to build and use this new target, but I am unclear with regards to a few details: - I'm not sure what are the criteria for choosing between lld and gnu-ld - When trying to build with `./x.py build --target arm-none-eabi`, the script tries to compile with `cc`, instead of `arm-none-eabi-gcc`. It could find different cross-compilers just fine, but I didn't understand where I had to specify it. (I ended up specifying `CC_arm_none_eabi=arm-none-eabi-gcc` in the environment). - I couldn't find where I can exclude std from compiling for this target (as I guess occurs with other bare-metal targets). - Should I add a separate target for `eabihf`?
2 parents 7d7787d + c8baec9 commit 7f1ed70

File tree

5 files changed

+78
-0
lines changed

5 files changed

+78
-0
lines changed

src/ci/docker/dist-various-1/Dockerfile

+4
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,17 @@ ENV TARGETS=$TARGETS,armebv7r-none-eabi
120120
ENV TARGETS=$TARGETS,armebv7r-none-eabihf
121121
ENV TARGETS=$TARGETS,armv7r-none-eabi
122122
ENV TARGETS=$TARGETS,armv7r-none-eabihf
123+
ENV TARGETS=$TARGETS,armv7a-none-eabi
124+
ENV TARGETS=$TARGETS,armv7a-none-eabihf
123125
ENV TARGETS=$TARGETS,thumbv7neon-unknown-linux-gnueabihf
124126

125127
ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \
126128
CC_mips_unknown_linux_musl=mips-openwrt-linux-gcc \
127129
CC_sparc64_unknown_linux_gnu=sparc64-linux-gnu-gcc \
128130
CC_x86_64_unknown_redox=x86_64-unknown-redox-gcc \
129131
CC_armebv7r_none_eabi=arm-none-eabi-gcc \
132+
CC_armv7a_none_eabi=arm-none-eabi-gcc \
133+
CC_armv7a_none_eabihf=arm-none-eabi-gcc \
130134
CC_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc \
131135
AR_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-ar \
132136
CXX_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Generic ARM-v7 Cortex-A target, with software floating-point emulation.
2+
//
3+
// Can be used in conjunction with the `target-feature` and
4+
// `target-cpu` compiler flags to opt-in more hardware-specific
5+
// features.
6+
//
7+
// For example, `-C target-cpu=cortex-a7`.
8+
9+
use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions, TargetResult};
10+
11+
pub fn target() -> TargetResult {
12+
Ok(Target {
13+
llvm_target: "armv7a-none-eabi".to_string(),
14+
target_endian: "little".to_string(),
15+
target_pointer_width: "32".to_string(),
16+
target_c_int_width: "32".to_string(),
17+
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
18+
arch: "arm".to_string(),
19+
target_os: "none".to_string(),
20+
target_env: String::new(),
21+
target_vendor: String::new(),
22+
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
23+
24+
options: TargetOptions {
25+
features: "+strict-align,+v7,+thumb2,-neon".to_string(),
26+
linker: Some("rust-lld".to_owned()),
27+
executables: true,
28+
relocation_model: "static".to_string(),
29+
max_atomic_width: Some(64),
30+
panic_strategy: PanicStrategy::Abort,
31+
abi_blacklist: super::arm_base::abi_blacklist(),
32+
.. Default::default()
33+
},
34+
})
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Generic ARM-v7 Cortex-A target, with hardware floating-point.
2+
//
3+
// Can be used in conjunction with the `target-feature` and
4+
// `target-cpu` compiler flags to opt-in more hardware-specific
5+
// features.
6+
//
7+
// For example, `-C target-cpu=cortex-a7`.
8+
9+
use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions, TargetResult};
10+
11+
pub fn target() -> TargetResult {
12+
Ok(Target {
13+
llvm_target: "armv7a-none-eabihf".to_string(),
14+
target_endian: "little".to_string(),
15+
target_pointer_width: "32".to_string(),
16+
target_c_int_width: "32".to_string(),
17+
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
18+
arch: "arm".to_string(),
19+
target_os: "none".to_string(),
20+
target_env: String::new(),
21+
target_vendor: String::new(),
22+
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
23+
24+
options: TargetOptions {
25+
features: "+strict-align,+v7,+vfp3,+d16,+thumb2,-neon".to_string(),
26+
linker: Some("rust-lld".to_owned()),
27+
executables: true,
28+
relocation_model: "static".to_string(),
29+
max_atomic_width: Some(64),
30+
panic_strategy: PanicStrategy::Abort,
31+
abi_blacklist: super::arm_base::abi_blacklist(),
32+
.. Default::default()
33+
},
34+
})
35+
}

src/librustc_target/spec/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ supported_targets! {
351351
("s390x-unknown-linux-gnu", s390x_unknown_linux_gnu),
352352
("sparc-unknown-linux-gnu", sparc_unknown_linux_gnu),
353353
("sparc64-unknown-linux-gnu", sparc64_unknown_linux_gnu),
354+
("armv7a-none-eabi", armv7a_none_eabi),
355+
("armv7a-none-eabihf", armv7a_none_eabihf),
354356
("arm-unknown-linux-gnueabi", arm_unknown_linux_gnueabi),
355357
("arm-unknown-linux-gnueabihf", arm_unknown_linux_gnueabihf),
356358
("arm-unknown-linux-musleabi", arm_unknown_linux_musleabi),

src/tools/build-manifest/src/main.rs

+2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ static TARGETS: &[&str] = &[
6666
"armv7r-none-eabi",
6767
"armv7r-none-eabihf",
6868
"armv7s-apple-ios",
69+
"armv7a-none-eabi",
70+
"armv7a-none-eabihf",
6971
"asmjs-unknown-emscripten",
7072
"i386-apple-ios",
7173
"i586-pc-windows-msvc",

0 commit comments

Comments
 (0)