]>
git.proxmox.com Git - rustc.git/blob - src/librustc_back/target/thumb_base.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.
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 // These 4 `thumbv*` targets cover the ARM Cortex-M family of processors which are widely used in
12 // microcontrollers. Namely, all these processors:
21 // We have opted for 4 targets instead of one target per processor (e.g. `cortex-m0`, `cortex-m3`,
22 // etc) because the differences between some processors like the cortex-m0 and cortex-m1 are almost
23 // non-existent from the POV of codegen so it doesn't make sense to have separate targets for them.
24 // And if differences exist between two processors under the same target, rustc flags can be used to
25 // optimize for one processor or the other.
27 // Also, we have not chosen a single target (`arm-none-eabi`) like GCC does because this makes
28 // difficult to integrate Rust code and C code. Targeting the Cortex-M4 requires different gcc flags
29 // than the ones you would use for the Cortex-M0 and with a single target it'd be impossible to
30 // differentiate one processor from the other.
32 // About arm vs thumb in the name. The Cortex-M devices only support the Thumb instruction set,
33 // which is more compact (higher code density), and not the ARM instruction set. That's why LLVM
34 // triples use thumb instead of arm. We follow suit because having thumb in the name let us
35 // differentiate these targets from our other `arm(v7)-*-*-gnueabi(hf)` targets in the context of
36 // build scripts / gcc flags.
39 use std
::default::Default
;
40 use target
::TargetOptions
;
42 pub fn opts() -> TargetOptions
{
43 // See rust-lang/rfcs#1645 for a discussion about these defaults
46 // In 99%+ of cases, we want to use the `arm-none-eabi-gcc` compiler (there aren't many
48 linker
: "arm-none-eabi-gcc".to_string(),
49 // Because these devices have very little resources having an unwinder is too onerous so we
50 // default to "abort" because the "unwind" strategy is very rare.
51 panic_strategy
: PanicStrategy
::Abort
,
52 // Similarly, one almost always never wants to use relocatable code because of the extra
54 relocation_model
: "static".to_string(),
55 abi_blacklist
: super::arm_base
::abi_blacklist(),