diff --git a/src/main.rs b/src/main.rs index dea90d1..a4ec6e5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,8 @@ #[macro_use] extern crate error_chain; extern crate fs2; +#[cfg(any(all(target_os = "linux", not(target_env = "musl")), + target_os = "macos"))] extern crate libc; extern crate rustc_version; extern crate serde_json; diff --git a/src/sysroot.rs b/src/sysroot.rs index 06d6814..c9828b9 100644 --- a/src/sysroot.rs +++ b/src/sysroot.rs @@ -4,6 +4,7 @@ use std::hash::{Hash, Hasher}; use std::path::PathBuf; use std::process::Command; use std::io::{self, Write}; +use std::fs; use rustc_version::VersionMeta; use tempdir::TempDir; @@ -34,6 +35,7 @@ fn build( ctoml: &cargo::Toml, home: &Home, rustflags: &Rustflags, + src: &Src, hash: u64, verbose: bool, ) -> Result<()> { @@ -66,6 +68,15 @@ version = "0.0.0" stoml.push_str(&profile.to_string()) } + { + // Recent rust-src comes with a lockfile for libstd. Use it. + let lockfile = src.path().join("Cargo.lock"); + if lockfile.exists() { + fs::copy(lockfile, &td.join("Cargo.lock")).chain_err( + || "couldn't copy lock file", + )?; + } + } util::write(&td.join("Cargo.toml"), &stoml)?; util::mkdir(&td.join("src"))?; util::write(&td.join("src/lib.rs"), "")?; @@ -187,7 +198,7 @@ pub fn update( let hash = hash(cmode, &blueprint, rustflags, &ctoml, meta)?; if old_hash(cmode, home)? != Some(hash) { - build(cmode, blueprint, &ctoml, home, rustflags, hash, verbose)?; + build(cmode, blueprint, &ctoml, home, rustflags, src, hash, verbose)?; } // copy host artifacts into the sysroot, if necessary