Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a thumbv4t-none-eabi target #74419

Merged
merged 12 commits into from
Jul 19, 2020
1 change: 1 addition & 0 deletions src/librustc_target/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,7 @@ supported_targets! {
("powerpc64-wrs-vxworks", powerpc64_wrs_vxworks),

("mipsel-sony-psp", mipsel_sony_psp),
("thumbv4t-none-eabi", thumbv4t_none_eabi),
}

/// Everything `rustc` knows about how to compile for a specific target.
Expand Down
62 changes: 62 additions & 0 deletions src/librustc_target/spec/thumbv4t_none_eabi.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//! Targets the ARMv4T, with code as `t32` code by default.
//!
//! Primarily of use for the GBA, but usable with other devices too.
//!
//! Please ping @Lokathor if changes are needed.
//!
//! This target profile assumes that you have the ARM binutils in your path (specifically the linker, `arm-none-eabi-ld`). They can be obtained for free for all major OSes from the ARM developer's website, and they may also be available in your system's package manager. Unfortunately, the standard linker that Rust uses (`lld`) only supports as far back as `ARMv5TE`, so we must use the GNU `ld` linker.
//!
//! **Important:** This target profile **does not** specify a linker script. You just get the default link script when you build a binary for this target. The default link script is very likely wrong, so you should use `-Clink-arg=-Tmy_script.ld` to override that with a correct linker script.

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

pub fn target() -> TargetResult {
Ok(Target {
llvm_target: "thumbv4t-none-eabi".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
target_c_int_width: "32".to_string(),
target_os: "none".to_string(),
target_env: "".to_string(),
target_vendor: "".to_string(),
arch: "arm".to_string(),
/* Data layout args are '-' separated:
* little endian
* stack is 64-bit aligned (EABI)
* pointers are 32-bit
* i64 must be 64-bit aligned (EABI)
* mangle names with ELF style
* native integers are 32-bit
* All other elements are default
*/
data_layout: "e-S64-p:32:32-i64:64-m:e-n32".to_string(),
linker_flavor: LinkerFlavor::Ld,
options: TargetOptions {
linker: Some("arm-none-eabi-ld".to_string()),
linker_is_gnu: true,

// extra args passed to the external assembler (assuming `arm-none-eabi-as`):
// * activate t32/a32 interworking
// * use arch ARMv4T
// * use little-endian
asm_args: vec![
"-mthumb-interwork".to_string(),
"-march=armv4t".to_string(),
"-mlittle-endian".to_string(),
],

// minimum extra features, these cannot be disabled via -C
features: "+soft-float,+strict-align".to_string(),

main_needs_argc_argv: false,

// No thread-local storage (just use a static Cell)
has_elf_tls: false,

// don't have atomic compare-and-swap
atomic_cas: false,

..super::thumb_base::opts()
},
})
}