warricksothr / RustBuild

Scripts and patches to auto build Rustc and Cargo on ARM
MIT License
104 stars 8 forks source link

RustBuild Twitter URL

Discontinued! ARM compatible libraries are now part of the standard build process for Rust. They can be downloaded here. Directions related to cross compiling can be found at rust-cross.

If you would like to compile your own version of rustc and rustlib on your ARM device, you can refer to petevine's fork.

Scripts and patches to auto build Rust and Cargo on an ARM machine

Unofficial build scripts and binaries for nightly Rust/Cargo on 'arm-unknown-linux-gnueabihf'

This repository contains the required setup/configuration/build scripts and patches for you to setup your own Rust compilation machine. Pre-built 'unofficial' Rust/Cargo binaries are listed below for those who do not want to run their own build machine or are unable to.

Binary Downloads

For those familiar with Jorge Aparicio's ruststrap project; the ARMv6 builds are incredibly similar to his documented process. They're built in a Raspbian container with glibc 2.13 and Clang 3.7. This means that they're compatible with ARMv6-armhf systems and up (Thanks to the requirement by ARM, that all newer ARM architectures are required to recognize and run old ARM architectures). So anyone with a Raspberry Pi running the Wheezy distribution of Raspbian should use those, even if it's the ARMv7 Raspberry Pi 2. However, if the Raspberry Pi 2 is running the newer Jessie distribution of Raspbian, that should be able to run the ARMv7 binaries as it meets the requirement of glibc >= 2.19.

Linking Service

I'm now running a simple linking service to direct to the latest versions available for download without having to go directly to dropbox. The repository links below will still work. However the new links are more convienient as they will update every 12 hours to point to the latest builds. RustBuild-Linker source

Note: 6 Week Rust Release Schedule

Every 6 weeks Rust will roll forward to a new release version. The linking service will automatically direct to the latest files as they become available. However, on the day of the release it will take the build server about 24 hours to catch up to the latest builds.

Architecture Releases Directory

ARMv7

(Built on Debian Jessie, with Clang 3.8.1 (3.5 before 2016/04/15), GLIBC 2.19-18, OpenSSL 1.2.0d static)

For ARMv7+ devices with linux and atleast GLIBC 2.19

(Including Raspberry Pi 2 running Raspbian Jessie (8))

Nightly

Beta

Stable

ARMv7 Direct Repository Links

Unofficial Nightly Binaries (1.10.0)

Unofficial Beta Binaries (1.9.0)

Unofficial Stable Binaries (1.8.0)

ARMv6-armhf

(Built on Raspbian with Clang 3.7 (October 7th+) or GCC 4.8 (September 29th-), GLIBC 2.13-38+rpi2+deb7u8, OpenSSL 1.2.0d static)

For ARMv6+ devices with linux and atleast GLIBC 2.13

For Raspberry Pi (A, A+, B, B+, 2) running Raspbian Wheezy (7)

Nightly

Beta

Stable

ARMv6-armhf Direct Repository Links

Unofficial Nightly Binaries (1.10.0)

Unofficial Beta Binaries (1.9.0)

Unofficial Stable Binaries (1.8.0)

Builds tested on:

Binary Install/Uninstall Instructions

Using the binary builds can be achieved in two ways. Ideally, using multirust to manage your rust binaries, or through manual linking on your system. I'm going to cover using multirust as that is the system I prefer to use. In this guide I will walk you through adding the latest nightly binary build to multirust. This can be adapted for the stable and beta builds simply.

Requirements:

Installation

# usermod -aG <group> <user>
# wget $LATEST_CARGO_TARBALL
# wget $LATEST_RUST_TARBALL
# tar xzf $LATEST_CARGO_TARBALL && rm $LATEST_CARGO_TARBALL
# tar xzf $LATEST_RUST_TARBALL && rm $LATEST_RUST_TARBALL
# chown -R root:<group> /opt/rust/nightly
# chmod -R 775 /opt/rust/nightly
# multirust update unofficial-nightly --link-local
# multirust default unofficial-nightly

