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