Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save morristech/6b612b4432f0f9432c9b4bdafda0f230 to your computer and use it in GitHub Desktop.

Select an option

Save morristech/6b612b4432f0f9432c9b4bdafda0f230 to your computer and use it in GitHub Desktop.
Bootstrap a working native aarch64-apple-darwin Rust toolchain
#!/bin/bash
# "Bash Strict Mode with logging"
set -eux -o pipefail
IFS=$'\n\t'
case $(uname -p) in
arm)
;;
*)
echo This has only been tested with a native ARM shell.
exit 1
;;
esac
if (file $(which rustup) | grep "arm64"); then
exit 0
fi
# Adapted from
# https://github.com/rust-lang/rustup/issues/2413#issuecomment-729140037
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | arch --x86_64 sh -s -- \
-y \
--default-host aarch64-apple-darwin \
--default-toolchain nightly-2020-11-18
rustup_tempdir=$(mktemp -d)
pushd $rustup_tempdir
source ~/.cargo/env
# Adapted from
# https://github.com/rust-lang/rustup/issues/2413#issuecomment-729173518 and
# https://github.com/rust-lang/rustup/issues/2413#issuecomment-729216870
git clone https://github.com/rust-lang/rustup/ .
git checkout 5674652a45ecf9066128df32fbc51e965586e4b2
RUSTC=$(rustup which rustc) $(rustup which cargo) build
RUSTC=$(rustup which rustc) $(rustup which cargo) dev-install
popd
rm -Rf $rustup_tempdir
if ! (file $(which rustup) | grep -q "arm64"); then
echo rustup did not get converted to ARM64 for some reason.
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment