@@ -15,7 +15,7 @@ use std::process::Command;
15
15
16
16
use build_helper:: output;
17
17
18
- use build:: util:: { exe, staticlib, libdir, mtime, is_dylib} ;
18
+ use build:: util:: { exe, staticlib, libdir, mtime, is_dylib, copy } ;
19
19
use build:: { Build , Compiler , Mode } ;
20
20
21
21
/// Build the standard library.
@@ -32,8 +32,8 @@ pub fn std<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
32
32
let libdir = build. sysroot_libdir ( compiler, target) ;
33
33
let _ = fs:: remove_dir_all ( & libdir) ;
34
34
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) ) ) ;
37
37
38
38
build_startup_objects ( build, target, & libdir) ;
39
39
@@ -77,8 +77,8 @@ pub fn std_link(build: &Build,
77
77
if host != compiler. host {
78
78
let _ = fs:: remove_dir_all ( & libdir) ;
79
79
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) ) ) ;
82
82
}
83
83
add_to_sysroot ( & out_dir, & libdir) ;
84
84
@@ -93,7 +93,7 @@ pub fn std_link(build: &Build,
93
93
/// Only required for musl targets that statically link to libc
94
94
fn copy_third_party_objects ( build : & Build , target : & str , into : & Path ) {
95
95
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) ) ;
97
97
}
98
98
}
99
99
@@ -119,7 +119,7 @@ fn build_startup_objects(build: &Build, target: &str, into: &Path) {
119
119
}
120
120
121
121
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) ) ;
123
123
}
124
124
}
125
125
@@ -240,9 +240,10 @@ fn libtest_shim(build: &Build, compiler: &Compiler, target: &str) -> PathBuf {
240
240
build. cargo_out ( compiler, Mode :: Libtest , target) . join ( "libtest_shim.rlib" )
241
241
}
242
242
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 ( ) )
246
247
}
247
248
248
249
/// Prepare a new compiler from the artifacts in `stage`
@@ -270,7 +271,7 @@ pub fn assemble_rustc(build: &Build, stage: u32, host: &str) {
270
271
for f in t ! ( fs:: read_dir( & src_libdir) ) . map ( |f| t ! ( f) ) {
271
272
let filename = f. file_name ( ) . into_string ( ) . unwrap ( ) ;
272
273
if is_dylib ( & filename) {
273
- t ! ( fs :: hard_link ( & f. path( ) , sysroot_libdir. join( & filename) ) ) ;
274
+ copy ( & f. path ( ) , & sysroot_libdir. join ( & filename) ) ;
274
275
}
275
276
}
276
277
@@ -282,15 +283,15 @@ pub fn assemble_rustc(build: &Build, stage: u32, host: &str) {
282
283
t ! ( fs:: create_dir_all( & bindir) ) ;
283
284
let compiler = build. compiler_path ( & Compiler :: new ( stage, host) ) ;
284
285
let _ = fs:: remove_file ( & compiler) ;
285
- t ! ( fs :: hard_link ( rustc, compiler) ) ;
286
+ copy ( & rustc, & compiler) ;
286
287
287
288
// See if rustdoc exists to link it into place
288
289
let rustdoc = exe ( "rustdoc" , host) ;
289
290
let rustdoc_src = out_dir. join ( & rustdoc) ;
290
291
let rustdoc_dst = bindir. join ( & rustdoc) ;
291
292
if fs:: metadata ( & rustdoc_src) . is_ok ( ) {
292
293
let _ = fs:: remove_file ( & rustdoc_dst) ;
293
- t ! ( fs :: hard_link ( & rustdoc_src, & rustdoc_dst) ) ;
294
+ copy ( & rustdoc_src, & rustdoc_dst) ;
294
295
}
295
296
}
296
297
@@ -329,8 +330,7 @@ fn add_to_sysroot(out_dir: &Path, sysroot_dst: &Path) {
329
330
let ( _, path) = paths. iter ( ) . map ( |path| {
330
331
( mtime ( & path) . seconds ( ) , path)
331
332
} ) . 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 ( ) ) ) ;
334
334
}
335
335
}
336
336
0 commit comments