Skip to content

Commit 517a614

Browse files
committed
use Cargo.lock file from rust-src if present
1 parent bace2df commit 517a614

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/sysroot.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::hash::{Hash, Hasher};
44
use std::path::PathBuf;
55
use std::process::Command;
66
use std::io::{self, Write};
7+
use std::fs;
78

89
use rustc_version::VersionMeta;
910
use tempdir::TempDir;
@@ -34,6 +35,7 @@ fn build(
3435
ctoml: &cargo::Toml,
3536
home: &Home,
3637
rustflags: &Rustflags,
38+
src: &Src,
3739
hash: u64,
3840
verbose: bool,
3941
) -> Result<()> {
@@ -66,6 +68,15 @@ version = "0.0.0"
6668
stoml.push_str(&profile.to_string())
6769
}
6870

71+
{
72+
// Recent rust-src comes with a lockfile for libstd. Use it.
73+
let lockfile = src.path().join("Cargo.lock");
74+
if lockfile.exists() {
75+
fs::copy(lockfile, &td.join("Cargo.lock")).chain_err(
76+
|| "couldn't copy lock file",
77+
)?;
78+
}
79+
}
6980
util::write(&td.join("Cargo.toml"), &stoml)?;
7081
util::mkdir(&td.join("src"))?;
7182
util::write(&td.join("src/lib.rs"), "")?;
@@ -187,7 +198,7 @@ pub fn update(
187198
let hash = hash(cmode, &blueprint, rustflags, &ctoml, meta)?;
188199

189200
if old_hash(cmode, home)? != Some(hash) {
190-
build(cmode, blueprint, &ctoml, home, rustflags, hash, verbose)?;
201+
build(cmode, blueprint, &ctoml, home, rustflags, src, hash, verbose)?;
191202
}
192203

193204
// copy host artifacts into the sysroot, if necessary

0 commit comments

Comments
 (0)