@@ -403,13 +403,24 @@ impl Step for Mingw {
403403 }
404404}
405405
406+ /// Creates the `rustc` installer component.
407+ ///
408+ /// This includes:
409+ /// - The compiler and LLVM.
410+ /// - Debugger scripts.
411+ /// - Various helper tools, e.g. LLD or Rust Analyzer proc-macro server (if enabled).
412+ /// - The licenses of all code used by the compiler.
413+ ///
414+ /// It does not include any standard library.
406415#[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
407416pub struct Rustc {
408- pub compiler : Compiler ,
417+ /// This is the compiler that we will *ship* in this dist step.
418+ pub target_compiler : Compiler ,
409419}
410420
411421impl Step for Rustc {
412422 type Output = GeneratedTarball ;
423+
413424 const DEFAULT : bool = true ;
414425 const IS_HOST : bool = true ;
415426
@@ -418,19 +429,19 @@ impl Step for Rustc {
418429 }
419430
420431 fn make_run ( run : RunConfig < ' _ > ) {
421- run. builder
422- . ensure ( Rustc { compiler : run. builder . compiler ( run. builder . top_stage , run. target ) } ) ;
432+ run. builder . ensure ( Rustc {
433+ target_compiler : run. builder . compiler ( run. builder . top_stage , run. target ) ,
434+ } ) ;
423435 }
424436
425- /// Creates the `rustc` installer component.
426437 fn run ( self , builder : & Builder < ' _ > ) -> GeneratedTarball {
427- let compiler = self . compiler ;
428- let host = self . compiler . host ;
438+ let target_compiler = self . target_compiler ;
439+ let target = self . target_compiler . host ;
429440
430- let tarball = Tarball :: new ( builder, "rustc" , & host . triple ) ;
441+ let tarball = Tarball :: new ( builder, "rustc" , & target . triple ) ;
431442
432443 // Prepare the rustc "image", what will actually end up getting installed
433- prepare_image ( builder, compiler , tarball. image_dir ( ) ) ;
444+ prepare_image ( builder, target_compiler , tarball. image_dir ( ) ) ;
434445
435446 // On MinGW we've got a few runtime DLL dependencies that we need to
436447 // include.
@@ -439,16 +450,16 @@ impl Step for Rustc {
439450 // anything requiring us to distribute a license, but it's likely the
440451 // install will *also* include the rust-mingw package, which also needs
441452 // licenses, so to be safe we just include it here in all MinGW packages.
442- if host . contains ( "pc-windows-gnu" ) && builder. config . dist_include_mingw_linker {
443- runtime_dll_dist ( tarball. image_dir ( ) , host , builder) ;
453+ if target . contains ( "pc-windows-gnu" ) && builder. config . dist_include_mingw_linker {
454+ runtime_dll_dist ( tarball. image_dir ( ) , target , builder) ;
444455 tarball. add_dir ( builder. src . join ( "src/etc/third-party" ) , "share/doc" ) ;
445456 }
446457
447458 return tarball. generate ( ) ;
448459
449- fn prepare_image ( builder : & Builder < ' _ > , compiler : Compiler , image : & Path ) {
450- let host = compiler . host ;
451- let src = builder. sysroot ( compiler ) ;
460+ fn prepare_image ( builder : & Builder < ' _ > , target_compiler : Compiler , image : & Path ) {
461+ let host = target_compiler . host ;
462+ let src = builder. sysroot ( target_compiler ) ;
452463
453464 // Copy rustc binary
454465 t ! ( fs:: create_dir_all( image. join( "bin" ) ) ) ;
@@ -461,17 +472,11 @@ impl Step for Rustc {
461472 . as_ref ( )
462473 . is_none_or ( |tools| tools. iter ( ) . any ( |tool| tool == "rustdoc" ) )
463474 {
464- let rustdoc = builder. rustdoc_for_compiler ( compiler ) ;
475+ let rustdoc = builder. rustdoc_for_compiler ( target_compiler ) ;
465476 builder. install ( & rustdoc, & image. join ( "bin" ) , FileType :: Executable ) ;
466477 }
467478
468- let ra_proc_macro_srv_compiler =
469- builder. compiler_for ( compiler. stage , builder. config . host_target , compiler. host ) ;
470- let compilers = RustcPrivateCompilers :: from_build_compiler (
471- builder,
472- ra_proc_macro_srv_compiler,
473- compiler. host ,
474- ) ;
479+ let compilers = RustcPrivateCompilers :: from_target_compiler ( builder, target_compiler) ;
475480
476481 if let Some ( ra_proc_macro_srv) = builder. ensure_if_default (
477482 tool:: RustAnalyzerProcMacroSrv :: from_compilers ( compilers) ,
@@ -481,11 +486,11 @@ impl Step for Rustc {
481486 builder. install ( & ra_proc_macro_srv. tool_path , & dst, FileType :: Executable ) ;
482487 }
483488
484- let libdir_relative = builder. libdir_relative ( compiler ) ;
489+ let libdir_relative = builder. libdir_relative ( target_compiler ) ;
485490
486491 // Copy runtime DLLs needed by the compiler
487492 if libdir_relative. to_str ( ) != Some ( "bin" ) {
488- let libdir = builder. rustc_libdir ( compiler ) ;
493+ let libdir = builder. rustc_libdir ( target_compiler ) ;
489494 for entry in builder. read_dir ( & libdir) {
490495 // A safeguard that we will not ship libgccjit.so from the libdir, in case the
491496 // GCC codegen backend is enabled by default.
@@ -519,8 +524,8 @@ impl Step for Rustc {
519524
520525 // Copy over lld if it's there
521526 if builder. config . lld_enabled {
522- let src_dir = builder. sysroot_target_bindir ( compiler , host) ;
523- let rust_lld = exe ( "rust-lld" , compiler . host ) ;
527+ let src_dir = builder. sysroot_target_bindir ( target_compiler , host) ;
528+ let rust_lld = exe ( "rust-lld" , target_compiler . host ) ;
524529 builder. copy_link (
525530 & src_dir. join ( & rust_lld) ,
526531 & dst_dir. join ( & rust_lld) ,
@@ -530,7 +535,7 @@ impl Step for Rustc {
530535 let self_contained_lld_dst_dir = dst_dir. join ( "gcc-ld" ) ;
531536 t ! ( fs:: create_dir( & self_contained_lld_dst_dir) ) ;
532537 for name in crate :: LLD_FILE_NAMES {
533- let exe_name = exe ( name, compiler . host ) ;
538+ let exe_name = exe ( name, target_compiler . host ) ;
534539 builder. copy_link (
535540 & self_contained_lld_src_dir. join ( & exe_name) ,
536541 & self_contained_lld_dst_dir. join ( & exe_name) ,
@@ -539,10 +544,12 @@ impl Step for Rustc {
539544 }
540545 }
541546
542- if builder. config . llvm_enabled ( compiler. host ) && builder. config . llvm_tools_enabled {
543- let src_dir = builder. sysroot_target_bindir ( compiler, host) ;
544- let llvm_objcopy = exe ( "llvm-objcopy" , compiler. host ) ;
545- let rust_objcopy = exe ( "rust-objcopy" , compiler. host ) ;
547+ if builder. config . llvm_enabled ( target_compiler. host )
548+ && builder. config . llvm_tools_enabled
549+ {
550+ let src_dir = builder. sysroot_target_bindir ( target_compiler, host) ;
551+ let llvm_objcopy = exe ( "llvm-objcopy" , target_compiler. host ) ;
552+ let rust_objcopy = exe ( "rust-objcopy" , target_compiler. host ) ;
546553 builder. copy_link (
547554 & src_dir. join ( & llvm_objcopy) ,
548555 & dst_dir. join ( & rust_objcopy) ,
@@ -551,8 +558,8 @@ impl Step for Rustc {
551558 }
552559
553560 if builder. tool_enabled ( "wasm-component-ld" ) {
554- let src_dir = builder. sysroot_target_bindir ( compiler , host) ;
555- let ld = exe ( "wasm-component-ld" , compiler . host ) ;
561+ let src_dir = builder. sysroot_target_bindir ( target_compiler , host) ;
562+ let ld = exe ( "wasm-component-ld" , target_compiler . host ) ;
556563 builder. copy_link ( & src_dir. join ( & ld) , & dst_dir. join ( & ld) , FileType :: Executable ) ;
557564 }
558565
@@ -599,7 +606,7 @@ impl Step for Rustc {
599606 }
600607
601608 fn metadata ( & self ) -> Option < StepMetadata > {
602- Some ( StepMetadata :: dist ( "rustc" , self . compiler . host ) )
609+ Some ( StepMetadata :: dist ( "rustc" , self . target_compiler . host ) )
603610 }
604611}
605612
@@ -1621,7 +1628,7 @@ impl Step for Extended {
16211628 // upgrades rustc was upgraded before rust-std. To avoid rustc clobbering
16221629 // the std files during uninstall. To do this ensure that rustc comes
16231630 // before rust-std in the list below.
1624- tarballs. push ( builder. ensure ( Rustc { compiler : target_compiler } ) ) ;
1631+ tarballs. push ( builder. ensure ( Rustc { target_compiler } ) ) ;
16251632 tarballs. push ( builder. ensure ( Std { compiler, target } ) . expect ( "missing std" ) ) ;
16261633
16271634 if target. is_windows_gnu ( ) {
0 commit comments