Skip to content

Commit

Permalink
rust: ship 1.49.0-beta on ARM
Browse files Browse the repository at this point in the history
Closes #67535
  • Loading branch information
Mushroom authored and fxcoudert committed Dec 25, 2020
1 parent c9ac1ba commit 467c932
Showing 1 changed file with 36 additions and 14 deletions.
50 changes: 36 additions & 14 deletions Formula/rust.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 467c932

Please sign in to comment.