From ee64b7113eb35e716f1661f5101701f9729d3e34 Mon Sep 17 00:00:00 2001 From: Adrian Calinescu Date: Sun, 25 Mar 2018 15:03:53 +0300 Subject: [PATCH 1/5] Added ARM hard float target (Raspberry Pi) --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 43bf2b6..10ee00e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,7 +50,8 @@ ENV PATH=/home/rust/.cargo/bin:/usr/local/musl/bin:/usr/local/sbin:/usr/local/bi # manually. RUN curl https://sh.rustup.rs -sSf | \ sh -s -- -y --default-toolchain $TOOLCHAIN && \ - rustup target add x86_64-unknown-linux-musl + rustup target add x86_64-unknown-linux-musl && \ + rustup target add armv7-unknown-linux-gnueabihf ADD cargo-config.toml /home/rust/.cargo/config # Set up a `git credentials` helper for using GH_USER and GH_TOKEN to access From 240bea532b0078e21df2c0ed97847c7620d96cde Mon Sep 17 00:00:00 2001 From: Adrian Calinescu Date: Sun, 25 Mar 2018 16:01:36 +0300 Subject: [PATCH 2/5] Added GCC ARM --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 10ee00e..32450d0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,6 +27,7 @@ RUN apt-get update && \ pkgconf \ sudo \ xutils-dev \ + gcc-4.7-multilib-arm-linux-gnueabihf \ && \ apt-get clean && rm -rf /var/lib/apt/lists/* && \ useradd rust --user-group --create-home --shell /bin/bash --groups sudo From 398f472430d7d0fc3fbf614a24531d9d1c4c521c Mon Sep 17 00:00:00 2001 From: Adrian Calinescu Date: Sun, 25 Mar 2018 16:22:02 +0300 Subject: [PATCH 3/5] Added armhf linker to cargo-config.toml --- cargo-config.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cargo-config.toml b/cargo-config.toml index 57fe63a..f621e4c 100644 --- a/cargo-config.toml +++ b/cargo-config.toml @@ -1,3 +1,6 @@ [build] # Target musl-libc by default when running Cargo. target = "x86_64-unknown-linux-musl" + +[target.arm-unknown-linux-gnueabihf] +linker = "arm-linux-gnueabihf-gcc-4.7" From d4ed7451867a7b43879e6eb276bd7b0657b22b61 Mon Sep 17 00:00:00 2001 From: Adrian Calinescu Date: Sun, 25 Mar 2018 16:48:44 +0300 Subject: [PATCH 4/5] Fix ARM linker ref --- cargo-config.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cargo-config.toml b/cargo-config.toml index f621e4c..6b7d5ca 100644 --- a/cargo-config.toml +++ b/cargo-config.toml @@ -2,5 +2,5 @@ # Target musl-libc by default when running Cargo. target = "x86_64-unknown-linux-musl" -[target.arm-unknown-linux-gnueabihf] +[target.armv7-unknown-linux-gnueabihf] linker = "arm-linux-gnueabihf-gcc-4.7" From 8fc88ff03a568e12563ffe76be79596e5c842b1b Mon Sep 17 00:00:00 2001 From: Adrian Calinescu Date: Sun, 25 Mar 2018 17:39:23 +0300 Subject: [PATCH 5/5] Added ARMhf build info to README --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 73c0c4e..c10a111 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,11 @@ alias rust-musl-builder='docker run --rm -it -v "$(pwd)":/home/rust/src ekidd/ru rust-musl-builder cargo build --release ``` +To target ARM hard float (Raspberry Pi): +```sh +rust-musl-builder cargo build --target=armv7-unknown-linux-gnueabihf --release +``` + This command assumes that `$(pwd)` is readable and writable by uid 1000, gid 1000. It will output binaries in `target/x86_64-unknown-linux-musl/release`. At the moment, it doesn't attempt to cache libraries between builds, so this is best reserved for making final release builds. ## Deploying your Rust application