@@ -15,7 +15,7 @@ use std::process::Command;
1515
1616use build_helper:: output;
1717
18- use build:: util:: { exe, staticlib, libdir, mtime, is_dylib} ;
18+ use build:: util:: { exe, staticlib, libdir, mtime, is_dylib, copy } ;
1919use build:: { Build , Compiler , Mode } ;
2020
2121/// Build the standard library.
@@ -32,8 +32,8 @@ pub fn std<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
3232 let libdir = build. sysroot_libdir ( compiler, target) ;
3333 let _ = fs:: remove_dir_all ( & libdir) ;
3434 t ! ( fs:: create_dir_all( & libdir) ) ;
35- t ! ( fs :: hard_link ( & build. compiler_rt_built. borrow( ) [ target] ,
36- libdir. join( staticlib( "compiler-rt" , target) ) ) ) ;
35+ copy ( & build. compiler_rt_built . borrow ( ) [ target] ,
36+ & libdir. join ( staticlib ( "compiler-rt" , target) ) ) ;
3737
3838 build_startup_objects ( build, target, & libdir) ;
3939
@@ -77,8 +77,8 @@ pub fn std_link(build: &Build,
7777 if host != compiler. host {
7878 let _ = fs:: remove_dir_all ( & libdir) ;
7979 t ! ( fs:: create_dir_all( & libdir) ) ;
80- t ! ( fs :: hard_link ( & build. compiler_rt_built. borrow( ) [ target] ,
81- libdir. join( staticlib( "compiler-rt" , target) ) ) ) ;
80+ copy ( & build. compiler_rt_built . borrow ( ) [ target] ,
81+ & libdir. join ( staticlib ( "compiler-rt" , target) ) ) ;
8282 }
8383 add_to_sysroot ( & out_dir, & libdir) ;
8484
@@ -93,7 +93,7 @@ pub fn std_link(build: &Build,
9393/// Only required for musl targets that statically link to libc
9494fn copy_third_party_objects ( build : & Build , target : & str , into : & Path ) {
9595 for & obj in & [ "crt1.o" , "crti.o" , "crtn.o" ] {
96- t ! ( fs :: copy( compiler_file( build. cc( target) , obj) , into. join( obj) ) ) ;
96+ copy ( & compiler_file ( build. cc ( target) , obj) , & into. join ( obj) ) ;
9797 }
9898}
9999
@@ -119,7 +119,7 @@ fn build_startup_objects(build: &Build, target: &str, into: &Path) {
119119 }
120120
121121 for obj in [ "crt2.o" , "dllcrt2.o" ] . iter ( ) {
122- t ! ( fs :: copy( compiler_file( build. cc( target) , obj) , into. join( obj) ) ) ;
122+ copy ( & compiler_file ( build. cc ( target) , obj) , & into. join ( obj) ) ;
123123 }
124124}
125125
@@ -240,9 +240,10 @@ fn libtest_shim(build: &Build, compiler: &Compiler, target: &str) -> PathBuf {
240240 build. cargo_out ( compiler, Mode :: Libtest , target) . join ( "libtest_shim.rlib" )
241241}
242242
243- fn compiler_file ( compiler : & Path , file : & str ) -> String {
244- output ( Command :: new ( compiler)
245- . arg ( format ! ( "-print-file-name={}" , file) ) ) . trim ( ) . to_string ( )
243+ fn compiler_file ( compiler : & Path , file : & str ) -> PathBuf {
244+ let out = output ( Command :: new ( compiler)
245+ . arg ( format ! ( "-print-file-name={}" , file) ) ) ;
246+ PathBuf :: from ( out. trim ( ) )
246247}
247248
248249/// Prepare a new compiler from the artifacts in `stage`
@@ -270,7 +271,7 @@ pub fn assemble_rustc(build: &Build, stage: u32, host: &str) {
270271 for f in t ! ( fs:: read_dir( & src_libdir) ) . map ( |f| t ! ( f) ) {
271272 let filename = f. file_name ( ) . into_string ( ) . unwrap ( ) ;
272273 if is_dylib ( & filename) {
273- t ! ( fs :: hard_link ( & f. path( ) , sysroot_libdir. join( & filename) ) ) ;
274+ copy ( & f. path ( ) , & sysroot_libdir. join ( & filename) ) ;
274275 }
275276 }
276277
@@ -282,15 +283,15 @@ pub fn assemble_rustc(build: &Build, stage: u32, host: &str) {
282283 t ! ( fs:: create_dir_all( & bindir) ) ;
283284 let compiler = build. compiler_path ( & Compiler :: new ( stage, host) ) ;
284285 let _ = fs:: remove_file ( & compiler) ;
285- t ! ( fs :: hard_link ( rustc, compiler) ) ;
286+ copy ( & rustc, & compiler) ;
286287
287288 // See if rustdoc exists to link it into place
288289 let rustdoc = exe ( "rustdoc" , host) ;
289290 let rustdoc_src = out_dir. join ( & rustdoc) ;
290291 let rustdoc_dst = bindir. join ( & rustdoc) ;
291292 if fs:: metadata ( & rustdoc_src) . is_ok ( ) {
292293 let _ = fs:: remove_file ( & rustdoc_dst) ;
293- t ! ( fs :: hard_link ( & rustdoc_src, & rustdoc_dst) ) ;
294+ copy ( & rustdoc_src, & rustdoc_dst) ;
294295 }
295296}
296297
@@ -329,8 +330,7 @@ fn add_to_sysroot(out_dir: &Path, sysroot_dst: &Path) {
329330 let ( _, path) = paths. iter ( ) . map ( |path| {
330331 ( mtime ( & path) . seconds ( ) , path)
331332 } ) . max ( ) . unwrap ( ) ;
332- t ! ( fs:: hard_link( & path,
333- sysroot_dst. join( path. file_name( ) . unwrap( ) ) ) ) ;
333+ copy ( & path, & sysroot_dst. join ( path. file_name ( ) . unwrap ( ) ) ) ;
334334 }
335335}
336336
0 commit comments