1#!/bin/bash 2 3# Note that this script is not actually "building" rust, but build- is the 4# convention for the shared helpers for putting stuff in our containers. 5 6set -ex 7 8uncollapsed_section_start rust "Building Rust toolchain" 9 10# cargo (and rustup) wants to store stuff in $HOME/.cargo, and binaries in 11# $HOME/.cargo/bin. Make bin a link to a public bin directory so the commands 12# are just available to all build jobs. 13mkdir -p "$HOME"/.cargo 14ln -s /usr/local/bin "$HOME"/.cargo/bin 15 16# Pick a specific snapshot from rustup so the compiler doesn't drift on us. 17RUST_VERSION=1.78.0-2024-05-02 18 19# For rust in Mesa, we use rustup to install. This lets us pick an arbitrary 20# version of the compiler, rather than whatever the container's Debian comes 21# with. 22curl -L --retry 4 -f --retry-all-errors --retry-delay 60 \ 23 --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- \ 24 --default-toolchain $RUST_VERSION \ 25 --profile minimal \ 26 -y 27 28rustup component add clippy rustfmt 29 30# Set up a config script for cross compiling -- cargo needs your system cc for 31# linking in cross builds, but doesn't know what you want to use for system cc. 32cat > /root/.cargo/config <<EOF 33[target.armv7-unknown-linux-gnueabihf] 34linker = "arm-linux-gnueabihf-gcc" 35 36[target.aarch64-unknown-linux-gnu] 37linker = "aarch64-linux-gnu-gcc" 38EOF 39 40section_end rust 41