From 467c93255f5abd4d6c9cb500b45ff4e9b67ea5fc Mon Sep 17 00:00:00 2001 From: Mushroom Date: Wed, 23 Dec 2020 17:44:20 +0000 Subject: [PATCH] rust: ship 1.49.0-beta on ARM Closes #67535 --- Formula/rust.rb | 50 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/Formula/rust.rb b/Formula/rust.rb index 64d42a594ede5..0a3b6ae86dc8b 100644 --- a/Formula/rust.rb +++ b/Formula/rust.rb @@ -4,8 +4,14 @@ class Rust < Formula license any_of: ["Apache-2.0", "MIT"] stable do - url "https://static.rust-lang.org/dist/rustc-1.48.0-src.tar.gz" - sha256 "0e763e6db47d5d6f91583284d2f989eacc49b84794d1443355b85c58d67ae43b" + if Hardware::CPU.arm? + url "https://static.rust-lang.org/dist/rustc-beta-src.tar.gz#1.49.0-beta" + sha256 "364fc8350d30f104595e458e51599369ffc5f796bb91b893372ba2631229963e" + version "1.48.0" + else + url "https://static.rust-lang.org/dist/rustc-1.48.0-src.tar.gz" + sha256 "0e763e6db47d5d6f91583284d2f989eacc49b84794d1443355b85c58d67ae43b" + end resource "cargo" do url "https://github.com/rust-lang/cargo.git", @@ -42,8 +48,13 @@ class Rust < Formula resource "cargobootstrap" do on_macos do # From https://github.com/rust-lang/rust/blob/#{version}/src/stage0.txt - url "https://static.rust-lang.org/dist/2020-11-19/cargo-1.48.0-x86_64-apple-darwin.tar.gz" - sha256 "ce00d796cf5a9ac8d88d9df94c408e5d7ccd3541932a829eae833cc8e57efb15" + if Hardware::CPU.arch == :arm64 + url "https://static.rust-lang.org/dist/2020-12-23/cargo-beta-aarch64-apple-darwin.tar.gz" + sha256 "efbc0e72533d4ca7def9a985feef4b3e43d24f1f6792815bdba9125af1f8ecdf" + else + url "https://static.rust-lang.org/dist/2020-11-19/cargo-1.48.0-x86_64-apple-darwin.tar.gz" + sha256 "ce00d796cf5a9ac8d88d9df94c408e5d7ccd3541932a829eae833cc8e57efb15" + end end on_linux do @@ -78,17 +89,15 @@ def install else args << "--release-channel=stable" end - # Cross-compile arm64 with x86_64 bootstrap compiler. - if Hardware::CPU.arch == :arm64 - args << "--build=x86_64-apple-darwin" - args << "--host=aarch64-apple-darwin" - args << "--target=aarch64-apple-darwin" - system "./configure", *args - system "arch", "-x86_64", "make" - else - system "./configure", *args - system "make" + + if Hardware::CPU.arm? + # Fix for 1.49.0-beta, remove when the stable version is released + inreplace "src/stage0.txt", "1.48.0", "beta" + inreplace "src/stage0.txt", "2020-11-19", "2020-12-23" end + + system "./configure", *args + system "make" system "make", "install" resource("cargobootstrap").stage do @@ -117,6 +126,19 @@ def post_install end end + def caveats + s = "" + + if Hardware::CPU.arm? + s += <<~EOS + This is a beta version of the Rust compiler for Apple Silicon + (rust 1.49.0-beta). + EOS + end + + s + end + test do system "#{bin}/rustdoc", "-h" (testpath/"hello.rs").write <<~EOS