]> git.lizzy.rs Git - rust.git/blob - src/librustc_target/spec/msp430_none_elf.rs
Auto merge of #68414 - michaelwoerister:share-drop-glue, r=alexcrichton
[rust.git] / src / librustc_target / spec / msp430_none_elf.rs
1 use crate::spec::{LinkerFlavor, PanicStrategy, Target, TargetOptions, TargetResult};
2
3 pub fn target() -> TargetResult {
4     Ok(Target {
5         llvm_target: "msp430-none-elf".to_string(),
6         target_endian: "little".to_string(),
7         target_pointer_width: "16".to_string(),
8         target_c_int_width: "16".to_string(),
9         data_layout: "e-m:e-p:16:16-i32:16-i64:16-f32:16-f64:16-a:8-n8:16-S16".to_string(),
10         arch: "msp430".to_string(),
11         target_os: "none".to_string(),
12         target_env: String::new(),
13         target_vendor: String::new(),
14         linker_flavor: LinkerFlavor::Gcc,
15
16         options: TargetOptions {
17             executables: true,
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: vec!["-mcpu=msp430".to_string()],
24             linker: Some("msp430-elf-gcc".to_string()),
25             no_integrated_as: true,
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: "static".to_string(),
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             ..Default::default()
61         },
62     })
63 }