Location to store Rust binaries

mcalhoun at macports.org mcalhoun at macports.org
Thu Dec 22 13:31:49 UTC 2022


I am sure everyone who cares about Rust is already familiar with the issues involved, but just for the sake of documentation, I will try to provide an overview.
The main issue is that a Rust compiler is required to build a Rust compiler.

On an Apple silicon machine running macOS 13, the Rust Portfile version 1.66 downloads
    rustc-1.65.0-aarch64-apple-darwin.tar.gz,
    rust-std-1.65.0-aarch64-apple-darwin.tar.gz, and
    cargo-1.65.0-aarch64-apple-darwin.tar.gz.
These are prebuilt binaries of the previous version (1.65) of the Rust compiler, Rust standard library, and Rust package manager respectively.
Upstream provides these prebuilt binaries for many different architectures [1].
This “stage0 compiler” is then used to build a local copy of Rust [2].

The problem is that the upstream binaries will only run on macOS 10.9+.
Upstream says 10.7+, but that is just the language [3].
The combination of the language, standard library, and package manager make the minimum higher [4][5].
Also, there is a proposal to set the minimum supported version to 10.12 [6].

So the question is how to get a working stage0 Rust compiler on older systems?
*) The alternative Rust compilers gccrs is still “in a very early stage” [7].
*) Mutabah's Rust Compiler (mrustc) is a Rust compiler written in C++ [8], so it may be a viable choice.
    However mrustc can build Rust up to 1.55, so, as pointed out by Kirill in another thread [10], the dependency chain could get quite long.
    If possible, it would be nice to avoid a similar issue with Clang [11].
*) There does not seem to be much enthusiasm upstream for re-adding support for older systems [6][12].
*) Previous versions of the Rust Portfile tried to modify the upstream binaries to work on older systems [13].
    This strategy certainly worked but could only go so far.

The current strategy is to build our own stag0 compiler in the port rust-bootstrap.
A 10.9+ machine builds the stage0 compiler.
The stage0 compiler is uploaded somewhere (currently my personal GitHub repository).
10.5-10.8 machines then download the stage0 compiler from us instead of upstream.
Our stage0 compiler makes extensive use of the MacPorts ecosystem, so that is another reason upstream would unlikely be interested.

Sorry if this is clear to everyone, but it took me a while to wrap my head around, and I am sure there are subtleties I am missing.

-Marcus

[1] https://github.com/rust-lang/rust/blob/1.66.0/src/stage0.json
[2] https://rustc-dev-guide.rust-lang.org/building/bootstrapping.html#stages-of-bootstrapping
[3] https://doc.rust-lang.org/nightly/rustc/platform-support.html
[4] https://trac.macports.org/ticket/62639
[5] https://github.com/rust-lang/rust/issues/40481
[6] https://github.com/rust-lang/rust/pull/104385
[7] https://github.com/Rust-GCC/gccrs
[8] https://github.com/thepowersgang/mrustc
[9] https://github.com/thepowersgang/mrustc#progress
[10] https://lists.macports.org/pipermail/macports-dev/2022-December/044862.html
[11] https://trac.macports.org/ticket/66226
[12] https://github.com/rust-lang/rfcs/pull/2837
[13] https://github.com/macports/macports-ports/blob/a9e1c26f4967b89ba6d0e546d2507ccc91adc295/lang/rust/Portfile#L66

> On Dec 21, 2022, at 9:02 PM, mcalhoun at macports.org wrote:
> 
> As many of you know, the Rust compiler is self-hosting, so Rust is required to build Rust.
> The problem is that the Rust binaries provided by upstream only work on macOS 10.9 and above.
> 
> To get around this, there is a rust-bootstrap port that build Rust binaries on 10.9+ intended to build Rust on previous macOS version.
> Currently, these binaries are stored on using my personal GitHub account.
> 
> So the entire upgrade process is essentially:
> 1) Update the version in rust-bootstrap.
> 2) Build Rust binaries on a 10.9 VM.
> 3) Upload Rust binaries to GitHub account.
> 4) On older machines, use MacPorts Rust binaries to build Rust.
>     On newer machines, us the upstream provides binaries to build Rust.
> 
> This is far from ideal, but it has allowed us to get Rust working back to 10.5 (both i386 and x86_64).
> 
> This entire procedure may be modified, and there are a few suggestions on the mailing list
> (https://lists.macports.org/pipermail/macports-dev/2022-December/thread.html#44855).
> 
> However, until consensus is reached about major changes, it would be nice to make some incremental improvements.
> 
> The easiest change: does anyone know of a better place to store the MacPorts generated binaries?
> 
> More challenging: can anyone think of a way to automate the process of building the MacPorts Rust binaries after rust-bootstrap is update?
> 
> -Marcus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macports.org/pipermail/macports-dev/attachments/20221222/2757d306/attachment.htm>


More information about the macports-dev mailing list