I just figured out how to cross-compile Rust programs for Raspberry Pis running Rasbian Stretch. Host system is an amd64 laptop running Debian unstable.
Turns out I was using the wrong target all along. For reference, here's a
uname -a on the Pi:
Linux pi 4.9.41+ #1023 Tue Aug 8 15:47:12 BST 2017 armv6l GNU/Linux
apt-get install gcc-arm-linux-gnueabi g++-arm-linux-gnueabi
Without those packages installed, you'll run into "configure: error: C compiler cannot create executables".
Configure cargo to use the correct linker when invoking rustc. Put the following into
[target.arm-unknown-linux-gnueabi] linker = "arm-linux-gnueabi-gcc"
Without this, rustc will fill your console with "Relocations in generic ELF (EM: 40)" errors.
Install the toolchain:
rustup target add arm-unknown-linux-gnueabi
Cd into whatever project you'd like to build and run:
cargo build --target=arm-unknown-linux-gnueabi
You should now have a
target/arm-unknown-linux-gnueabi/debugdirectory which contains the binary you're looking for:
target/arm-unknown-linux-gnueabi/debug/netio: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.3, for GNU/Linux 3.2.0, BuildID[sha1]=823fc0735e12c488b313d820679e1b0006f90c3b, with debug_info, not stripped