@@ -1115,8 +1115,11 @@ impl Build {
1115
1115
1116
1116
objects. push ( Object :: new ( file. to_path_buf ( ) , obj) ) ;
1117
1117
}
1118
- self . compile_objects ( & objects) ?;
1119
- self . assemble ( lib_name, & dst. join ( gnu_lib_name) , & objects) ?;
1118
+
1119
+ let print = PrintThread :: new ( ) ?;
1120
+
1121
+ self . compile_objects ( & objects, & print) ?;
1122
+ self . assemble ( lib_name, & dst. join ( gnu_lib_name) , & objects, & print) ?;
1120
1123
1121
1124
if self . get_target ( ) ?. contains ( "msvc" ) {
1122
1125
let compiler = self . get_base_compiler ( ) ?;
@@ -1257,7 +1260,7 @@ impl Build {
1257
1260
}
1258
1261
1259
1262
#[ cfg( feature = "parallel" ) ]
1260
- fn compile_objects ( & self , objs : & [ Object ] ) -> Result < ( ) , Error > {
1263
+ fn compile_objects ( & self , objs : & [ Object ] , print : & PrintThread ) -> Result < ( ) , Error > {
1261
1264
use std:: sync:: Once ;
1262
1265
1263
1266
// Limit our parallelism globally with a jobserver. Start off by
@@ -1286,7 +1289,6 @@ impl Build {
1286
1289
// With all that in mind we compile all objects in a loop here, after we
1287
1290
// acquire the appropriate tokens, Once all objects have been compiled
1288
1291
// we wait on all the processes and propagate the results of compilation.
1289
- let print = PrintThread :: new ( ) ?;
1290
1292
1291
1293
let children = objs
1292
1294
. iter ( )
@@ -1369,12 +1371,10 @@ impl Build {
1369
1371
}
1370
1372
1371
1373
#[ cfg( not( feature = "parallel" ) ) ]
1372
- fn compile_objects ( & self , objs : & [ Object ] ) -> Result < ( ) , Error > {
1373
- let print = PrintThread :: new ( ) ?;
1374
-
1374
+ fn compile_objects ( & self , objs : & [ Object ] , print : & PrintThread ) -> Result < ( ) , Error > {
1375
1375
for obj in objs {
1376
1376
let ( mut cmd, name) = self . create_compile_object_cmd ( obj) ?;
1377
- run_inner ( & mut cmd, & name, print. pipe_writer_cloned ( ) ? . unwrap ( ) ) ?;
1377
+ run ( & mut cmd, & name, print) ?;
1378
1378
}
1379
1379
1380
1380
Ok ( ( ) )
@@ -2087,21 +2087,27 @@ impl Build {
2087
2087
Ok ( ( cmd, tool. to_string ( ) ) )
2088
2088
}
2089
2089
2090
- fn assemble ( & self , lib_name : & str , dst : & Path , objs : & [ Object ] ) -> Result < ( ) , Error > {
2090
+ fn assemble (
2091
+ & self ,
2092
+ lib_name : & str ,
2093
+ dst : & Path ,
2094
+ objs : & [ Object ] ,
2095
+ print : & PrintThread ,
2096
+ ) -> Result < ( ) , Error > {
2091
2097
// Delete the destination if it exists as we want to
2092
2098
// create on the first iteration instead of appending.
2093
- let _ = fs:: remove_file ( & dst) ;
2099
+ let _ = fs:: remove_file ( dst) ;
2094
2100
2095
2101
// Add objects to the archive in limited-length batches. This helps keep
2096
2102
// the length of the command line within a reasonable length to avoid
2097
2103
// blowing system limits on limiting platforms like Windows.
2098
2104
let objs: Vec < _ > = objs
2099
2105
. iter ( )
2100
- . map ( |o| o. dst . clone ( ) )
2101
- . chain ( self . objects . iter ( ) . map ( |path| ( * * path ) . to_owned ( ) ) )
2106
+ . map ( |o| o. dst . as_path ( ) )
2107
+ . chain ( self . objects . iter ( ) . map ( std :: ops :: Deref :: deref ) )
2102
2108
. collect ( ) ;
2103
2109
for chunk in objs. chunks ( 100 ) {
2104
- self . assemble_progressive ( dst, chunk) ?;
2110
+ self . assemble_progressive ( dst, chunk, print ) ?;
2105
2111
}
2106
2112
2107
2113
if self . cuda && self . cuda_file_count ( ) > 0 {
@@ -2111,12 +2117,9 @@ impl Build {
2111
2117
let out_dir = self . get_out_dir ( ) ?;
2112
2118
let dlink = out_dir. join ( lib_name. to_owned ( ) + "_dlink.o" ) ;
2113
2119
let mut nvcc = self . get_compiler ( ) . to_command ( ) ;
2114
- nvcc. arg ( "--device-link" )
2115
- . arg ( "-o" )
2116
- . arg ( dlink. clone ( ) )
2117
- . arg ( dst) ;
2118
- run ( & mut nvcc, "nvcc" ) ?;
2119
- self . assemble_progressive ( dst, & [ dlink] ) ?;
2120
+ nvcc. arg ( "--device-link" ) . arg ( "-o" ) . arg ( & dlink) . arg ( dst) ;
2121
+ run ( & mut nvcc, "nvcc" , print) ?;
2122
+ self . assemble_progressive ( dst, & [ dlink. as_path ( ) ] , print) ?;
2120
2123
}
2121
2124
2122
2125
let target = self . get_target ( ) ?;
@@ -2148,13 +2151,18 @@ impl Build {
2148
2151
// NOTE: We add `s` even if flags were passed using $ARFLAGS/ar_flag, because `s`
2149
2152
// here represents a _mode_, not an arbitrary flag. Further discussion of this choice
2150
2153
// can be seen in https://github.com/rust-lang/cc-rs/pull/763.
2151
- run ( ar. arg ( "s" ) . arg ( dst) , & cmd) ?;
2154
+ run ( ar. arg ( "s" ) . arg ( dst) , & cmd, print ) ?;
2152
2155
}
2153
2156
2154
2157
Ok ( ( ) )
2155
2158
}
2156
2159
2157
- fn assemble_progressive ( & self , dst : & Path , objs : & [ PathBuf ] ) -> Result < ( ) , Error > {
2160
+ fn assemble_progressive (
2161
+ & self ,
2162
+ dst : & Path ,
2163
+ objs : & [ & Path ] ,
2164
+ print : & PrintThread ,
2165
+ ) -> Result < ( ) , Error > {
2158
2166
let target = self . get_target ( ) ?;
2159
2167
2160
2168
if target. contains ( "msvc" ) {
@@ -2175,7 +2183,7 @@ impl Build {
2175
2183
cmd. arg ( dst) ;
2176
2184
}
2177
2185
cmd. args ( objs) ;
2178
- run ( & mut cmd, & program) ?;
2186
+ run ( & mut cmd, & program, print ) ?;
2179
2187
} else {
2180
2188
let ( mut ar, cmd, _any_flags) = self . get_ar ( ) ?;
2181
2189
@@ -2206,7 +2214,7 @@ impl Build {
2206
2214
// NOTE: We add cq here regardless of whether $ARFLAGS/ar_flag have been used because
2207
2215
// it dictates the _mode_ ar runs in, which the setter of $ARFLAGS/ar_flag can't
2208
2216
// dictate. See https://github.com/rust-lang/cc-rs/pull/763 for further discussion.
2209
- run ( ar. arg ( "cq" ) . arg ( dst) . args ( objs) , & cmd) ?;
2217
+ run ( ar. arg ( "cq" ) . arg ( dst) . args ( objs) , & cmd, print ) ?;
2210
2218
}
2211
2219
2212
2220
Ok ( ( ) )
@@ -3507,9 +3515,8 @@ fn run_inner(cmd: &mut Command, program: &str, pipe_writer: File) -> Result<(),
3507
3515
wait_on_child ( cmd, program, & mut child)
3508
3516
}
3509
3517
3510
- fn run ( cmd : & mut Command , program : & str ) -> Result < ( ) , Error > {
3511
- let mut print = PrintThread :: new ( ) ?;
3512
- run_inner ( cmd, program, print. pipe_writer ( ) . take ( ) . unwrap ( ) ) ?;
3518
+ fn run ( cmd : & mut Command , program : & str , print : & PrintThread ) -> Result < ( ) , Error > {
3519
+ run_inner ( cmd, program, print. pipe_writer_cloned ( ) ?. unwrap ( ) ) ?;
3513
3520
3514
3521
Ok ( ( ) )
3515
3522
}
0 commit comments