]> git.lizzy.rs Git - rust.git/blob - src/librustc_target/spec/msp430_none_elf.rs
#[cfg(target_has_atomic_cas)] -> #[cfg(target_has_atomic = "cas")]
[rust.git] / src / librustc_target / spec / msp430_none_elf.rs
1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 use spec::{LinkerFlavor, PanicStrategy, Target, TargetOptions, TargetResult};
12
13 pub fn target() -> TargetResult {
14     Ok(Target {
15         llvm_target: "msp430-none-elf".to_string(),
16         target_endian: "little".to_string(),
17         target_pointer_width: "16".to_string(),
18         target_c_int_width: "16".to_string(),
19         data_layout: "e-m:e-p:16:16-i32:16-i64:16-f32:16-f64:16-a:8-n8:16-S16".to_string(),
20         arch: "msp430".to_string(),
21         target_os: "none".to_string(),
22         target_env: "".to_string(),
23         target_vendor: "".to_string(),
24         linker_flavor: LinkerFlavor::Gcc,
25
26         options: TargetOptions {
27             executables: true,
28
29             // The LLVM backend currently can't generate object files. To
30             // workaround this LLVM generates assembly files which then we feed
31             // to gcc to get object files. For this reason we have a hard
32             // dependency on this specific gcc.
33             asm_args: vec!["-mcpu=msp430".to_string()],
34             linker: Some("msp430-elf-gcc".to_string()),
35             no_integrated_as: true,
36
37             // There are no atomic CAS instructions available in the MSP430
38             // instruction set
39             max_atomic_width: Some(16),
40             atomic_cas: false,
41
42             // Because these devices have very little resources having an
43             // unwinder is too onerous so we default to "abort" because the
44             // "unwind" strategy is very rare.
45             panic_strategy: PanicStrategy::Abort,
46
47             // Similarly, one almost always never wants to use relocatable
48             // code because of the extra costs it involves.
49             relocation_model: "static".to_string(),
50
51             // Right now we invoke an external assembler and this isn't
52             // compatible with multiple codegen units, and plus we probably
53             // don't want to invoke that many gcc instances.
54             default_codegen_units: Some(1),
55
56             // Since MSP430 doesn't meaningfully support faulting on illegal
57             // instructions, LLVM generates a call to abort() function instead
58             // of a trap instruction. Such calls are 4 bytes long, and that is
59             // too much overhead for such small target.
60             trap_unreachable: false,
61
62             // See the thumb_base.rs file for an explanation of this value
63             emit_debug_gdb_scripts: false,
64
65             .. Default::default( )
66         }
67     })
68 }