@@ -251,14 +251,17 @@ fn rustc<'a, 'cfg>(
251
251
add_custom_env ( & mut rustc, & script_outputs, current_id, kind) ?;
252
252
}
253
253
254
- for output in outputs. iter ( ) {
255
- // If there is both an rmeta and rlib, rustc will prefer to use the
256
- // rlib, even if it is older. Therefore, we must delete the rlib to
257
- // force using the new rmeta.
258
- if output. path . extension ( ) == Some ( OsStr :: new ( "rmeta" ) ) {
259
- let dst = root. join ( & output. path ) . with_extension ( "rlib" ) ;
260
- if dst. exists ( ) {
261
- paths:: remove_file ( & dst) ?;
254
+ // Don't touch any file when we are generating build-plan
255
+ if !build_plan {
256
+ for output in outputs. iter ( ) {
257
+ // If there is both an rmeta and rlib, rustc will prefer to use the
258
+ // rlib, even if it is older. Therefore, we must delete the rlib to
259
+ // force using the new rmeta.
260
+ if output. path . extension ( ) == Some ( OsStr :: new ( "rmeta" ) ) {
261
+ let dst = root. join ( & output. path ) . with_extension ( "rlib" ) ;
262
+ if dst. exists ( ) {
263
+ paths:: remove_file ( & dst) ?;
264
+ }
262
265
}
263
266
}
264
267
}
@@ -277,9 +280,10 @@ fn rustc<'a, 'cfg>(
277
280
}
278
281
279
282
state. running ( & rustc) ;
280
- let timestamp = paths:: set_invocation_time ( & fingerprint_dir) ?;
281
- if build_plan {
283
+ let timestamp = if build_plan {
282
284
state. build_plan ( buildkey, rustc. clone ( ) , outputs. clone ( ) ) ;
285
+ // Build plan should not touch the timestamp
286
+ None
283
287
} else {
284
288
exec. exec (
285
289
rustc,
@@ -291,7 +295,8 @@ fn rustc<'a, 'cfg>(
291
295
)
292
296
. map_err ( internal_if_simple_exit_code)
293
297
. chain_err ( || format ! ( "could not compile `{}`." , name) ) ?;
294
- }
298
+ Some ( paths:: set_invocation_time ( & fingerprint_dir) ?)
299
+ } ;
295
300
296
301
if do_rename && real_name != crate_name {
297
302
let dst = & outputs[ 0 ] . path ;
@@ -324,7 +329,10 @@ fn rustc<'a, 'cfg>(
324
329
rustc_dep_info_loc. display( )
325
330
) )
326
331
} ) ?;
327
- filetime:: set_file_times ( dep_info_loc, timestamp, timestamp) ?;
332
+
333
+ if let Some ( timestamp) = timestamp {
334
+ filetime:: set_file_times ( dep_info_loc, timestamp, timestamp) ?;
335
+ }
328
336
}
329
337
330
338
Ok ( ( ) )
0 commit comments