-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Add an option to run rustbuild on low priority on Windows and Unix #42069
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -152,6 +152,9 @@ | |
| # known-good version of OpenSSL, compile it, and link it to Cargo. | ||
| #openssl-static = false | ||
|
|
||
| # Run the build with low priority | ||
| #low_priority = false | ||
|
||
|
|
||
| # ============================================================================= | ||
| # General install configuration options | ||
| # ============================================================================= | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,6 +76,9 @@ extern crate num_cpus; | |
| extern crate rustc_serialize; | ||
| extern crate toml; | ||
|
|
||
| #[cfg(unix)] | ||
| extern crate libc; | ||
|
|
||
| use std::cmp; | ||
| use std::collections::HashMap; | ||
| use std::env; | ||
|
|
@@ -108,9 +111,29 @@ pub mod util; | |
| #[cfg(windows)] | ||
| mod job; | ||
|
|
||
| #[cfg(not(windows))] | ||
| #[cfg(unix)] | ||
| mod job { | ||
| pub unsafe fn setup() {} | ||
| use libc; | ||
|
|
||
| //apparently glibc defines their own enum for this parameter, in a different type | ||
| #[cfg(not(any(target_env = "musl", target_env = "musleabi", target_env = "musleabihf", | ||
| target_os = "emscripten", target_arch = "mips", target_arch = "mipsel")))] | ||
| const PRIO_PGRP: libc::c_uint = libc::PRIO_PGRP as libc::c_uint; | ||
|
||
| #[cfg(any(target_env = "musl", target_env = "musleabi", target_env = "musleabihf", | ||
| target_os = "emscripten", target_arch = "mips", target_arch = "mipsel"))] | ||
| const PRIO_PGRP: libc::c_int = libc::PRIO_PGRP; | ||
|
|
||
| pub unsafe fn setup(build: &mut ::Build) { | ||
| if build.config.low_priority { | ||
| libc::setpriority(PRIO_PGRP, 0, 10); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[cfg(not(any(unix, windows)))] | ||
| mod job { | ||
| pub unsafe fn setup(_build: &mut ::Build) { | ||
| } | ||
| } | ||
|
|
||
| pub use config::Config; | ||
|
|
@@ -263,7 +286,7 @@ impl Build { | |
| /// Executes the entire build, as configured by the flags and configuration. | ||
| pub fn build(&mut self) { | ||
| unsafe { | ||
| job::setup(); | ||
| job::setup(self); | ||
| } | ||
|
|
||
| if let Subcommand::Clean = self.flags.cmd { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you expand this to explain a bit about what this means? Referencing
nicehere for Unix and "low priority" job object for Windows would probably be sufficient.