Skip to content

Commit b24c849

Browse files
authored
Respect Cargo.lock file for sysroot build (#75)
Ensures that the same versions of crates.io dependencies such as compiler_builtins are used.
1 parent 9a37293 commit b24c849

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/sysroot.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::collections::hash_map::DefaultHasher;
22
use std::env;
3+
use std::fs;
34
use std::hash::{Hash, Hasher};
45
use std::io;
56
use std::io::Write;
@@ -56,6 +57,7 @@ fn build(
5657

5758
fn build_crate(
5859
crate_name: &str,
60+
lockfile: &Path,
5961
mut stoml: String,
6062
cmode: &CompilationMode,
6163
ctoml: &cargo::Toml,
@@ -79,6 +81,10 @@ fn build_crate(
7981
}
8082

8183
util::write(&td.join("Cargo.toml"), &stoml)?;
84+
fs::copy(lockfile, &td.join("Cargo.lock")).chain_err(||
85+
format!("failed to copy Cargo.lock from `{}` to `{}`",
86+
lockfile.display(), &td.join("Cargo.lock").display())
87+
)?;
8288
util::mkdir(&td.join("src"))?;
8389
util::write(&td.join("src/lib.rs"), "")?;
8490

@@ -188,7 +194,9 @@ version = "0.1.0"
188194
map.insert("lib".to_owned(), Value::Table(lib));
189195
stoml.push_str(&Value::Table(map).to_string());
190196

191-
build_crate("alloc", stoml, cmode, ctoml, dst, verbose)
197+
let lockfile = src.path().join("..").join("Cargo.lock");
198+
199+
build_crate("alloc", &lockfile, stoml, cmode, ctoml, dst, verbose)
192200
}
193201

194202
fn old_hash(cmode: &CompilationMode, home: &Home) -> Result<Option<u64>> {

0 commit comments

Comments
 (0)