Skip to content

Commit 569e0e1

Browse files
committed
handle stage0 cargo and rustc separately
This change allows setting either `build.cargo` or `build.rustc` without requiring both to be set simultaneously, which was not possible previously. To try it, set `build.rustc` without setting `build.cargo`, and try to bootstrap on clean build. Signed-off-by: onur-ozkan <work@onurozkan.dev>
1 parent a32d4a0 commit 569e0e1

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/bootstrap/bootstrap.py

+15-8
Original file line numberDiff line numberDiff line change
@@ -533,9 +533,11 @@ def download_toolchain(self):
533533
bin_root = self.bin_root()
534534

535535
key = self.stage0_compiler.date
536-
if self.rustc().startswith(bin_root) and \
537-
(not os.path.exists(self.rustc()) or
538-
self.program_out_of_date(self.rustc_stamp(), key)):
536+
need_rustc = self.rustc().startswith(bin_root) and \
537+
(not os.path.exists(self.rustc()) or self.program_out_of_date(self.rustc_stamp(), key))
538+
need_cargo = self.cargo().startswith(bin_root) and not os.path.exists(self.cargo())
539+
540+
if need_rustc or need_cargo:
539541
if os.path.exists(bin_root):
540542
# HACK: On Windows, we can't delete rust-analyzer-proc-macro-server while it's
541543
# running. Kill it.
@@ -568,11 +570,16 @@ def download_toolchain(self):
568570

569571
toolchain_suffix = "{}-{}{}".format(rustc_channel, self.build, tarball_suffix)
570572

571-
tarballs_to_download = [
572-
("rust-std-{}".format(toolchain_suffix), "rust-std-{}".format(self.build)),
573-
("rustc-{}".format(toolchain_suffix), "rustc"),
574-
("cargo-{}".format(toolchain_suffix), "cargo"),
575-
]
573+
tarballs_to_download = []
574+
575+
if need_rustc:
576+
tarballs_to_download.append(
577+
("rust-std-{}".format(toolchain_suffix), "rust-std-{}".format(self.build))
578+
)
579+
tarballs_to_download.append(("rustc-{}".format(toolchain_suffix), "rustc"))
580+
581+
if need_cargo:
582+
tarballs_to_download.append(("cargo-{}".format(toolchain_suffix), "cargo"))
576583

577584
tarballs_download_info = [
578585
DownloadInfo(

0 commit comments

Comments
 (0)