Now you'll have a version of rust installed in a standard place. Other users could also link against it with only the last step.

If you'd prefer to install it only for your user, just use a directory in your home for deployment. Something like "~/opt/rust/nightly" would be fine.

Updating is as simple as entering the deployed directory, removing all the files and folders, and then perform steps 2-4 again. (Because we used --link-local multirust doesn't care that we've changed the files.)

Uninstallation

# rm -rf /opt/rust/nightly
# multirust remove-toolchain unofficial-nightly

Usage Instructions

Run # /bin/bash scripts/setup/debian_root_build.sh <name of container> to build a new container from scratch (in the default /chroots directory).

Then run # /bin/bash scripts/setup/debian_root_setup.sh <name of container> to download the required sources and do the initial setup of the filesystem for the container. This will start the container with systemd-nspawn and do the final configuration in the container, downloading the system tools required. During the process you will need to configure the dropbox_uploader utility. Follow the prompts when they appear.

Now you have a working container with the ability to build Rust/Cargo arm binaries. To kickstart the process, in the app folder you defined during the dropbox_upload setup, create a "snapshots" folder and copy the oldest snapshot from my snapshots folder to yours. This is essential for your first build process. After that you are entirely reliant on your own binaries. (Alternatively you can cross compile a stage-0 rust compiler on a host machine with your desired target and use that instead.)

In order to build a recent version of Rust, you'll need to first build an up to date snapshot, then compile the Rust binary, and finally create Cargo. (Cargo will require a previous version of cargo to compile) This can be achieved with the 3 following commands currently

Nightly

systemd-nspawn /chroots/<name of container> /bin/bash ~/build-snap.sh
systemd-nspawn /chroots/<name of container> /bin/bash ~/build-rust.sh
systemd-nspawn /chroots/<name of container> /bin/bash ~/build-cargo.sh

This will build the most recent nightly by first bootstrapping an older snapshot to build a newer snapshot, then compiling a new Rust from the new snapshot, finally building Cargo from the rustc and a previous version of Cargo. These will all be uploaded to the root directory of the app folder for immediate use.

Alternatively you can use the following to also build beta and stable releases

Beta

systemd-nspawn /chroots/<name of container> /bin/bash ~/build-snap.sh beta
systemd-nspawn /chroots/<name of container> /bin/bash ~/build-rust.sh beta
systemd-nspawn /chroots/<name of container> /bin/bash ~/build-cargo.sh beta

Stable

systemd-nspawn /chroots/<name of container> /bin/bash ~/build-snap.sh stable
systemd-nspawn /chroots/<name of container> /bin/bash ~/build-rust.sh stable
systemd-nspawn /chroots/<name of container> /bin/bash ~/build-cargo.sh stable

NOTE: The beta/stable tags on the cargo builder do not mean the beta/stable channels of Cargo. Cargo is currently sub 1.0.0 so there is nothing but the nightly branch. However the beta/stable tags mean to build cargo with the latest version of the beta/stable rust compiler and cargo (nightly cargo if no previous cargo exists). This means that the beta/stable version of Cargo should be less prone to issues over the nightly compiled Cargo.

More Information

I run this on a ODROID XU4 running the latest Arch linux and 3.10 HMP kernel with a 32GB eMMC. I have yet to have a memory failure on the eMMC, but it does get heavy usage, so I am considering a ramdrive as the ODROID XU4 has 2gb, and the Arch system + build container running barely reach 800MB during peak compilation.

A typical snapshot + rust + cargo build is about 8 hours with tests.

New snapshots do not need to be built often, so the actual build time for nightlies is closer to 3.5 hours.

The container with Rust/Cargo nightlies, a Rust snapshot, tools, file cache and the in progress compilation runs around 8GB

These scripts are configured to compile the snapshots and full Rust compilers with Clang for the improvement in build time over a slight reduction in runtime performance. (This may change as new versions of Clang are promoted to debian stable.)

Todo

License

All scripts/patches in this repository are licensed under the MIT license.

More information can be found in the LICENSE file in this directory

Acknowledgements

Inspired and built upon the excellent work of Jorge Aparicio's ruststrap