Skip to content

Commit cfcac37

Browse files
committed
Auto merge of #44607 - alexcrichton:rustbuild-no-j, r=Mark-Simulacrum
rustbuild: Don't pass `-j` if called by `make` In these situations Cargo just prints out a warning about ignoring the flag anyway, so let `make` take care of jobs and whatnot instead of getting warnings printed.
2 parents 1cdd689 + 4857bb7 commit cfcac37

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/bootstrap/builder.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use std::any::Any;
12+
use std::cell::RefCell;
13+
use std::collections::BTreeSet;
14+
use std::env;
1115
use std::fmt::Debug;
16+
use std::fs;
1217
use std::hash::Hash;
13-
use std::cell::RefCell;
18+
use std::ops::Deref;
1419
use std::path::{Path, PathBuf};
1520
use std::process::Command;
16-
use std::fs;
17-
use std::ops::Deref;
18-
use std::any::Any;
19-
use std::collections::BTreeSet;
2021

2122
use compile;
2223
use install;
@@ -437,9 +438,14 @@ impl<'a> Builder<'a> {
437438
let out_dir = self.stage_out(compiler, mode);
438439
cargo.env("CARGO_TARGET_DIR", out_dir)
439440
.arg(cmd)
440-
.arg("-j").arg(self.jobs().to_string())
441441
.arg("--target").arg(target);
442442

443+
// If we were invoked from `make` then that's already got a jobserver
444+
// set up for us so no need to tell Cargo about jobs all over again.
445+
if env::var_os("MAKEFLAGS").is_none() && env::var_os("MFLAGS").is_none() {
446+
cargo.arg("-j").arg(self.jobs().to_string());
447+
}
448+
443449
// FIXME: Temporary fix for https://github.com/rust-lang/cargo/issues/3005
444450
// Force cargo to output binaries with disambiguating hashes in the name
445451
cargo.env("__CARGO_DEFAULT_LIB_METADATA", &self.config.channel);

0 commit comments

Comments
 (0)