From 517a614fca91da9372e370f5468dd8b0b3e202ed Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 31 Aug 2017 18:43:56 +0200 Subject: [PATCH 1/2] use Cargo.lock file from rust-src if present --- src/sysroot.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 From b96e9ff8c8fa77799ad275a0bea789922daf62e2 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Wed, 6 Sep 2017 00:16:18 +0200 Subject: [PATCH 2/2] fix warning --- src/main.rs | 2 ++ 1 file changed, 2 insertions(+) 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;