Skip to content

Commit

Permalink
Rollup merge of rust-lang#60135 - Gilnaa:arm-none-eabi, r=nagisa
Browse files Browse the repository at this point in the history
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`?
  • Loading branch information
kennytm authored May 2, 2019
2 parents 50be6df + c8baec9 commit b7b4f25
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/ci/docker/dist-various-1/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,17 @@ ENV TARGETS=$TARGETS,armebv7r-none-eabi
ENV TARGETS=$TARGETS,armebv7r-none-eabihf
ENV TARGETS=$TARGETS,armv7r-none-eabi
ENV TARGETS=$TARGETS,armv7r-none-eabihf
ENV TARGETS=$TARGETS,armv7a-none-eabi
ENV TARGETS=$TARGETS,armv7a-none-eabihf
ENV TARGETS=$TARGETS,thumbv7neon-unknown-linux-gnueabihf

ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \
CC_mips_unknown_linux_musl=mips-openwrt-linux-gcc \
CC_sparc64_unknown_linux_gnu=sparc64-linux-gnu-gcc \
CC_x86_64_unknown_redox=x86_64-unknown-redox-gcc \
CC_armebv7r_none_eabi=arm-none-eabi-gcc \
CC_armv7a_none_eabi=arm-none-eabi-gcc \
CC_armv7a_none_eabihf=arm-none-eabi-gcc \
CC_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc \
AR_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-ar \
CXX_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++
Expand Down
35 changes: 35 additions & 0 deletions src/librustc_target/spec/armv7a_none_eabi.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Generic ARM-v7 Cortex-A target, with software floating-point emulation.
//
// Can be used in conjunction with the `target-feature` and
// `target-cpu` compiler flags to opt-in more hardware-specific
// features.
//
// For example, `-C target-cpu=cortex-a7`.

use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions, TargetResult};

pub fn target() -> TargetResult {
Ok(Target {
llvm_target: "armv7a-none-eabi".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
target_c_int_width: "32".to_string(),
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
arch: "arm".to_string(),
target_os: "none".to_string(),
target_env: String::new(),
target_vendor: String::new(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),

options: TargetOptions {
features: "+strict-align,+v7,+thumb2,-neon".to_string(),
linker: Some("rust-lld".to_owned()),
executables: true,
relocation_model: "static".to_string(),
max_atomic_width: Some(64),
panic_strategy: PanicStrategy::Abort,
abi_blacklist: super::arm_base::abi_blacklist(),
.. Default::default()
},
})
}
35 changes: 35 additions & 0 deletions src/librustc_target/spec/armv7a_none_eabihf.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Generic ARM-v7 Cortex-A target, with hardware floating-point.
//
// Can be used in conjunction with the `target-feature` and
// `target-cpu` compiler flags to opt-in more hardware-specific
// features.
//
// For example, `-C target-cpu=cortex-a7`.

use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions, TargetResult};

pub fn target() -> TargetResult {
Ok(Target {
llvm_target: "armv7a-none-eabihf".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
target_c_int_width: "32".to_string(),
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
arch: "arm".to_string(),
target_os: "none".to_string(),
target_env: String::new(),
target_vendor: String::new(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),

options: TargetOptions {
features: "+strict-align,+v7,+vfp3,+d16,+thumb2,-neon".to_string(),
linker: Some("rust-lld".to_owned()),
executables: true,
relocation_model: "static".to_string(),
max_atomic_width: Some(64),
panic_strategy: PanicStrategy::Abort,
abi_blacklist: super::arm_base::abi_blacklist(),
.. Default::default()
},
})
}
2 changes: 2 additions & 0 deletions src/librustc_target/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@ supported_targets! {
("s390x-unknown-linux-gnu", s390x_unknown_linux_gnu),
("sparc-unknown-linux-gnu", sparc_unknown_linux_gnu),
("sparc64-unknown-linux-gnu", sparc64_unknown_linux_gnu),
("armv7a-none-eabi", armv7a_none_eabi),
("armv7a-none-eabihf", armv7a_none_eabihf),
("arm-unknown-linux-gnueabi", arm_unknown_linux_gnueabi),
("arm-unknown-linux-gnueabihf", arm_unknown_linux_gnueabihf),
("arm-unknown-linux-musleabi", arm_unknown_linux_musleabi),
Expand Down
2 changes: 2 additions & 0 deletions src/tools/build-manifest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ static TARGETS: &[&str] = &[
"armv7r-none-eabi",
"armv7r-none-eabihf",
"armv7s-apple-ios",
"armv7a-none-eabi",
"armv7a-none-eabihf",
"asmjs-unknown-emscripten",
"i386-apple-ios",
"i586-pc-windows-msvc",
Expand Down

0 comments on commit b7b4f25

Please sign in to comment.