rustc_target/spec/targets/
msp430_none_elf.rs

1use crate::spec::{Cc, LinkerFlavor, PanicStrategy, RelocModel, Target, TargetOptions, cvs};
2
3pub(crate) fn target() -> Target {
4    Target {
5        llvm_target: "msp430-none-elf".into(),
6        metadata: crate::spec::TargetMetadata {
7            description: Some("16-bit MSP430 microcontrollers".into()),
8            tier: Some(3),
9            host_tools: Some(false),
10            std: Some(false),
11        },
12        pointer_width: 16,
13        data_layout: "e-m:e-p:16:16-i32:16-i64:16-f32:16-f64:16-a:8-n8:16-S16".into(),
14        arch: "msp430".into(),
15
16        options: TargetOptions {
17            c_int_width: "16".into(),
18
19            // The LLVM backend currently can't generate object files. To
20            // workaround this LLVM generates assembly files which then we feed
21            // to gcc to get object files. For this reason we have a hard
22            // dependency on this specific gcc.
23            asm_args: cvs!["-mcpu=msp430"],
24            linker: Some("msp430-elf-gcc".into()),
25            linker_flavor: LinkerFlavor::Unix(Cc::Yes),
26
27            // There are no atomic CAS instructions available in the MSP430
28            // instruction set, and the LLVM backend doesn't currently support
29            // compiler fences so the Atomic* API is missing on this target.
30            // When the LLVM backend gains support for compile fences uncomment
31            // the `singlethread: true` line and set `max_atomic_width` to
32            // `Some(16)`.
33            max_atomic_width: Some(0),
34            atomic_cas: false,
35            // singlethread: true,
36
37            // Because these devices have very little resources having an
38            // unwinder is too onerous so we default to "abort" because the
39            // "unwind" strategy is very rare.
40            panic_strategy: PanicStrategy::Abort,
41
42            // Similarly, one almost always never wants to use relocatable
43            // code because of the extra costs it involves.
44            relocation_model: RelocModel::Static,
45
46            // Right now we invoke an external assembler and this isn't
47            // compatible with multiple codegen units, and plus we probably
48            // don't want to invoke that many gcc instances.
49            default_codegen_units: Some(1),
50
51            // Since MSP430 doesn't meaningfully support faulting on illegal
52            // instructions, LLVM generates a call to abort() function instead
53            // of a trap instruction. Such calls are 4 bytes long, and that is
54            // too much overhead for such small target.
55            trap_unreachable: false,
56
57            // See the thumb_base.rs file for an explanation of this value
58            emit_debug_gdb_scripts: false,
59
60            eh_frame_header: false,
61
62            ..Default::default()
63        },
64    }
65}