Skip to content

Commit

Permalink
Auto merge of #36874 - japaric:thumbs, r=alexcrichton
Browse files Browse the repository at this point in the history
add Thumbs to the compiler

this commit adds 4 new target definitions to the compiler for easier
cross compilation to ARM Cortex-M devices.

- `thumbv6m-none-eabi`
  - For the Cortex-M0, Cortex-M0+ and Cortex-M1
  - This architecture doesn't have hardware support (instructions) for
    atomics. Hence, the `Atomic*` structs are not available for this
    target.
- `thumbv7m-none-eabi`
  - For the Cortex-M3
- `thumbv7em-none-eabi`
  - For the FPU-less variants of the Cortex-M4 and Cortex-M7
  - On this target, all the floating point operations will be lowered
    software routines (intrinsics)
- `thumbv7em-none-eabihf`
  - For the variants of the Cortex-M4 and Cortex-M7 that do have a FPU.
  - On this target, all the floating point operations will be lowered
    to hardware instructions

No binary releases of standard crates, like `core`, are planned for
these targets because Cargo, in the future, will compile e.g. the `core`
crate on the fly as part of the `cargo build` process. In the meantime,
you'll have to compile the `core` crate yourself. [Xargo] is the easiest
way to do that as in handles the compilation of `core` automatically and
can be used just like Cargo: `xargo build --target thumbv6m-none-eabi`
is all that's needed.

[Xargo]: https://crates.io/crates/xargo

---

cc @brson @alexcrichton
  • Loading branch information
bors committed Oct 4, 2016
2 parents 4a9af01 + 6136069 commit a5dac7a
Show file tree
Hide file tree
Showing 60 changed files with 291 additions and 65 deletions.
2 changes: 1 addition & 1 deletion src/librustc/session/config.rs
Expand Up @@ -933,7 +933,7 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
let os = &sess.target.target.target_os;
let env = &sess.target.target.target_env;
let vendor = &sess.target.target.target_vendor;
let max_atomic_width = sess.target.target.options.max_atomic_width;
let max_atomic_width = sess.target.target.max_atomic_width();

let fam = if let Some(ref fam) = sess.target.target.options.target_family {
intern(fam)
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/aarch64_apple_ios.rs
Expand Up @@ -25,7 +25,7 @@ pub fn target() -> TargetResult {
options: TargetOptions {
features: "+neon,+fp-armv8,+cyclone".to_string(),
eliminate_frame_pointer: false,
max_atomic_width: 128,
max_atomic_width: Some(128),
.. base
},
})
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/aarch64_linux_android.rs
Expand Up @@ -12,7 +12,7 @@ use target::{Target, TargetResult};

