So I thought it might be fun to compile a "Hello, world" app on my Mac (OSX 10.12.3) to run on Raspberry Pi 3 (Raspbian 8, Linux Kernel 4.4).
Long story short, I decided the promise of steed
(to "achieve truly hassle free cross compilation from any system (macOS, Windows, *BSD, etc.) to any Linux system, be it x86 or ARM hardware.") could be worth investing in, but I first needed to build it.
So, I started with
$ cargo new --bin hello && cd hello
Then, following steed
's directions for my system:
$ cargo install xargo
$ curl -OL https://github.com/japaric/steed/raw/master/docker/armv7-unknown-linux-steedeabihf.json
$ export RUST_TARGET_PATH=$(pwd)
$ edit Xargo.toml && cat $_
[dependencies.collections] # `steed` depends on collections
[dependencies.rand] # and rand
[dependencies.std]
git = "https://github.com/japaric/steed" # `path` works too
stage = 1
$ xargo run --target armv7-unknown-linux-steedeabihf
This last gives an error:
Compiling hello v0.1.0 (file:///Users/bRad/Development/toolchains/rust/hello)
error: linking with `cc` failed: exit code: 1
|
= note: "cc" "-Wl,--as-needed" "-Wl,--build-id=none" "-Wl,-z,noexecstack" "-nostartfiles" "-static" "-L" "/Users/bRad/.xargo/lib/rustlib/armv7-unknown-linux-steedeabihf/lib" "/Users/bRad/Development/toolchains/rust/hello/target/armv7-unknown-linux-steedeabihf/debug/deps/hello-0991cfa18062d722.0.o" "-o" "/Users/bRad/Development/toolchains/rust/hello/target/armv7-unknown-linux-steedeabihf/debug/deps/hello-0991cfa18062d722" "-Wl,--gc-sections" "-nodefaultlibs" "-L" "/Users/bRad/Development/toolchains/rust/hello/target/armv7-unknown-linux-steedeabihf/debug/deps" "-L" "/Users/bRad/Development/toolchains/rust/hello/target/debug/deps" "-L" "/Users/bRad/.xargo/lib/rustlib/armv7-unknown-linux-steedeabihf/lib" "-Wl,-Bstatic" "-Wl,-Bdynamic" "/Users/bRad/.xargo/lib/rustlib/armv7-unknown-linux-steedeabihf/lib/libstd-bb40cc9c3579a09c.rlib" "/Users/bRad/.xargo/lib/rustlib/armv7-unknown-linux-steedeabihf/lib/libcollections-ea247e9941d76447.rlib" "/Users/bRad/.xargo/lib/rustlib/armv7-unknown-linux-steedeabihf/lib/liballoc-8822446a17c83f7f.rlib" "/Users/bRad/.xargo/lib/rustlib/armv7-unknown-linux-steedeabihf/lib/libralloc-214b72e3110676fc.rlib" "/Users/bRad/.xargo/lib/rustlib/armv7-unknown-linux-steedeabihf/lib/librand-8fa86f69e7373826.rlib" "/Users/bRad/.xargo/lib/rustlib/armv7-unknown-linux-steedeabihf/lib/libstd_unicode-804e7337c69564ad.rlib" "/Users/bRad/.xargo/lib/rustlib/armv7-unknown-linux-steedeabihf/lib/libralloc_shim-094a5847d31d0a1d.rlib" "/Users/bRad/.xargo/lib/rustlib/armv7-unknown-linux-steedeabihf/lib/libsc-979258bc38534d78.rlib" "/Users/bRad/.xargo/lib/rustlib/armv7-unknown-linux-steedeabihf/lib/libcore-89b19dcb9372380f.rlib" "/Users/bRad/.xargo/lib/rustlib/armv7-unknown-linux-steedeabihf/lib/libcompiler_builtins-1f18d4142a8b01da.rlib"
= note: ld: unknown option: --as-needed
collect2: error: ld returned 1 exit status
error: aborting due to previous error
error: Could not compile `hello`.
To learn more, run the command again with --verbose.
###Notes:
- I have Clang 4.0.0, GCC 6.3.0 and Apple's Clang 8.0.0 (aka Clang v3.9) installed on my system. I've set
cc
to each of them and gotten the same error each time. -
ld
invokes Apple's linker. I downloaded and built the GNU linker from binuitls (ld-new -v
yieldsGNU ld (GNU Binutils) 2.27
), and configured xargo to use it by creating a.cargo/config
file with the following:
[target.armv7-unknown-linux-steedeabihf]
linker = "/Users/bRad/Development/toolchains/binutils-2.27/build/ld/ld-new"
Unfortunately, this also yielded the same result.
Any advice on how to get through what looks like steed's final build step? This is my third approach over as many days trying to cross-compile for RPi3. I'd be grateful for any advice you might have. Thanks in advance!