Skip to content
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

Rollup of 10 pull requests #42090

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1a7375b
Add an option to run rustbuild on low priority
Zoxc Mar 23, 2017
1b6a182
Improve the error management when /proc is not mounted
sylvestre May 17, 2017
b955296
misc doc improvements for std::env
tshepang May 17, 2017
f4e33a0
fix typo in libstd/sync/mpsc/mod.rs docs
seeekr May 18, 2017
1eb6639
Make documentation works again by removing two unnecessary ES6 pieces.
pravic May 18, 2017
474cc91
Use in-memory representation for Fingerprint that is more amenable to…
michaelwoerister May 17, 2017
4549423
Use 128 instead of 64 bits for DefPath hashes
michaelwoerister May 18, 2017
b2fc7b1
Add documentation for `ExitStatus`
citizen428 May 11, 2017
4f88106
update config name and description for low-priority
QuietMisdreavus May 18, 2017
cd6cbd7
Update the Cargo submodules
alexcrichton May 18, 2017
ecfdc9a
rustbuild: install rust-analysis and rust-src when extended build is …
Keruspe May 17, 2017
801e2b7
rustbuild: refactor install
Keruspe May 18, 2017
c5163aa
Fix x.py
nagisa May 18, 2017
21dd9fd
Rollup merge of #42024 - citizen428:docs/update-exitstatus, r=stevekl…
Mark-Simulacrum May 18, 2017
28050d8
Rollup merge of #42056 - sylvestre:master, r=alexcrichton
Mark-Simulacrum May 18, 2017
b384931
Rollup merge of #42067 - Keruspe:master, r=alexcrichton
Mark-Simulacrum May 18, 2017
59b5585
Rollup merge of #42069 - QuietMisdreavus:low_pri, r=alexcrichton
Mark-Simulacrum May 18, 2017
fa3c407
Rollup merge of #42070 - tshepang:env-misc, r=BurntSushi
Mark-Simulacrum May 18, 2017
284de04
Rollup merge of #42079 - seeekr:patch-1, r=steveklabnik
Mark-Simulacrum May 18, 2017
e528654
Rollup merge of #42080 - pravic:jquery-removal-fix, r=frewsxcv
Mark-Simulacrum May 18, 2017
b6ada54
Rollup merge of #42082 - michaelwoerister:wider_def_path_hashes, r=eddyb
Mark-Simulacrum May 18, 2017
3bb3b28
Rollup merge of #42086 - alexcrichton:update-cargo, r=Mark-Simulacrum
Mark-Simulacrum May 18, 2017
82daee0
Rollup merge of #42089 - nagisa:xpy-broke-on-py3-again⁈, r=alexcrichton
Mark-Simulacrum May 18, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,13 +398,14 @@ def run(self, args, env=None, cwd=None):
sys.exit(ret)

def output(self, args, env=None, cwd=None):
default_encoding = sys.getdefaultencoding()
proc = subprocess.Popen(args, stdout=subprocess.PIPE, env=env, cwd=cwd)
(out, err) = proc.communicate()
ret = proc.wait()
if ret != 0:
print(out)
sys.exit(ret)
return out
return out.decode(default_encoding)

def build_triple(self):
default_encoding = sys.getdefaultencoding()
Expand Down Expand Up @@ -570,10 +571,10 @@ def update_submodules(self):