pub fn target() -> TargetResult {
let mut base = super::android_base::opts();
base.max_atomic_width = 128;
base.max_atomic_width = Some(128);
// As documented in http://developer.android.com/ndk/guides/cpu-features.html
// the neon (ASIMD) and FP must exist on all android aarch64 targets.
base.features = "+neon,+fp-armv8".to_string();
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/aarch64_unknown_linux_gnu.rs
Expand Up @@ -12,7 +12,7 @@ use target::{Target, TargetResult};

pub fn target() -> TargetResult {
let mut base = super::linux_base::opts();
base.max_atomic_width = 128;
base.max_atomic_width = Some(128);
Ok(Target {
llvm_target: "aarch64-unknown-linux-gnu".to_string(),
target_endian: "little".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/arm_linux_androideabi.rs
Expand Up @@ -13,7 +13,7 @@ use target::{Target, TargetResult};
pub fn target() -> TargetResult {
let mut base = super::android_base::opts();
base.features = "+v7,+vfp3,+d16".to_string();
base.max_atomic_width = 64;
base.max_atomic_width = Some(64);

Ok(Target {
llvm_target: "arm-linux-androideabi".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/arm_unknown_linux_gnueabi.rs
Expand Up @@ -12,7 +12,7 @@ use target::{Target, TargetOptions, TargetResult};

pub fn target() -> TargetResult {
let mut base = super::linux_base::opts();
base.max_atomic_width = 64;
base.max_atomic_width = Some(64);
Ok(Target {
llvm_target: "arm-unknown-linux-gnueabi".to_string(),
target_endian: "little".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/arm_unknown_linux_gnueabihf.rs
Expand Up @@ -12,7 +12,7 @@ use target::{Target, TargetOptions, TargetResult};

pub fn target() -> TargetResult {
let mut base = super::linux_base::opts();
base.max_atomic_width = 64;
base.max_atomic_width = Some(64);
Ok(Target {
llvm_target: "arm-unknown-linux-gnueabihf".to_string(),
target_endian: "little".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/arm_unknown_linux_musleabi.rs
Expand Up @@ -16,7 +16,7 @@ pub fn target() -> TargetResult {
// Most of these settings are copied from the arm_unknown_linux_gnueabi
// target.
base.features = "+v6".to_string();
base.max_atomic_width = 64;
base.max_atomic_width = Some(64);
Ok(Target {
// It's important we use "gnueabi" and not "musleabi" here. LLVM uses it
// to determine the calling convention and float ABI, and it doesn't
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/arm_unknown_linux_musleabihf.rs
Expand Up @@ -16,7 +16,7 @@ pub fn target() -> TargetResult {
// Most of these settings are copied from the arm_unknown_linux_gnueabihf
// target.
base.features = "+v6,+vfp2".to_string();
base.max_atomic_width = 64;
base.max_atomic_width = Some(64);
Ok(Target {
// It's important we use "gnueabihf" and not "musleabihf" here. LLVM
// uses it to determine the calling convention and float ABI, and it
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/armv7_apple_ios.rs
Expand Up @@ -24,7 +24,7 @@ pub fn target() -> TargetResult {
target_vendor: "apple".to_string(),
options: TargetOptions {
features: "+v7,+vfp3,+neon".to_string(),
max_atomic_width: 64,
max_atomic_width: Some(64),
.. base
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/armv7_linux_androideabi.rs
Expand Up @@ -13,7 +13,7 @@ use target::{Target, TargetResult};
pub fn target() -> TargetResult {
let mut base = super::android_base::opts();
base.features = "+v7,+thumb2,+vfp3,+d16".to_string();
base.max_atomic_width = 64;
base.max_atomic_width = Some(64);

Ok(Target {
llvm_target: "armv7-none-linux-android".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/armv7_unknown_linux_gnueabihf.rs
Expand Up @@ -26,7 +26,7 @@ pub fn target() -> TargetResult {
// Info about features at https://wiki.debian.org/ArmHardFloatPort
features: "+v7,+vfp3,+d16,+thumb2".to_string(),
cpu: "generic".to_string(),
max_atomic_width: 64,
max_atomic_width: Some(64),
.. base
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/armv7_unknown_linux_musleabihf.rs
Expand Up @@ -17,7 +17,7 @@ pub fn target() -> TargetResult {
// target.
base.features = "+v7,+vfp3,+neon".to_string();
base.cpu = "cortex-a8".to_string();
base.max_atomic_width = 64;
base.max_atomic_width = Some(64);
Ok(Target {
// It's important we use "gnueabihf" and not "musleabihf" here. LLVM
// uses it to determine the calling convention and float ABI, and LLVM
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/armv7s_apple_ios.rs
Expand Up @@ -24,7 +24,7 @@ pub fn target() -> TargetResult {
target_vendor: "apple".to_string(),
options: TargetOptions {
features: "+v7,+vfp4,+neon".to_string(),
max_atomic_width: 64,
max_atomic_width: Some(64),
.. base
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/asmjs_unknown_emscripten.rs
Expand Up @@ -21,7 +21,7 @@ pub fn target() -> Result<Target, String> {
linker_is_gnu: true,
allow_asm: false,
obj_is_bitcode: true,
max_atomic_width: 32,
max_atomic_width: Some(32),
post_link_args: vec!["-s".to_string(), "ERROR_ON_UNDEFINED_SYMBOLS=1".to_string()],
.. Default::default()
};
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/i386_apple_ios.rs
Expand Up @@ -23,7 +23,7 @@ pub fn target() -> TargetResult {
target_env: "".to_string(),
target_vendor: "apple".to_string(),
options: TargetOptions {
max_atomic_width: 64,
max_atomic_width: Some(64),
.. base
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/i686_apple_darwin.rs
Expand Up @@ -13,7 +13,7 @@ use target::{Target, TargetResult};
pub fn target() -> TargetResult {
let mut base = super::apple_base::opts();
base.cpu = "yonah".to_string();
base.max_atomic_width = 64;
base.max_atomic_width = Some(64);
base.pre_link_args.push("-m32".to_string());

Ok(Target {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/i686_linux_android.rs
Expand Up @@ -13,7 +13,7 @@ use target::{Target, TargetResult};
pub fn target() -> TargetResult {
let mut base = super::android_base::opts();

base.max_atomic_width = 64;
base.max_atomic_width = Some(64);

// http://developer.android.com/ndk/guides/abis.html#x86
base.cpu = "pentiumpro".to_string();
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/i686_pc_windows_gnu.rs
Expand Up @@ -13,7 +13,7 @@ use target::{Target, TargetResult};
pub fn target() -> TargetResult {
let mut base = super::windows_base::opts();
base.cpu = "pentium4".to_string();
base.max_atomic_width = 64;
base.max_atomic_width = Some(64);

// Mark all dynamic libraries and executables as compatible with the larger 4GiB address
// space available to x86 Windows binaries on x86_64.
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/i686_pc_windows_msvc.rs
Expand Up @@ -13,7 +13,7 @@ use target::{Target, TargetResult};
pub fn target() -> TargetResult {
let mut base = super::windows_msvc_base::opts();
base.cpu = "pentium4".to_string();
base.max_atomic_width = 64;
base.max_atomic_width = Some(64);

// Mark all dynamic libraries and executables as compatible with the larger 4GiB address
// space available to x86 Windows binaries on x86_64.
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/i686_unknown_dragonfly.rs
Expand Up @@ -13,7 +13,7 @@ use target::{Target, TargetResult};
pub fn target() -> TargetResult {
let mut base = super::dragonfly_base::opts();
base.cpu = "pentium4".to_string();
base.max_atomic_width = 64;
base.max_atomic_width = Some(64);
base.pre_link_args.push("-m32".to_string());

Ok(Target {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/i686_unknown_freebsd.rs
Expand Up @@ -13,7 +13,7 @@ use target::{Target, TargetResult};
pub fn target() -> TargetResult {
let mut base = super::freebsd_base::opts();
base.cpu = "pentium4".to_string();
base.max_atomic_width = 64;
base.max_atomic_width = Some(64);
base.pre_link_args.push("-m32".to_string());

Ok(Target {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/i686_unknown_haiku.rs
Expand Up @@ -13,7 +13,7 @@ use target::{Target, TargetResult};
pub fn target() -> TargetResult {
let mut base = super::haiku_base::opts();
base.cpu = "pentium4".to_string();
base.max_atomic_width = 64;
base.max_atomic_width = Some(64);
base.pre_link_args.push("-m32".to_string());

Ok(Target {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/i686_unknown_linux_gnu.rs
Expand Up @@ -13,7 +13,7 @@ use target::{Target, TargetResult};
pub fn target() -> TargetResult {
let mut base = super::linux_base::opts();
base.cpu = "pentium4".to_string();
base.max_atomic_width = 64;
base.max_atomic_width = Some(64);
base.pre_link_args.push("-m32".to_string());

Ok(Target {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/i686_unknown_linux_musl.rs
Expand Up @@ -13,7 +13,7 @@ use target::{Target, TargetResult};
pub fn target() -> TargetResult {
let mut base = super::linux_musl_base::opts();
base.cpu = "pentium4".to_string();
base.max_atomic_width = 64;
base.max_atomic_width = Some(64);
base.pre_link_args.push("-m32".to_string());
base.pre_link_args.push("-Wl,-melf_i386".to_string());

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/le32_unknown_nacl.rs
Expand Up @@ -24,7 +24,7 @@ pub fn target() -> TargetResult {
exe_suffix: ".pexe".to_string(),
linker_is_gnu: true,
allow_asm: false,
max_atomic_width: 32,
max_atomic_width: Some(32),
.. Default::default()
};
Ok(Target {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/mips64_unknown_linux_gnuabi64.rs
Expand Up @@ -24,7 +24,7 @@ pub fn target() -> TargetResult {
// NOTE(mips64r2) matches C toolchain
cpu: "mips64r2".to_string(),
features: "+mips64r2".to_string(),
max_atomic_width: 64,
max_atomic_width: Some(64),
..super::linux_base::opts()
},
})
Expand Down
Expand Up @@ -24,7 +24,7 @@ pub fn target() -> TargetResult {
// NOTE(mips64r2) matches C toolchain
cpu: "mips64r2".to_string(),
features: "+mips64r2".to_string(),
max_atomic_width: 64,
max_atomic_width: Some(64),
..super::linux_base::opts()
},
})
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/mips_unknown_linux_gnu.rs
Expand Up @@ -23,7 +23,7 @@ pub fn target() -> TargetResult {
options: TargetOptions {
cpu: "mips32r2".to_string(),
features: "+mips32r2".to_string(),
max_atomic_width: 32,
max_atomic_width: Some(32),
..super::linux_base::opts()
},
})
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/mips_unknown_linux_musl.rs
Expand Up @@ -23,7 +23,7 @@ pub fn target() -> TargetResult {
options: TargetOptions {
cpu: "mips32r2".to_string(),
features: "+mips32r2,+soft-float".to_string(),
max_atomic_width: 32,
max_atomic_width: Some(32),
..super::linux_base::opts()
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/mips_unknown_linux_uclibc.rs
Expand Up @@ -23,7 +23,7 @@ pub fn target() -> TargetResult {
options: TargetOptions {
cpu: "mips32r2".to_string(),
features: "+mips32r2,+soft-float".to_string(),
max_atomic_width: 32,
max_atomic_width: Some(32),
..super::linux_base::opts()
},
})
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/mipsel_unknown_linux_gnu.rs
Expand Up @@ -24,7 +24,7 @@ pub fn target() -> TargetResult {
options: TargetOptions {
cpu: "mips32".to_string(),
features: "+mips32".to_string(),
max_atomic_width: 32,
max_atomic_width: Some(32),
..super::linux_base::opts()
},
})
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/mipsel_unknown_linux_musl.rs
Expand Up @@ -23,7 +23,7 @@ pub fn target() -> TargetResult {
options: TargetOptions {
cpu: "mips32".to_string(),
features: "+mips32,+soft-float".to_string(),
max_atomic_width: 32,
max_atomic_width: Some(32),
..super::linux_base::opts()
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/mipsel_unknown_linux_uclibc.rs
Expand Up @@ -24,7 +24,7 @@ pub fn target() -> TargetResult {
options: TargetOptions {
cpu: "mips32".to_string(),
features: "+mips32,+soft-float".to_string(),
max_atomic_width: 32,
max_atomic_width: Some(32),
..super::linux_base::opts()
},
})
Expand Down

0 comments on commit a5dac7a

Please sign in to comment.