• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
8# cargo (and rustup) wants to store stuff in $HOME/.cargo, and binaries in
9# $HOME/.cargo/bin.  Make bin a link to a public bin directory so the commands
10# are just available to all build jobs.
11mkdir -p "$HOME"/.cargo
12ln -s /usr/local/bin "$HOME"/.cargo/bin
13
14# Rusticl requires at least Rust 1.66.0 and NAK requires 1.73.0
15#
16# Also, pick a specific snapshot from rustup so the compiler doesn't drift on
17# us.
18RUST_VERSION=1.73.0-2023-10-05
19
20# For rust in Mesa, we use rustup to install.  This lets us pick an arbitrary
21# version of the compiler, rather than whatever the container's Debian comes
22# with.
23curl -L --retry 4 -f --retry-all-errors --retry-delay 60 \
24    --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- \
25      --default-toolchain $RUST_VERSION \
26      --profile minimal \
27      -y
28
29rustup component add clippy rustfmt
30
31# Set up a config script for cross compiling -- cargo needs your system cc for
32# linking in cross builds, but doesn't know what you want to use for system cc.
33cat > /root/.cargo/config <<EOF
34[target.armv7-unknown-linux-gnueabihf]
35linker = "arm-linux-gnueabihf-gcc"
36
37[target.aarch64-unknown-linux-gnu]
38linker = "aarch64-linux-gnu-gcc"
39EOF
40