@@ -231,7 +231,7 @@ impl Step for Std {
231231 let  target_sysroot_bin =
232232 builder. sysroot_libdir ( compiler,  target) . parent ( ) . unwrap ( ) . join ( "bin" ) ; 
233233 t ! ( fs:: create_dir_all( & target_sysroot_bin) ) ; 
234-  builder. cp_r ( & src_sysroot_bin,  & target_sysroot_bin) ; 
234+  builder. cp_link_r ( & src_sysroot_bin,  & target_sysroot_bin) ; 
235235 } 
236236 } 
237237
@@ -307,7 +307,7 @@ fn copy_and_stamp(
307307 dependency_type :  DependencyType , 
308308)  { 
309309 let  target = libdir. join ( name) ; 
310-  builder. copy ( & sourcedir. join ( name) ,  & target) ; 
310+  builder. copy_link ( & sourcedir. join ( name) ,  & target) ; 
311311
312312 target_deps. push ( ( target,  dependency_type) ) ; 
313313} 
@@ -316,7 +316,7 @@ fn copy_llvm_libunwind(builder: &Builder<'_>, target: TargetSelection, libdir: &
316316 let  libunwind_path = builder. ensure ( llvm:: Libunwind  {  target } ) ; 
317317 let  libunwind_source = libunwind_path. join ( "libunwind.a" ) ; 
318318 let  libunwind_target = libdir. join ( "libunwind.a" ) ; 
319-  builder. copy ( & libunwind_source,  & libunwind_target) ; 
319+  builder. copy_link ( & libunwind_source,  & libunwind_target) ; 
320320 libunwind_target
321321} 
322322
@@ -385,7 +385,7 @@ fn copy_self_contained_objects(
385385 for  & obj in  & [ "crtbegin.o" ,  "crtbeginS.o" ,  "crtend.o" ,  "crtendS.o" ]  { 
386386 let  src = crt_path. join ( obj) ; 
387387 let  target = libdir_self_contained. join ( obj) ; 
388-  builder. copy ( & src,  & target) ; 
388+  builder. copy_link ( & src,  & target) ; 
389389 target_deps. push ( ( target,  DependencyType :: TargetSelfContained ) ) ; 
390390 } 
391391
@@ -418,7 +418,7 @@ fn copy_self_contained_objects(
418418 for  obj in  [ "crt2.o" ,  "dllcrt2.o" ] . iter ( )  { 
419419 let  src = compiler_file ( builder,  & builder. cc ( target) ,  target,  CLang :: C ,  obj) ; 
420420 let  target = libdir_self_contained. join ( obj) ; 
421-  builder. copy ( & src,  & target) ; 
421+  builder. copy_link ( & src,  & target) ; 
422422 target_deps. push ( ( target,  DependencyType :: TargetSelfContained ) ) ; 
423423 } 
424424 } 
@@ -637,7 +637,7 @@ impl Step for StdLink {
637637 let  stage0_bin_dir = builder. out . join ( host) . join ( "stage0/bin" ) ; 
638638 let  sysroot_bin_dir = sysroot. join ( "bin" ) ; 
639639 t ! ( fs:: create_dir_all( & sysroot_bin_dir) ) ; 
640-  builder. cp_r ( & stage0_bin_dir,  & sysroot_bin_dir) ; 
640+  builder. cp_link_r ( & stage0_bin_dir,  & sysroot_bin_dir) ; 
641641
642642 // Copy all *.so files from stage0/lib to stage0-sysroot/lib 
643643 let  stage0_lib_dir = builder. out . join ( host) . join ( "stage0/lib" ) ; 
@@ -646,7 +646,8 @@ impl Step for StdLink {
646646 let  file = t ! ( file) ; 
647647 let  path = file. path ( ) ; 
648648 if  path. is_file ( )  && is_dylib ( & file. file_name ( ) . into_string ( ) . unwrap ( ) )  { 
649-  builder. copy ( & path,  & sysroot. join ( "lib" ) . join ( path. file_name ( ) . unwrap ( ) ) ) ; 
649+  builder
650+  . copy_link ( & path,  & sysroot. join ( "lib" ) . join ( path. file_name ( ) . unwrap ( ) ) ) ; 
650651 } 
651652 } 
652653 } 
@@ -661,7 +662,7 @@ impl Step for StdLink {
661662 . join ( host) 
662663 . join ( "codegen-backends" ) ; 
663664 if  stage0_codegen_backends. exists ( )  { 
664-  builder. cp_r ( & stage0_codegen_backends,  & sysroot_codegen_backends) ; 
665+  builder. cp_link_r ( & stage0_codegen_backends,  & sysroot_codegen_backends) ; 
665666 } 
666667 } 
667668 } 
@@ -684,7 +685,7 @@ fn copy_sanitizers(
684685
685686 for  runtime in  & runtimes { 
686687 let  dst = libdir. join ( & runtime. name ) ; 
687-  builder. copy ( & runtime. path ,  & dst) ; 
688+  builder. copy_link ( & runtime. path ,  & dst) ; 
688689
689690 // The `aarch64-apple-ios-macabi` and `x86_64-apple-ios-macabi` are also supported for 
690691 // sanitizers, but they share a sanitizer runtime with `${arch}-apple-darwin`, so we do 
@@ -790,7 +791,7 @@ impl Step for StartupObjects {
790791 } 
791792
792793 let  target = sysroot_dir. join ( ( * file) . to_string ( )  + ".o" ) ; 
793-  builder. copy ( dst_file,  & target) ; 
794+  builder. copy_link ( dst_file,  & target) ; 
794795 target_deps. push ( ( target,  DependencyType :: Target ) ) ; 
795796 } 
796797
@@ -812,7 +813,7 @@ fn cp_rustc_component_to_ci_sysroot(
812813 if  src. is_dir ( )  { 
813814 t ! ( fs:: create_dir_all( dst) ) ; 
814815 }  else  { 
815-  builder. copy ( & src,  & dst) ; 
816+  builder. copy_link ( & src,  & dst) ; 
816817 } 
817818 } 
818819} 
@@ -1443,7 +1444,7 @@ fn copy_codegen_backends_to_sysroot(
14431444 let  dot = filename. find ( '.' ) . unwrap ( ) ; 
14441445 format ! ( "{}-{}{}" ,  & filename[ ..dash] ,  builder. rust_release( ) ,  & filename[ dot..] ) 
14451446 } ; 
1446-  builder. copy ( file,  & dst. join ( target_filename) ) ; 
1447+  builder. copy_link ( file,  & dst. join ( target_filename) ) ; 
14471448 } 
14481449} 
14491450
@@ -1599,7 +1600,7 @@ impl Step for Sysroot {
15991600 OsStr :: new ( std:: env:: consts:: DLL_EXTENSION ) , 
16001601 ] ; 
16011602 let  ci_rustc_dir = builder. config . ci_rustc_dir ( ) ; 
1602-  builder. cp_filtered ( & ci_rustc_dir,  & sysroot,  & |path| { 
1603+  builder. cp_link_filtered ( & ci_rustc_dir,  & sysroot,  & |path| { 
16031604 if  path. extension ( ) . map_or ( true ,  |ext| !filtered_extensions. contains ( & ext) )  { 
16041605 return  true ; 
16051606 } 
@@ -1791,7 +1792,7 @@ impl Step for Assemble {
17911792 let  filename = f. file_name ( ) . into_string ( ) . unwrap ( ) ; 
17921793 if  ( is_dylib ( & filename)  || is_debug_info ( & filename) )  && !proc_macros. contains ( & filename) 
17931794 { 
1794-  builder. copy ( & f. path ( ) ,  & rustc_libdir. join ( & filename) ) ; 
1795+  builder. copy_link ( & f. path ( ) ,  & rustc_libdir. join ( & filename) ) ; 
17951796 } 
17961797 } 
17971798
@@ -1805,15 +1806,15 @@ impl Step for Assemble {
18051806 if  let  Some ( lld_install)  = lld_install { 
18061807 let  src_exe = exe ( "lld" ,  target_compiler. host ) ; 
18071808 let  dst_exe = exe ( "rust-lld" ,  target_compiler. host ) ; 
1808-  builder. copy ( & lld_install. join ( "bin" ) . join ( src_exe) ,  & libdir_bin. join ( dst_exe) ) ; 
1809+  builder. copy_link ( & lld_install. join ( "bin" ) . join ( src_exe) ,  & libdir_bin. join ( dst_exe) ) ; 
18091810 let  self_contained_lld_dir = libdir_bin. join ( "gcc-ld" ) ; 
18101811 t ! ( fs:: create_dir_all( & self_contained_lld_dir) ) ; 
18111812 let  lld_wrapper_exe = builder. ensure ( crate :: core:: build_steps:: tool:: LldWrapper  { 
18121813 compiler :  build_compiler, 
18131814 target :  target_compiler. host , 
18141815 } ) ; 
18151816 for  name in  crate :: LLD_FILE_NAMES  { 
1816-  builder. copy ( 
1817+  builder. copy_link ( 
18171818 & lld_wrapper_exe, 
18181819 & self_contained_lld_dir. join ( exe ( name,  target_compiler. host ) ) , 
18191820 ) ; 
@@ -1838,7 +1839,7 @@ impl Step for Assemble {
18381839 // When using `download-ci-llvm`, some of the tools 
18391840 // may not exist, so skip trying to copy them. 
18401841 if  src_path. exists ( )  { 
1841-  builder. copy ( & src_path,  & libdir_bin. join ( & tool_exe) ) ; 
1842+  builder. copy_link ( & src_path,  & libdir_bin. join ( & tool_exe) ) ; 
18421843 } 
18431844 } 
18441845 } 
@@ -1851,7 +1852,7 @@ impl Step for Assemble {
18511852 extra_features :  vec ! [ ] , 
18521853 } ) ; 
18531854 let  tool_exe = exe ( "llvm-bitcode-linker" ,  target_compiler. host ) ; 
1854-  builder. copy ( & src_path,  & libdir_bin. join ( & tool_exe) ) ; 
1855+  builder. copy_link ( & src_path,  & libdir_bin. join ( & tool_exe) ) ; 
18551856 } 
18561857
18571858 // Ensure that `libLLVM.so` ends up in the newly build compiler directory, 
@@ -1865,7 +1866,7 @@ impl Step for Assemble {
18651866 let  bindir = sysroot. join ( "bin" ) ; 
18661867 t ! ( fs:: create_dir_all( bindir) ) ; 
18671868 let  compiler = builder. rustc ( target_compiler) ; 
1868-  builder. copy ( & rustc,  & compiler) ; 
1869+  builder. copy_link ( & rustc,  & compiler) ; 
18691870
18701871 target_compiler
18711872 } 
@@ -1891,7 +1892,7 @@ pub fn add_to_sysroot(
18911892 DependencyType :: Target  => sysroot_dst, 
18921893 DependencyType :: TargetSelfContained  => self_contained_dst, 
18931894 } ; 
1894-  builder. copy ( & path,  & dst. join ( path. file_name ( ) . unwrap ( ) ) ) ; 
1895+  builder. copy_link ( & path,  & dst. join ( path. file_name ( ) . unwrap ( ) ) ) ; 
18951896 } 
18961897} 
18971898
0 commit comments