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.
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.
11 use spec::{LinkerFlavor, PanicStrategy, Target, TargetOptions, TargetResult};
13 pub fn target() -> TargetResult {
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: String::new(),
23 target_vendor: String::new(),
24 linker_flavor: LinkerFlavor::Gcc,
26 options: TargetOptions {
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,
37 // There are no atomic CAS instructions available in the MSP430
38 // instruction set, and the LLVM backend doesn't currently support
39 // compiler fences so the Atomic* API is missing on this target.
40 // When the LLVM backend gains support for compile fences uncomment
41 // the `singlethread: true` line and set `max_atomic_width` to
43 max_atomic_width: Some(0),
45 // singlethread: true,
47 // Because these devices have very little resources having an
48 // unwinder is too onerous so we default to "abort" because the
49 // "unwind" strategy is very rare.
50 panic_strategy: PanicStrategy::Abort,
52 // Similarly, one almost always never wants to use relocatable
53 // code because of the extra costs it involves.
54 relocation_model: "static".to_string(),
56 // Right now we invoke an external assembler and this isn't
57 // compatible with multiple codegen units, and plus we probably
58 // don't want to invoke that many gcc instances.
59 default_codegen_units: Some(1),
61 // Since MSP430 doesn't meaningfully support faulting on illegal
62 // instructions, LLVM generates a call to abort() function instead
63 // of a trap instruction. Such calls are 4 bytes long, and that is
64 // too much overhead for such small target.
65 trap_unreachable: false,
67 // See the thumb_base.rs file for an explanation of this value
68 emit_debug_gdb_scripts: false,
70 .. Default::default( )