rustc_target/spec/base/
arm_none.rs

1// These are the baseline settings for 32-bit bare-metal Arm targets using the EABI or EABIHF ABI.
2
3use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, PanicStrategy, RelocModel, TargetOptions};
4
5pub(crate) fn opts() -> TargetOptions {
6    // See rust-lang/rfcs#1645 for a discussion about these defaults
7    TargetOptions {
8        linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
9        // In most cases, LLD is good enough
10        linker: Some("rust-lld".into()),
11        // Because these devices have very little resources having an unwinder is too onerous so we
12        // default to "abort" because the "unwind" strategy is very rare.
13        panic_strategy: PanicStrategy::Abort,
14        // Similarly, one almost always never wants to use relocatable code because of the extra
15        // costs it involves.
16        relocation_model: RelocModel::Static,
17        // When this section is added a volatile load to its start address is also generated. This
18        // volatile load is a footgun as it can end up loading an invalid memory address, depending
19        // on how the user set up their linker scripts. This section adds pretty printer for stuff
20        // like std::Vec, which is not that used in no-std context, so it's best to left it out
21        // until we figure a way to add the pretty printers without requiring a volatile load cf.
22        // rust-lang/rust#44993.
23        emit_debug_gdb_scripts: false,
24        // LLVM is eager to trash the link register when calling `noreturn` functions, which
25        // breaks debugging. Preserve LR by default to prevent that from happening.
26        frame_pointer: FramePointer::Always,
27        // ARM supports multiple ABIs for enums, the linux one matches the default of 32 here
28        // but any arm-none or thumb-none target will be defaulted to 8 on GCC.
29        c_enum_min_bits: Some(8),
30        ..Default::default()
31    }
32}