|
| 1 | +// Generic ARMv7-A target for bare-metal code - floating point disabled |
| 2 | +// |
| 3 | +// This is basically the `armv7-unknown-linux-gnueabi` target with some changes |
| 4 | +// (listed below) to bring it closer to the bare-metal `thumb` & `aarch64` |
| 5 | +// targets: |
| 6 | +// |
| 7 | +// - `TargetOptions.features`: added `+strict-align`. rationale: unaligned |
| 8 | +// memory access is disabled on boot on these cores |
| 9 | +// - linker changed to LLD. rationale: C is not strictly needed to build |
| 10 | +// bare-metal binaries (the `gcc` linker has the advantage that it knows where C |
| 11 | +// libraries and crt*.o are but it's not much of an advantage here); LLD is also |
| 12 | +// faster |
| 13 | +// - `target_os` set to `none`. rationale: matches `thumb` targets |
| 14 | +// - `target_{env,vendor}` set to an empty string. rationale: matches `thumb` |
| 15 | +// targets |
| 16 | +// - `panic_strategy` set to `abort`. rationale: matches `thumb` targets |
| 17 | +// - `relocation-model` set to `static`; also no PIE, no relro and no dynamic |
| 18 | +// linking. rationale: matches `thumb` targets |
| 19 | + |
| 20 | +use super::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions}; |
| 21 | + |
| 22 | +pub fn target() -> Result<Target, String> { |
| 23 | + let opts = TargetOptions { |
| 24 | + linker: Some("rust-lld".to_owned()), |
| 25 | + features: "+v7,+thumb2,+soft-float,-neon,+strict-align".to_string(), |
| 26 | + executables: true, |
| 27 | + relocation_model: "static".to_string(), |
| 28 | + disable_redzone: true, |
| 29 | + max_atomic_width: Some(64), |
| 30 | + panic_strategy: PanicStrategy::Abort, |
| 31 | + abi_blacklist: super::arm_base::abi_blacklist(), |
| 32 | + emit_debug_gdb_scripts: false, |
| 33 | + ..Default::default() |
| 34 | + }; |
| 35 | + Ok(Target { |
| 36 | + llvm_target: "armv7a-none-eabi".to_string(), |
| 37 | + target_endian: "little".to_string(), |
| 38 | + target_pointer_width: "32".to_string(), |
| 39 | + target_c_int_width: "32".to_string(), |
| 40 | + target_os: "none".to_string(), |
| 41 | + target_env: String::new(), |
| 42 | + target_vendor: String::new(), |
| 43 | + data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), |
| 44 | + arch: "arm".to_string(), |
| 45 | + linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), |
| 46 | + options: opts, |
| 47 | + }) |
| 48 | +} |
0 commit comments