Skip to content

Commit

Permalink
bootstrap: use the same version number for rustc and cargo
Browse files Browse the repository at this point in the history
Historically the stable tarballs were named after the version number of
the specific tool, instead of the version number of Rust. For example,
both of the following tarballs were part of the same release:

    rustc-1.48.0-x86_64-unknown-linux-gnu.tar.xz
    cargo-0.49.0-x86_64-unknown-linux-gnu.tar.xz

PR rust-lang#77336 changed the dist code to instead use Rust's version number for
all the tarballs, regardless of the tool they contain:

    rustc-1.48.0-x86_64-unknown-linux-gnu.tar.xz
    cargo-1.48.0-x86_64-unknown-linux-gnu.tar.xz

Because of that there is no need anymore to have a separate `cargo`
field in src/stage0.txt, as the Cargo version will always be the same as
the rustc version. This PR removes the field, simplifying the code and
the maintenance work required while producing releases.
  • Loading branch information
pietroalbini authored and Mark-Simulacrum committed Nov 17, 2020
1 parent efcb3b3 commit d17874f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 31 deletions.
29 changes: 4 additions & 25 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,6 @@ def output(filepath):
class RustBuild(object):
"""Provide all the methods required to build Rust"""
def __init__(self):
self.cargo_channel = ''
self.date = ''
self._download_url = ''
self.rustc_channel = ''
Expand All @@ -387,7 +386,6 @@ def download_stage0(self):
will move all the content to the right place.
"""
rustc_channel = self.rustc_channel
cargo_channel = self.cargo_channel
rustfmt_channel = self.rustfmt_channel

if self.rustc().startswith(self.bin_root()) and \
Expand All @@ -400,30 +398,22 @@ def download_stage0(self):
rustc_channel, self.build, tarball_suffix)
pattern = "rust-std-{}".format(self.build)
self._download_stage0_helper(filename, pattern, tarball_suffix)

filename = "rustc-{}-{}{}".format(rustc_channel, self.build,
tarball_suffix)
self._download_stage0_helper(filename, "rustc", tarball_suffix)
filename = "cargo-{}-{}{}".format(rustc_channel, self.build,
tarball_suffix)
self._download_stage0_helper(filename, "cargo", tarball_suffix)
self.fix_bin_or_dylib("{}/bin/rustc".format(self.bin_root()))
self.fix_bin_or_dylib("{}/bin/rustdoc".format(self.bin_root()))
self.fix_bin_or_dylib("{}/bin/cargo".format(self.bin_root()))
lib_dir = "{}/lib".format(self.bin_root())
for lib in os.listdir(lib_dir):
if lib.endswith(".so"):
self.fix_bin_or_dylib("{}/{}".format(lib_dir, lib))
with output(self.rustc_stamp()) as rust_stamp:
rust_stamp.write(self.date)

if self.cargo().startswith(self.bin_root()) and \
(not os.path.exists(self.cargo()) or
self.program_out_of_date(self.cargo_stamp())):
tarball_suffix = '.tar.xz' if support_xz() else '.tar.gz'
filename = "cargo-{}-{}{}".format(cargo_channel, self.build,
tarball_suffix)
self._download_stage0_helper(filename, "cargo", tarball_suffix)
self.fix_bin_or_dylib("{}/bin/cargo".format(self.bin_root()))
with output(self.cargo_stamp()) as cargo_stamp:
cargo_stamp.write(self.date)

if self.rustfmt() and self.rustfmt().startswith(self.bin_root()) and (
not os.path.exists(self.rustfmt())
or self.program_out_of_date(self.rustfmt_stamp(), self.rustfmt_channel)
Expand Down Expand Up @@ -601,16 +591,6 @@ def rustc_stamp(self):
"""
return os.path.join(self.bin_root(), '.rustc-stamp')

def cargo_stamp(self):
"""Return the path for .cargo-stamp
>>> rb = RustBuild()
>>> rb.build_dir = "build"
>>> rb.cargo_stamp() == os.path.join("build", "stage0", ".cargo-stamp")
True
"""
return os.path.join(self.bin_root(), '.cargo-stamp')

def rustfmt_stamp(self):
"""Return the path for .rustfmt-stamp
Expand Down Expand Up @@ -1056,7 +1036,6 @@ def bootstrap(help_triggered):
data = stage0_data(build.rust_root)
build.date = data['date']
build.rustc_channel = data['rustc']
build.cargo_channel = data['cargo']

if "rustfmt" in data:
build.rustfmt_channel = data['rustfmt']
Expand Down
11 changes: 5 additions & 6 deletions src/stage0.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
# This file describes the stage0 compiler that's used to then bootstrap the Rust
# compiler itself. For the rustbuild build system, this also describes the
# relevant Cargo revision that we're using.
# compiler itself.
#
# Currently Rust always bootstraps from the previous stable release, and in our
# train model this means that the master branch bootstraps from beta, beta
# bootstraps from current stable, and stable bootstraps from the previous stable
# release.
#
# If you're looking at this file on the master branch, you'll likely see that
# rustc and cargo are configured to `beta`, whereas if you're looking at a
# source tarball for a stable release you'll likely see `1.x.0` for rustc and
# `0.(x+1).0` for Cargo where they were released on `date`.
# rustc is configured to `beta`, whereas if you're looking at a source tarball
# for a stable release you'll likely see `1.x.0` for rustc, with the previous
# stable release's version number. `date` is the date where the release we're
# bootstrapping off was released.

date: 2020-10-16
rustc: beta
cargo: beta

# We use a nightly rustfmt to format the source because it solves some
# bootstrapping issues with use of new syntax in this repo. If you're looking at
Expand Down

0 comments on commit d17874f

Please sign in to comment.