Skip to content

Commit

Permalink
auto merge of #11700 : bharrisau/rust/thumb, r=alexcrichton
Browse files Browse the repository at this point in the history
To build for the cortex-M series ARM processors LLC needs to be told to build for the thumb instruction set. There are two ways to do this, either with the triple "thumb\*-\*-\*" or with -march=thumb (which just overrides the triple anyway). I chose the first way.

The following will fail because the local cc doesn't know what to do with -mthumb.
````
rustc test.rs --lib --target thumb-linux-eab
error: linking with `cc` failed: exit code: 1
note: cc: error: unrecognized command line option ‘-mthumb’
````

Changing the linker works as expected.
````
rustc test.rs --lib --target thumb-linux-eabi --linker arm-none-eabi-gcc
````

Ideally I'd have the triple thumb-none-eabi, but adding a new OS looks like much more work (and I'm not familiar enough with what it does to know if it is needed).
  • Loading branch information
bors committed Jan 21, 2014
2 parents 232d8e5 + 50d0e07 commit 505572b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/librustc/back/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ use metadata::loader::meta_section_name;
use syntax::abi;

pub fn get_target_strs(target_triple: ~str, target_os: abi::Os) -> target_strs::t {
let cc_args = if target_triple.contains("thumb") {
~[~"-mthumb"]
} else {
~[~"-marm"]
};
return target_strs::t {
module_asm: ~"",

Expand Down Expand Up @@ -63,6 +68,6 @@ pub fn get_target_strs(target_triple: ~str, target_os: abi::Os) -> target_strs::

target_triple: target_triple,

cc_args: ~[~"-marm"],
cc_args: cc_args,
};
}
1 change: 1 addition & 0 deletions src/librustc/driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,7 @@ static architecture_abis : &'static [(&'static str, abi::Architecture)] = &'stat

("arm", abi::Arm),
("xscale", abi::Arm),
("thumb", abi::Arm),

("mips", abi::Mips)];

Expand Down

0 comments on commit 505572b

Please sign in to comment.