for submod in submodules:
path, status = submod
if path.endswith(b"llvm") and \
if path.endswith('llvm') and \
(self.get_toml('llvm-config') or self.get_mk('CFG_LLVM_ROOT')):
continue
if path.endswith(b"jemalloc") and \
if path.endswith('jemalloc') and \
(self.get_toml('jemalloc') or self.get_mk('CFG_JEMALLOC_ROOT')):
continue
submod_path = os.path.join(self.rust_root, path)
Expand Down
3 changes: 3 additions & 0 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ pub struct Config {
pub backtrace: bool, // support for RUST_BACKTRACE

// misc
pub low_priority: bool,
pub channel: String,
pub quiet_tests: bool,
// Fallback musl-root for all targets
Expand Down Expand Up @@ -148,6 +149,7 @@ struct Build {
target: Vec<String>,
cargo: Option<String>,
rustc: Option<String>,
low_priority: Option<bool>,
compiler_docs: Option<bool>,
docs: Option<bool>,
submodules: Option<bool>,
Expand Down Expand Up @@ -306,6 +308,7 @@ impl Config {
config.nodejs = build.nodejs.map(PathBuf::from);
config.gdb = build.gdb.map(PathBuf::from);
config.python = build.python.map(PathBuf::from);
set(&mut config.low_priority, build.low_priority);
set(&mut config.compiler_docs, build.compiler_docs);
set(&mut config.docs, build.docs);
set(&mut config.submodules, build.submodules);
Expand Down
4 changes: 4 additions & 0 deletions src/bootstrap/config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@
# known-good version of OpenSSL, compile it, and link it to Cargo.
#openssl-static = false

# Run the build with low priority, by setting the process group's "nice" value
# to +10 on Unix platforms, and by using a "low priority" job object on Windows.
#low-priority = false

# =============================================================================
# General install configuration options
# =============================================================================
Expand Down
169 changes: 98 additions & 71 deletions src/bootstrap/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,83 +21,110 @@ use std::process::Command;
use Build;
use dist::{sanitize_sh, tmpdir};

/// Installs everything.
pub fn install(build: &Build, stage: u32, host: &str) {
let prefix_default = PathBuf::from("/usr/local");
let sysconfdir_default = PathBuf::from("/etc");
let docdir_default = PathBuf::from("share/doc/rust");
let bindir_default = PathBuf::from("bin");
let libdir_default = PathBuf::from("lib");
let mandir_default = PathBuf::from("share/man");
let prefix = build.config.prefix.as_ref().unwrap_or(&prefix_default);
let sysconfdir = build.config.sysconfdir.as_ref().unwrap_or(&sysconfdir_default);
let docdir = build.config.docdir.as_ref().unwrap_or(&docdir_default);
let bindir = build.config.bindir.as_ref().unwrap_or(&bindir_default);
let libdir = build.config.libdir.as_ref().unwrap_or(&libdir_default);
let mandir = build.config.mandir.as_ref().unwrap_or(&mandir_default);

let sysconfdir = prefix.join(sysconfdir);
let docdir = prefix.join(docdir);
let bindir = prefix.join(bindir);
let libdir = prefix.join(libdir);
let mandir = prefix.join(mandir);

let destdir = env::var_os("DESTDIR").map(PathBuf::from);

let prefix = add_destdir(&prefix, &destdir);
let sysconfdir = add_destdir(&sysconfdir, &destdir);
let docdir = add_destdir(&docdir, &destdir);
let bindir = add_destdir(&bindir, &destdir);
let libdir = add_destdir(&libdir, &destdir);
let mandir = add_destdir(&mandir, &destdir);

let empty_dir = build.out.join("tmp/empty_dir");
t!(fs::create_dir_all(&empty_dir));
if build.config.docs {
install_sh(&build, "docs", "rust-docs", &build.rust_package_vers(),
stage, host, &prefix, &sysconfdir, &docdir, &bindir, &libdir,
&mandir, &empty_dir);
}
pub struct Installer<'a> {
build: &'a Build,
prefix: PathBuf,
sysconfdir: PathBuf,
docdir: PathBuf,
bindir: PathBuf,
libdir: PathBuf,
mandir: PathBuf,
}

for target in build.config.target.iter() {
install_sh(&build, "std", "rust-std", &build.rust_package_vers(),
stage, target, &prefix, &sysconfdir, &docdir, &bindir, &libdir,
&mandir, &empty_dir);
}
impl<'a> Installer<'a> {
pub fn new(build: &'a Build) -> Installer<'a> {
let prefix_default = PathBuf::from("/usr/local");
let sysconfdir_default = PathBuf::from("/etc");
let docdir_default = PathBuf::from("share/doc/rust");
let bindir_default = PathBuf::from("bin");
let libdir_default = PathBuf::from("lib");
let mandir_default = PathBuf::from("share/man");
let prefix = build.config.prefix.as_ref().unwrap_or(&prefix_default);
let sysconfdir = build.config.sysconfdir.as_ref().unwrap_or(&sysconfdir_default);
let docdir = build.config.docdir.as_ref().unwrap_or(&docdir_default);
let bindir = build.config.bindir.as_ref().unwrap_or(&bindir_default);
let libdir = build.config.libdir.as_ref().unwrap_or(&libdir_default);
let mandir = build.config.mandir.as_ref().unwrap_or(&mandir_default);

let sysconfdir = prefix.join(sysconfdir);
let docdir = prefix.join(docdir);
let bindir = prefix.join(bindir);
let libdir = prefix.join(libdir);
let mandir = prefix.join(mandir);

let destdir = env::var_os("DESTDIR").map(PathBuf::from);

if build.config.extended {
install_sh(&build, "cargo", "cargo", &build.cargo_package_vers(),
stage, host, &prefix, &sysconfdir, &docdir, &bindir, &libdir,
&mandir, &empty_dir);
install_sh(&build, "rls", "rls", &build.rls_package_vers(),
stage, host, &prefix, &sysconfdir, &docdir, &bindir, &libdir,
&mandir, &empty_dir);
let prefix = add_destdir(&prefix, &destdir);
let sysconfdir = add_destdir(&sysconfdir, &destdir);
let docdir = add_destdir(&docdir, &destdir);
let bindir = add_destdir(&bindir, &destdir);
let libdir = add_destdir(&libdir, &destdir);
let mandir = add_destdir(&mandir, &destdir);

Installer {
build,
prefix,
sysconfdir,
docdir,
bindir,
libdir,
mandir,
}
}

install_sh(&build, "rustc", "rustc", &build.rust_package_vers(),
stage, host, &prefix, &sysconfdir, &docdir, &bindir, &libdir,
&mandir, &empty_dir);
/// Installs everything.
pub fn install(&self, stage: u32, host: &str) {
let empty_dir = self.build.out.join("tmp/empty_dir");
t!(fs::create_dir_all(&empty_dir));

t!(fs::remove_dir_all(&empty_dir));
}
if self.build.config.docs {
self.install_sh("docs", "rust-docs", &self.build.rust_package_vers(),
stage, Some(host), &empty_dir);
}

fn install_sh(build: &Build, package: &str, name: &str, version: &str, stage: u32, host: &str,
prefix: &Path, sysconfdir: &Path, docdir: &Path, bindir: &Path, libdir: &Path,
mandir: &Path, empty_dir: &Path) {
println!("Install {} stage{} ({})", package, stage, host);
let package_name = format!("{}-{}-{}", name, version, host);

let mut cmd = Command::new("sh");
cmd.current_dir(empty_dir)
.arg(sanitize_sh(&tmpdir(build).join(&package_name).join("install.sh")))
.arg(format!("--prefix={}", sanitize_sh(prefix)))
.arg(format!("--sysconfdir={}", sanitize_sh(sysconfdir)))
.arg(format!("--docdir={}", sanitize_sh(docdir)))
.arg(format!("--bindir={}", sanitize_sh(bindir)))
.arg(format!("--libdir={}", sanitize_sh(libdir)))
.arg(format!("--mandir={}", sanitize_sh(mandir)))
.arg("--disable-ldconfig");
build.run(&mut cmd);
for target in self.build.config.target.iter() {
self.install_sh("std", "rust-std", &self.build.rust_package_vers(),
stage, Some(target), &empty_dir);
}

if self.build.config.extended {
self.install_sh("cargo", "cargo", &self.build.cargo_package_vers(),
stage, Some(host), &empty_dir);
self.install_sh("rls", "rls", &self.build.rls_package_vers(),
stage, Some(host), &empty_dir);
self.install_sh("analysis", "rust-analysis", &self.build.rust_package_vers(),
stage, Some(host), &empty_dir);
self.install_sh("src", "rust-src", &self.build.rust_package_vers(),
stage, None, &empty_dir);
}

self.install_sh("rustc", "rustc", &self.build.rust_package_vers(),
stage, Some(host), &empty_dir);

t!(fs::remove_dir_all(&empty_dir));
}

fn install_sh(&self, package: &str, name: &str, version: &str,
stage: u32, host: Option<&str>, empty_dir: &Path) {
println!("Install {} stage{} ({:?})", package, stage, host);
let package_name = if let Some(host) = host {
format!("{}-{}-{}", name, version, host)
} else {
format!("{}-{}", name, version)
};

let mut cmd = Command::new("sh");
cmd.current_dir(empty_dir)
.arg(sanitize_sh(&tmpdir(self.build).join(&package_name).join("install.sh")))
.arg(format!("--prefix={}", sanitize_sh(&self.prefix)))
.arg(format!("--sysconfdir={}", sanitize_sh(&self.sysconfdir)))
.arg(format!("--docdir={}", sanitize_sh(&self.docdir)))
.arg(format!("--bindir={}", sanitize_sh(&self.bindir)))
.arg(format!("--libdir={}", sanitize_sh(&self.libdir)))
.arg(format!("--mandir={}", sanitize_sh(&self.mandir)))
.arg("--disable-ldconfig");
self.build.run(&mut cmd);
}
}

fn add_destdir(path: &Path, destdir: &Option<PathBuf>) -> PathBuf {
Expand Down
9 changes: 8 additions & 1 deletion src/bootstrap/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
use std::env;
use std::io;
use std::mem;
use Build;

type HANDLE = *mut u8;
type BOOL = i32;
Expand All @@ -60,8 +61,10 @@ const DUPLICATE_SAME_ACCESS: DWORD = 0x2;
const PROCESS_DUP_HANDLE: DWORD = 0x40;
const JobObjectExtendedLimitInformation: JOBOBJECTINFOCLASS = 9;
const JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE: DWORD = 0x2000;
const JOB_OBJECT_LIMIT_PRIORITY_CLASS: DWORD = 0x00000020;
const SEM_FAILCRITICALERRORS: UINT = 0x0001;
const SEM_NOGPFAULTERRORBOX: UINT = 0x0002;
const BELOW_NORMAL_PRIORITY_CLASS: DWORD = 0x00004000;

extern "system" {
fn CreateJobObjectW(lpJobAttributes: *mut u8, lpName: *const u8) -> HANDLE;
Expand Down Expand Up @@ -118,7 +121,7 @@ struct JOBOBJECT_BASIC_LIMIT_INFORMATION {
SchedulingClass: DWORD,
}

pub unsafe fn setup() {
pub unsafe fn setup(build: &mut Build) {
// Tell Windows to not show any UI on errors (such as not finding a required dll
// during startup or terminating abnormally). This is important for running tests,
// since some of them use abnormal termination by design.
Expand All @@ -136,6 +139,10 @@ pub unsafe fn setup() {
// children will reside in the job by default.
let mut info = mem::zeroed::<JOBOBJECT_EXTENDED_LIMIT_INFORMATION>();
info.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
if build.config.low_priority {
info.BasicLimitInformation.LimitFlags |= JOB_OBJECT_LIMIT_PRIORITY_CLASS;
info.BasicLimitInformation.PriorityClass = BELOW_NORMAL_PRIORITY_CLASS;
}
let r = SetInformationJobObject(job,
JobObjectExtendedLimitInformation,
&mut info as *mut _ as LPVOID,
Expand Down
29 changes: 26 additions & 3 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules {
.run(move |s| dist::rls(build, s.stage, s.target));
rules.dist("install", "path/to/nowhere")
.dep(|s| s.name("default:dist"))
.run(move |s| install::install(build, s.stage, s.target));
.run(move |s| install::Installer::new(build).install(s.stage, s.target));
rules.dist("dist-cargo", "cargo")
.host(true)
.only_host_build(true)
Expand Down
Loading