Skip to content

Commit 505572b

Browse files
committed
auto merge of #11700 : bharrisau/rust/thumb, r=alexcrichton
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).
2 parents 232d8e5 + 50d0e07 commit 505572b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/librustc/back/arm.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ use metadata::loader::meta_section_name;
1414
use syntax::abi;
1515

1616
pub fn get_target_strs(target_triple: ~str, target_os: abi::Os) -> target_strs::t {
17+
let cc_args = if target_triple.contains("thumb") {
18+
~[~"-mthumb"]
19+
} else {
20+
~[~"-marm"]
21+
};
1722
return target_strs::t {
1823
module_asm: ~"",
1924

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

6469
target_triple: target_triple,
6570

66-
cc_args: ~[~"-marm"],
71+
cc_args: cc_args,
6772
};
6873
}

src/librustc/driver/driver.rs

+1
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,7 @@ static architecture_abis : &'static [(&'static str, abi::Architecture)] = &'stat
661661

662662
("arm", abi::Arm),
663663
("xscale", abi::Arm),
664+
("thumb", abi::Arm),
664665

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

0 commit comments

Comments
 (0)