I'm particularly interested in using Rust for creating some software that will run on ARM processors, therefore, I would like to learn how compatible is Rust at the moment with ARM? And whether there is already a roadmap for improvements?
Yes! There's even prebuilt arm toolchains available on github. I've built a project for raspberry pi (the armv6hf version) using them. With a bit of extra effort, you can even cross compile so you don't need to deal with slow build times :).
Bonus question for smarter people than I:
Rust uses the LLVM as its back end for compilation -- so does that make this question irrelevant? Is the real question "Can the LLVM backend target ARM?"
Videos
A match “arm” is simply one of the cases of the match. The arm consists of a pattern to match against, followed by =>, followed by the value to produce if the pattern matches.
“Arm’s pattern” here simply means the pattern for that particular arm. For example, in the match expression
let x = 1;
match x {
1 => println!("one"),
2 => println!("two"),
3 => println!("three"),
_ => println!("anything"),
}
there are four arms, with patterns 1, 2, 3 and _ (match anything) respectively.
The "arms pattern" is the pattern (plain english word) that belongs to the arm (each case for the match statement is called an arm, as is common for branching statements). It is not a pattern as in the "design patterns" buzzword.
The thing that should match to select a specific arm is called a pattern (rather than, say, a value) as it is not limited to static values, but can, thanks to the expressivenes of the rust type system, describe parts of the value while selecting other parts for use in the pattern.
Here's an example where the thing to match is a tuple:
match (price_in_cents / 100, price_in_cents % 100) {
(d, 0) => format!("{d} dollar"),
(0, c) => format!("{c} cents"),
(d, c) => format!("{d}:{c}"),
}
Note that order is important here, if I would have put the last arm first it would match any value (and the compiler would warn that the other arms are unreachable).
Note that _ in the example from @nneonneo s example is not a magic symbol to match anything, it is a declaration of a variable to put any value in. The only thing special is that the name _ implies that you are not going to use it. You can say x with the same result, except that the compiler will warn about you declaring a variable x and then not using it.
Thanks to @Notlikethat's comment:
a) Yes you need to provide your own GCC cross-compiler.
b) You can get one here (select a mingw32 build).
Just unzip linaro's GCC then point cargo to it:
[target.armv7-unknown-linux-gnueabihf]
linker = "C:/Users/me/gcc-linaro-5.3.1-2016.05-i686-mingw32_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc.exe"
It seems to work even though it is arm- and not armv7-. I guess linking doesn't depend on the ISA. Actually I haven't run it yet, but it builds without errors!
Edit:
You can now use armv7-unknown-linux-musleabihf instead and get an actually portable binary (i.e. it doesn't depend on the GNU C library which often causes compatibility issues).
For MacOS better use: musleabihf, for Windows you can use gnueabihf as bellow:
Mac
$ brew install arm-linux-gnueabihf-binutils
$ rustup target add armv7-unknown-linux-musleabihf
In .cargo/config
[build]
target = "armv7-unknown-linux-musleabihf"
[target.armv7-unknown-linux-c]
linker = "arm-linux-gnueabihf-ld"
With simple src/main.rs
fn main() {
println!("Hello, Raspberry!");
}
Then things are fine:
Hasans-Air:rpi hasan$ cargo build
Compiling rpi v0.1.0 (/Users/hasan/PycharmProjects/rpi)
Finished dev [unoptimized + debuginfo] target(s) in 0.41s
Hasans-Air:rpi hasan$ scp target/armv7-unknown-linux-musleabihf/debug/rpi [email protected]:
[email protected]'s password:
rpi 100% 2702KB 2.6MB/s 00:01
Hasans-Air:rpi hasan$ ssh [email protected] 'chmod +x ~/rpi && ~/rpi'
[email protected]'s password:
Hello, Raspberry!
Win 10 Get the linker from here, and run:
rustup target add armv7-unknown-linux-gnueabihf
Creating file .cargo/config with content:
[build]
target = "armv7-unknown-linux-gnueabihf"
[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"
And with simple src/main.rs:
fn main() {
println!("Hello, Raspberry! from Win 10");
}
I was able to get things done

