Last active
March 22, 2022 12:05
-
-
Save pepyakin/2ff227c2d837a2eacd8d3879d5e0c94f to your computer and use it in GitHub Desktop.
Substrate Raspberry PI cross-compile build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Run this script from the directory with the Cargo project. | |
docker run --rm -it \ | |
--env BINDGEN_EXTRA_CLANG_ARGS="--sysroot=/usr/arm-linux-gnueabihf -D__ARM_PCS_VFP -mfpu=vfp -mfloat-abi=hard" \ | |
--env CARGO_HOME=/home/rust/src/cargo_home \ | |
-v "$(pwd)":/home/rust/src <containter id> \ | |
cargo build --target=armv7-unknown-linux-gnueabihf --release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Put this file in the root of substrate / polkadot directory and build the image using | |
# the following command: | |
# | |
# docker build -t <container id> . | |
# | |
# you can pick <container id> yourself. For example: `johndoe/rpi-cross`. | |
# | |
FROM rust:latest | |
RUN dpkg --add-architecture armhf && \ | |
apt-get update && apt-get upgrade -y && \ | |
apt-get install -y aptitude && \ | |
aptitude install -y \ | |
gcc-arm-linux-gnueabihf \ | |
g++-arm-linux-gnueabihf \ | |
pkg-config \ | |
cmake \ | |
libssl-dev \ | |
git \ | |
clang \ | |
libclang-dev \ | |
libssl-dev:armhf | |
# Install nightly with w32-u-u and add arvm7 to stable | |
RUN rustup target add armv7-unknown-linux-gnueabihf | |
RUN rustup install nightly && \ | |
rustup target add wasm32-unknown-unknown --toolchain nightly &&\ | |
cargo +nightly install --git https://github.com/alexcrichton/wasm-gc --force | |
ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER arm-linux-gnueabihf-gcc | |
ENV PKG_CONFIG_ALLOW_CROSS 1 | |
ENV PKG_CONFIG_PATH /usr/lib/arm-linux-gnueabihf/pkgconfig/ | |
# Disallow the `pkg-config` crate to look for the config for zlib, because build.rs of `libz-sys` | |
# gets confused and pulls the system-wide library (i.e. of the host) instead of the target when | |
# cross-compiling. This essentially leads to static linking of zlib. | |
# | |
# Alternatively, we can supply LIBZ_SYS_STATIC=1. Weirdly enough, installing libgtk-3-dev:armhf | |
# also solves the problem somehow. | |
# | |
# Here is the related issue: https://github.com/rust-lang/libz-sys/issues/49 | |
ENV ZLIB_NO_PKG_CONFIG 1 | |
# This is for compiling GUI apps. | |
# RUN aptitude install -y libasound2-dev:armhf libgtk-3-dev:armhf libsdl2-dev:armhf | |
RUN useradd rust --user-group --create-home --shell /bin/bash --groups sudo | |
WORKDIR /home/rust/src |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Get this error while trying to compile:
I read on other places on the internet that wasmtime-runtime can't be compiled for arm, but they don't say either that substrate can't be compiled for arm so I don't really understand did you have this problem ?