Skip to content

Commit d17874f

Browse files
pietroalbiniMark-Simulacrum
authored andcommitted
bootstrap: use the same version number for rustc and cargo
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 #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.
1 parent efcb3b3 commit d17874f

File tree

2 files changed

+9
-31
lines changed

2 files changed

+9
-31
lines changed

src/bootstrap/bootstrap.py

+4-25
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,6 @@ def output(filepath):
360360
class RustBuild(object):
361361
"""Provide all the methods required to build Rust"""
362362
def __init__(self):
363-
self.cargo_channel = ''
364363
self.date = ''
365364
self._download_url = ''
366365
self.rustc_channel = ''
@@ -387,7 +386,6 @@ def download_stage0(self):
387386
will move all the content to the right place.
388387
"""
389388
rustc_channel = self.rustc_channel
390-
cargo_channel = self.cargo_channel
391389
rustfmt_channel = self.rustfmt_channel
392390

393391
if self.rustc().startswith(self.bin_root()) and \
@@ -400,30 +398,22 @@ def download_stage0(self):
400398
rustc_channel, self.build, tarball_suffix)
401399
pattern = "rust-std-{}".format(self.build)
402400
self._download_stage0_helper(filename, pattern, tarball_suffix)
403-
404401
filename = "rustc-{}-{}{}".format(rustc_channel, self.build,
405402
tarball_suffix)
406403
self._download_stage0_helper(filename, "rustc", tarball_suffix)
404+
filename = "cargo-{}-{}{}".format(rustc_channel, self.build,
405+
tarball_suffix)
406+
self._download_stage0_helper(filename, "cargo", tarball_suffix)
407407
self.fix_bin_or_dylib("{}/bin/rustc".format(self.bin_root()))
408408
self.fix_bin_or_dylib("{}/bin/rustdoc".format(self.bin_root()))
409+
self.fix_bin_or_dylib("{}/bin/cargo".format(self.bin_root()))
409410
lib_dir = "{}/lib".format(self.bin_root())
410411
for lib in os.listdir(lib_dir):
411412
if lib.endswith(".so"):
412413
self.fix_bin_or_dylib("{}/{}".format(lib_dir, lib))
413414
with output(self.rustc_stamp()) as rust_stamp:
414415
rust_stamp.write(self.date)
415416

416-
if self.cargo().startswith(self.bin_root()) and \
417-
(not os.path.exists(self.cargo()) or
418-
self.program_out_of_date(self.cargo_stamp())):
419-
tarball_suffix = '.tar.xz' if support_xz() else '.tar.gz'
420-
filename = "cargo-{}-{}{}".format(cargo_channel, self.build,
421-
tarball_suffix)
422-
self._download_stage0_helper(filename, "cargo", tarball_suffix)
423-
self.fix_bin_or_dylib("{}/bin/cargo".format(self.bin_root()))
424-
with output(self.cargo_stamp()) as cargo_stamp:
425-
cargo_stamp.write(self.date)
426-
427417
if self.rustfmt() and self.rustfmt().startswith(self.bin_root()) and (
428418
not os.path.exists(self.rustfmt())
429419
or self.program_out_of_date(self.rustfmt_stamp(), self.rustfmt_channel)
@@ -601,16 +591,6 @@ def rustc_stamp(self):
601591
"""
602592
return os.path.join(self.bin_root(), '.rustc-stamp')
603593

604-
def cargo_stamp(self):
605-
"""Return the path for .cargo-stamp
606-
607-
>>> rb = RustBuild()
608-
>>> rb.build_dir = "build"
609-
>>> rb.cargo_stamp() == os.path.join("build", "stage0", ".cargo-stamp")
610-
True
611-
"""
612-
return os.path.join(self.bin_root(), '.cargo-stamp')
613-
614594
def rustfmt_stamp(self):
615595
"""Return the path for .rustfmt-stamp
616596
@@ -1056,7 +1036,6 @@ def bootstrap(help_triggered):
10561036
data = stage0_data(build.rust_root)
10571037
build.date = data['date']
10581038
build.rustc_channel = data['rustc']
1059-
build.cargo_channel = data['cargo']
10601039

10611040
if "rustfmt" in data:
10621041
build.rustfmt_channel = data['rustfmt']

src/stage0.txt

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
# This file describes the stage0 compiler that's used to then bootstrap the Rust
2-
# compiler itself. For the rustbuild build system, this also describes the
3-
# relevant Cargo revision that we're using.
2+
# compiler itself.
43
#
54
# Currently Rust always bootstraps from the previous stable release, and in our
65
# train model this means that the master branch bootstraps from beta, beta
76
# bootstraps from current stable, and stable bootstraps from the previous stable
87
# release.
98
#
109
# If you're looking at this file on the master branch, you'll likely see that
11-
# rustc and cargo are configured to `beta`, whereas if you're looking at a
12-
# source tarball for a stable release you'll likely see `1.x.0` for rustc and
13-
# `0.(x+1).0` for Cargo where they were released on `date`.
10+
# rustc is configured to `beta`, whereas if you're looking at a source tarball
11+
# for a stable release you'll likely see `1.x.0` for rustc, with the previous
12+
# stable release's version number. `date` is the date where the release we're
13+
# bootstrapping off was released.
1414

1515
date: 2020-10-16
1616
rustc: beta
17-
cargo: beta
1817

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

0 commit comments

Comments
 (0)