ARM Cortex-M cross compiler


#1

Does anyone know what is required to get a ARM Thumbv7 Rust cross-compiler?

I’ve seen the Zinc project, so it’s obviously possible. However, the Zinc project seems to be tied to rust-nightly package for Ubuntu/Debian. I’m using Arch Linux, and when I try to build using the Rust compiler in the Arch Linux official repositories (rust-1.0.0.alpha-3) I get the following…

[cmd-prompt] rustc --target thumbv7em-none-eabi
error: 
Error loading target specification: 
Could not find specification for target "thumbv7em-none-eabi"

I’m therefore assuming the compiler that the Zinc project is using has been built with the LLVM thumb backend, but I’m really not sure.

So, does anyone know how to obtain/build a Rust ARM Thumb cross-compiler for Linux?

Thanks,
Mike


#2

I think I figured this out. See http://doc.rust-lang.org/rustc_back/target/.

If I add this json file to my project and compile with rustc --target=thumbv7em-none-eabi it seems to work.

Note to other users looking for this functionality: Learn the “flexible target specification” implementation.


#3

Both links you provided are 404. Could you update the link since this topic is really interesting.


#4

http://manishearth.github.io/rust-internals-docs/rustc_back/target/index.html

This should tell you how to write your own target spec


#5

The JSON file that I linked above can now be found here: https://github.com/hackndev/zinc/blob/master/thumbv7em-none-eabi.json

I also have a couple of examples prepared:

They were created quite a while ago, so I don’t know if they still compile, but they should serve as a low barrier to entry starting point for anyone wishing to pursue ARM Cortex-M programming in Rust.