Created
November 20, 2020 22:51
-
-
Save briansmith/dd06e8dfeac46d1032d974000dac1fa6 to your computer and use it in GitHub Desktop.
Bootstrap a working native aarch64-apple-darwin Rust toolchain
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 | |
# "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
The above is no longer necessary.
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain nightly-2020-11-25
worked for me today. See https://blog.rust-lang.org/2020/11/27/Rustup-1.23.0.html#support-for-apple-m1-devices for more info. (Today's Rust Nightly is broken because of briansmith/ring#1130; tomorrow's should work.)