Skip to content

Commit f8edf75

Browse files
committed
Merge branch 'master' into 7656-format-placeholder-code-when-generating-a-crate
2 parents aa7fe99 + b68b097 commit f8edf75

File tree

12 files changed

+653
-185
lines changed

12 files changed

+653
-185
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ git2-curl = "0.12.0"
3838
glob = "0.3.0"
3939
hex = "0.4"
4040
home = "0.5"
41-
humantime = "1.2.0"
41+
humantime = "2.0.0"
4242
ignore = "0.4.7"
4343
lazy_static = "1.2.0"
4444
jobserver = "0.1.13"

src/cargo/core/compiler/compilation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl<'cfg> Compilation<'cfg> {
101101
root_output: PathBuf::from("/"),
102102
deps_output: PathBuf::from("/"),
103103
host_deps_output: PathBuf::from("/"),
104-
host_dylib_path: bcx.info(default_kind).sysroot_host_libdir.clone(),
104+
host_dylib_path: bcx.info(CompileKind::Host).sysroot_host_libdir.clone(),
105105
target_dylib_path: bcx.info(default_kind).sysroot_target_libdir.clone(),
106106
tests: Vec::new(),
107107
binaries: Vec::new(),

src/cargo/core/compiler/context/mod.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ pub struct Context<'a, 'cfg> {
6969
/// metadata files in addition to the rlib itself. This is only filled in
7070
/// when `pipelining` above is enabled.
7171
rmeta_required: HashSet<Unit<'a>>,
72+
73+
/// When we're in jobserver-per-rustc process mode, this keeps those
74+
/// jobserver clients for each Unit (which eventually becomes a rustc
75+
/// process).
76+
pub rustc_clients: HashMap<Unit<'a>, Client>,
7277
}
7378

7479
impl<'a, 'cfg> Context<'a, 'cfg> {
@@ -112,6 +117,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
112117
unit_dependencies,
113118
files: None,
114119
rmeta_required: HashSet::new(),
120+
rustc_clients: HashMap::new(),
115121
pipelining,
116122
})
117123
}
@@ -491,4 +497,23 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
491497
pub fn rmeta_required(&self, unit: &Unit<'a>) -> bool {
492498
self.rmeta_required.contains(unit) || self.bcx.config.cli_unstable().timings.is_some()
493499
}
500+
501+
pub fn new_jobserver(&mut self) -> CargoResult<Client> {
502+
let tokens = self.bcx.build_config.jobs as usize;
503+
let client = Client::new(tokens).chain_err(|| "failed to create jobserver")?;
504+
505+
// Drain the client fully
506+
for i in 0..tokens {
507+
while let Err(e) = client.acquire_raw() {
508+
anyhow::bail!(
509+
"failed to fully drain {}/{} token from jobserver at startup: {:?}",
510+
i,
511+
tokens,
512+
e,
513+
);
514+
}
515+
}
516+
517+
Ok(client)
518+
}
494519
}

0 commit comments

Comments
 (0)