@@ -444,9 +444,8 @@ def __init__(self):
444
444
self .verbose = False
445
445
self .git_version = None
446
446
self .nix_deps_dir = None
447
- self .rustc_commit = None
448
447
449
- def download_toolchain (self , stage0 = True , rustc_channel = None ):
448
+ def download_toolchain (self ):
450
449
"""Fetch the build system for Rust, written in Rust
451
450
452
451
This method will build a cache directory, then it will fetch the
@@ -456,45 +455,35 @@ def download_toolchain(self, stage0=True, rustc_channel=None):
456
455
Each downloaded tarball is extracted, after that, the script
457
456
will move all the content to the right place.
458
457
"""
459
- if rustc_channel is None :
460
- rustc_channel = self .stage0_compiler .version
461
- bin_root = self .bin_root (stage0 )
458
+ rustc_channel = self .stage0_compiler .version
459
+ bin_root = self .bin_root ()
462
460
463
461
key = self .stage0_compiler .date
464
- if not stage0 :
465
- key += str (self .rustc_commit )
466
- if self .rustc (stage0 ).startswith (bin_root ) and \
467
- (not os .path .exists (self .rustc (stage0 )) or
468
- self .program_out_of_date (self .rustc_stamp (stage0 ), key )):
462
+ if self .rustc ().startswith (bin_root ) and \
463
+ (not os .path .exists (self .rustc ()) or
464
+ self .program_out_of_date (self .rustc_stamp (), key )):
469
465
if os .path .exists (bin_root ):
470
466
shutil .rmtree (bin_root )
471
467
tarball_suffix = '.tar.xz' if support_xz () else '.tar.gz'
472
468
filename = "rust-std-{}-{}{}" .format (
473
469
rustc_channel , self .build , tarball_suffix )
474
470
pattern = "rust-std-{}" .format (self .build )
475
- self ._download_component_helper (filename , pattern , tarball_suffix , stage0 )
471
+ self ._download_component_helper (filename , pattern , tarball_suffix )
476
472
filename = "rustc-{}-{}{}" .format (rustc_channel , self .build ,
477
473
tarball_suffix )
478
- self ._download_component_helper (filename , "rustc" , tarball_suffix , stage0 )
479
- # download-rustc doesn't need its own cargo, it can just use beta's.
480
- if stage0 :
481
- filename = "cargo-{}-{}{}" .format (rustc_channel , self .build ,
482
- tarball_suffix )
483
- self ._download_component_helper (filename , "cargo" , tarball_suffix )
484
- self .fix_bin_or_dylib ("{}/bin/cargo" .format (bin_root ))
485
- else :
486
- filename = "rustc-dev-{}-{}{}" .format (rustc_channel , self .build , tarball_suffix )
487
- self ._download_component_helper (
488
- filename , "rustc-dev" , tarball_suffix , stage0
489
- )
474
+ self ._download_component_helper (filename , "rustc" , tarball_suffix )
475
+ filename = "cargo-{}-{}{}" .format (rustc_channel , self .build ,
476
+ tarball_suffix )
477
+ self ._download_component_helper (filename , "cargo" , tarball_suffix )
478
+ self .fix_bin_or_dylib ("{}/bin/cargo" .format (bin_root ))
490
479
491
480
self .fix_bin_or_dylib ("{}/bin/rustc" .format (bin_root ))
492
481
self .fix_bin_or_dylib ("{}/bin/rustdoc" .format (bin_root ))
493
482
lib_dir = "{}/lib" .format (bin_root )
494
483
for lib in os .listdir (lib_dir ):
495
484
if lib .endswith (".so" ):
496
485
self .fix_bin_or_dylib (os .path .join (lib_dir , lib ))
497
- with output (self .rustc_stamp (stage0 )) as rust_stamp :
486
+ with output (self .rustc_stamp ()) as rust_stamp :
498
487
rust_stamp .write (key )
499
488
500
489
if self .rustfmt () and self .rustfmt ().startswith (bin_root ) and (
@@ -518,24 +507,17 @@ def download_toolchain(self, stage0=True, rustc_channel=None):
518
507
rustfmt_stamp .write (self .stage0_rustfmt .channel ())
519
508
520
509
def _download_component_helper (
521
- self , filename , pattern , tarball_suffix , stage0 = True , key = None
510
+ self , filename , pattern , tarball_suffix , key = None
522
511
):
523
512
if key is None :
524
- if stage0 :
525
- key = self .stage0_compiler .date
526
- else :
527
- key = self .rustc_commit
513
+ key = self .stage0_compiler .date
528
514
cache_dst = os .path .join (self .build_dir , "cache" )
529
515
rustc_cache = os .path .join (cache_dst , key )
530
516
if not os .path .exists (rustc_cache ):
531
517
os .makedirs (rustc_cache )
532
518
533
- if stage0 :
534
- base = self ._download_url
535
- url = "dist/{}" .format (key )
536
- else :
537
- base = "https://ci-artifacts.rust-lang.org"
538
- url = "rustc-builds/{}" .format (self .rustc_commit )
519
+ base = self ._download_url
520
+ url = "dist/{}" .format (key )
539
521
tarball = os .path .join (rustc_cache , filename )
540
522
if not os .path .exists (tarball ):
541
523
get (
@@ -544,9 +526,9 @@ def _download_component_helper(
544
526
tarball ,
545
527
self .checksums_sha256 ,
546
528
verbose = self .verbose ,
547
- do_verify = stage0 ,
529
+ do_verify = True ,
548
530
)
549
- unpack (tarball , tarball_suffix , self .bin_root (stage0 ), match = pattern , verbose = self .verbose )
531
+ unpack (tarball , tarball_suffix , self .bin_root (), match = pattern , verbose = self .verbose )
550
532
551
533
def fix_bin_or_dylib (self , fname ):
552
534
"""Modifies the interpreter section of 'fname' to fix the dynamic linker,
@@ -644,62 +626,15 @@ def fix_bin_or_dylib(self, fname):
644
626
print ("warning: failed to call patchelf:" , reason )
645
627
return
646
628
647
- # If `download-rustc` is set, download the most recent commit with CI artifacts
648
- def maybe_download_ci_toolchain (self ):
649
- # If `download-rustc` is not set, default to rebuilding.
650
- download_rustc = self .get_toml ("download-rustc" , section = "rust" )
651
- if download_rustc is None or download_rustc == "false" :
652
- return None
653
- assert download_rustc == "true" or download_rustc == "if-unchanged" , download_rustc
654
-
655
- # Handle running from a directory other than the top level
656
- rev_parse = ["git" , "rev-parse" , "--show-toplevel" ]
657
- top_level = subprocess .check_output (rev_parse , universal_newlines = True ).strip ()
658
- compiler = "{}/compiler/" .format (top_level )
659
- library = "{}/library/" .format (top_level )
660
-
661
- # Look for a version to compare to based on the current commit.
662
- # Only commits merged by bors will have CI artifacts.
663
- merge_base = [
664
- "git" ,
"rev-list" ,
"[email protected] " ,
"-n1" ,
665
- "--first-parent" , "HEAD"
666
- ]
667
- commit = subprocess .check_output (merge_base , universal_newlines = True ).strip ()
668
- if not commit :
669
- print ("error: could not find commit hash for downloading rustc" )
670
- print ("help: maybe your repository history is too shallow?" )
671
- print ("help: consider disabling `download-rustc`" )
672
- print ("help: or fetch enough history to include one upstream commit" )
673
- exit (1 )
674
-
675
- # Warn if there were changes to the compiler or standard library since the ancestor commit.
676
- status = subprocess .call (["git" , "diff-index" , "--quiet" , commit , "--" , compiler , library ])
677
- if status != 0 :
678
- if download_rustc == "if-unchanged" :
679
- if self .verbose :
680
- print ("warning: saw changes to compiler/ or library/ since {}; " \
681
- "ignoring `download-rustc`" .format (commit ))
682
- return None
683
- print ("warning: `download-rustc` is enabled, but there are changes to " \
684
- "compiler/ or library/" )
685
-
686
- if self .verbose :
687
- print ("using downloaded stage2 artifacts from CI (commit {})" .format (commit ))
688
- self .rustc_commit = commit
689
- # FIXME: support downloading artifacts from the beta channel
690
- self .download_toolchain (False , "nightly" )
691
-
692
- def rustc_stamp (self , stage0 ):
629
+ def rustc_stamp (self ):
693
630
"""Return the path for .rustc-stamp at the given stage
694
631
695
632
>>> rb = RustBuild()
696
633
>>> rb.build_dir = "build"
697
- >>> rb.rustc_stamp(True) == os.path.join("build", "stage0", ".rustc-stamp")
698
- True
699
- >>> rb.rustc_stamp(False) == os.path.join("build", "ci-rustc", ".rustc-stamp")
634
+ >>> rb.rustc_stamp() == os.path.join("build", "stage0", ".rustc-stamp")
700
635
True
701
636
"""
702
- return os .path .join (self .bin_root (stage0 ), '.rustc-stamp' )
637
+ return os .path .join (self .bin_root (), '.rustc-stamp' )
703
638
704
639
def rustfmt_stamp (self ):
705
640
"""Return the path for .rustfmt-stamp
@@ -709,7 +644,7 @@ def rustfmt_stamp(self):
709
644
>>> rb.rustfmt_stamp() == os.path.join("build", "stage0", ".rustfmt-stamp")
710
645
True
711
646
"""
712
- return os .path .join (self .bin_root (True ), '.rustfmt-stamp' )
647
+ return os .path .join (self .bin_root (), '.rustfmt-stamp' )
713
648
714
649
def program_out_of_date (self , stamp_path , key ):
715
650
"""Check if the given program stamp is out of date"""
@@ -718,26 +653,21 @@ def program_out_of_date(self, stamp_path, key):
718
653
with open (stamp_path , 'r' ) as stamp :
719
654
return key != stamp .read ()
720
655
721
- def bin_root (self , stage0 ):
656
+ def bin_root (self ):
722
657
"""Return the binary root directory for the given stage
723
658
724
659
>>> rb = RustBuild()
725
660
>>> rb.build_dir = "build"
726
- >>> rb.bin_root(True) == os.path.join("build", "stage0")
727
- True
728
- >>> rb.bin_root(False) == os.path.join("build", "ci-rustc")
661
+ >>> rb.bin_root() == os.path.join("build", "stage0")
729
662
True
730
663
731
664
When the 'build' property is given should be a nested directory:
732
665
733
666
>>> rb.build = "devel"
734
- >>> rb.bin_root(True ) == os.path.join("build", "devel", "stage0")
667
+ >>> rb.bin_root() == os.path.join("build", "devel", "stage0")
735
668
True
736
669
"""
737
- if stage0 :
738
- subdir = "stage0"
739
- else :
740
- subdir = "ci-rustc"
670
+ subdir = "stage0"
741
671
return os .path .join (self .build_dir , self .build , subdir )
742
672
743
673
def get_toml (self , key , section = None ):
@@ -785,37 +715,33 @@ def cargo(self):
785
715
"""Return config path for cargo"""
786
716
return self .program_config ('cargo' )
787
717
788
- def rustc (self , stage0 ):
718
+ def rustc (self ):
789
719
"""Return config path for rustc"""
790
- return self .program_config ('rustc' , stage0 )
720
+ return self .program_config ('rustc' )
791
721
792
722
def rustfmt (self ):
793
723
"""Return config path for rustfmt"""
794
724
if self .stage0_rustfmt is None :
795
725
return None
796
726
return self .program_config ('rustfmt' )
797
727
798
- def program_config (self , program , stage0 = True ):
728
+ def program_config (self , program ):
799
729
"""Return config path for the given program at the given stage
800
730
801
731
>>> rb = RustBuild()
802
732
>>> rb.config_toml = 'rustc = "rustc"\\ n'
803
733
>>> rb.program_config('rustc')
804
734
'rustc'
805
735
>>> rb.config_toml = ''
806
- >>> cargo_path = rb.program_config('cargo', True)
807
- >>> cargo_path.rstrip(".exe") == os.path.join(rb.bin_root(True),
808
- ... "bin", "cargo")
809
- True
810
- >>> cargo_path = rb.program_config('cargo', False)
811
- >>> cargo_path.rstrip(".exe") == os.path.join(rb.bin_root(False),
736
+ >>> cargo_path = rb.program_config('cargo')
737
+ >>> cargo_path.rstrip(".exe") == os.path.join(rb.bin_root(),
812
738
... "bin", "cargo")
813
739
True
814
740
"""
815
741
config = self .get_toml (program )
816
742
if config :
817
743
return os .path .expanduser (config )
818
- return os .path .join (self .bin_root (stage0 ), "bin" , "{}{}" .format (
744
+ return os .path .join (self .bin_root (), "bin" , "{}{}" .format (
819
745
program , self .exe_suffix ()))
820
746
821
747
@staticmethod
@@ -871,14 +797,14 @@ def build_bootstrap(self):
871
797
if "CARGO_BUILD_TARGET" in env :
872
798
del env ["CARGO_BUILD_TARGET" ]
873
799
env ["CARGO_TARGET_DIR" ] = build_dir
874
- env ["RUSTC" ] = self .rustc (True )
875
- env ["LD_LIBRARY_PATH" ] = os .path .join (self .bin_root (True ), "lib" ) + \
800
+ env ["RUSTC" ] = self .rustc ()
801
+ env ["LD_LIBRARY_PATH" ] = os .path .join (self .bin_root (), "lib" ) + \
876
802
(os .pathsep + env ["LD_LIBRARY_PATH" ]) \
877
803
if "LD_LIBRARY_PATH" in env else ""
878
- env ["DYLD_LIBRARY_PATH" ] = os .path .join (self .bin_root (True ), "lib" ) + \
804
+ env ["DYLD_LIBRARY_PATH" ] = os .path .join (self .bin_root (), "lib" ) + \
879
805
(os .pathsep + env ["DYLD_LIBRARY_PATH" ]) \
880
806
if "DYLD_LIBRARY_PATH" in env else ""
881
- env ["LIBRARY_PATH" ] = os .path .join (self .bin_root (True ), "lib" ) + \
807
+ env ["LIBRARY_PATH" ] = os .path .join (self .bin_root (), "lib" ) + \
882
808
(os .pathsep + env ["LIBRARY_PATH" ]) \
883
809
if "LIBRARY_PATH" in env else ""
884
810
@@ -900,7 +826,7 @@ def build_bootstrap(self):
900
826
if self .get_toml ("deny-warnings" , "rust" ) != "false" :
901
827
env ["RUSTFLAGS" ] += " -Dwarnings"
902
828
903
- env ["PATH" ] = os .path .join (self .bin_root (True ), "bin" ) + \
829
+ env ["PATH" ] = os .path .join (self .bin_root (), "bin" ) + \
904
830
os .pathsep + env ["PATH" ]
905
831
if not os .path .isfile (self .cargo ()):
906
832
raise Exception ("no cargo executable found at `{}`" .format (
@@ -1171,8 +1097,6 @@ def bootstrap(help_triggered):
1171
1097
1172
1098
# Fetch/build the bootstrap
1173
1099
build .download_toolchain ()
1174
- # Download the master compiler if `download-rustc` is set
1175
- build .maybe_download_ci_toolchain ()
1176
1100
sys .stdout .flush ()
1177
1101
build .ensure_vendored ()
1178
1102
build .build_bootstrap ()
@@ -1184,8 +1108,6 @@ def bootstrap(help_triggered):
1184
1108
env = os .environ .copy ()
1185
1109
env ["BOOTSTRAP_PARENT_ID" ] = str (os .getpid ())
1186
1110
env ["BOOTSTRAP_PYTHON" ] = sys .executable
1187
- if build .rustc_commit is not None :
1188
- env ["BOOTSTRAP_DOWNLOAD_RUSTC" ] = '1'
1189
1111
run (args , env = env , verbose = build .verbose , is_bootstrap = True )
1190
1112
1191
1113
0 commit comments