Skip to content

Commit ef3bb6f

Browse files
committed
Do not strip binaries in bootstrap everytime if they are unchanged
1 parent 8800ec1 commit ef3bb6f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/bootstrap/src/core/build_steps/compile.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use std::ffi::OsStr;
1212
use std::io::BufReader;
1313
use std::io::prelude::*;
1414
use std::path::{Path, PathBuf};
15+
use std::time::SystemTime;
1516
use std::{env, fs, str};
1617

1718
use serde_derive::Deserialize;
@@ -2578,7 +2579,17 @@ pub fn strip_debug(builder: &Builder<'_>, target: TargetSelection, path: &Path)
25782579
}
25792580

25802581
let previous_mtime = t!(t!(path.metadata()).modified());
2581-
command("strip").arg("--strip-debug").arg(path).run_capture(builder);
2582+
let stamp = BuildStamp::new(path.parent().unwrap())
2583+
.with_prefix(path.file_name().unwrap().to_str().unwrap())
2584+
.with_prefix("strip")
2585+
.add_stamp(previous_mtime.duration_since(SystemTime::UNIX_EPOCH).unwrap().as_nanos());
2586+
2587+
// Running strip can be relatively expensive (~1s on librustc_driver.so), so we don't rerun it
2588+
// if the file is unchanged.
2589+
if !stamp.is_up_to_date() {
2590+
command("strip").arg("--strip-debug").arg(path).run_capture(builder);
2591+
}
2592+
t!(stamp.write());
25822593

25832594
let file = t!(fs::File::open(path));
25842595

0 commit comments

Comments
 (0)