Misc tweaks

This commit is contained in:
John Kåre Alsaker 2018-04-08 13:44:29 +02:00
parent c338bd539e
commit e24cbe2da0
13 changed files with 72 additions and 11 deletions

View File

@ -346,6 +346,9 @@
# Whether to deny warnings in crates
#deny-warnings = true
# Print backtrace on internal compiler errors during bootstrap
#backtrace-on-ice = false
# =============================================================================
# Options for specific targets
#

1
src/Cargo.lock generated
View File

@ -390,6 +390,7 @@ dependencies = [
"env_logger 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)",
"filetime 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"miow 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -107,6 +107,13 @@ fn main() {
env::join_paths(&dylib_path).unwrap());
let mut maybe_crate = None;
// Print backtrace in case of ICE
if env::var("RUSTC_BACKTRACE_ON_ICE").is_ok() && env::var("RUST_BACKTRACE").is_err() {
cmd.env("RUST_BACKTRACE", "1");
}
cmd.env("RUSTC_BREAK_ON_ICE", "1");
if let Some(target) = target {
// The stage0 compiler has a special sysroot distinct from what we
// actually downloaded, so we just always pass the `--sysroot` option.

View File

@ -706,6 +706,10 @@ impl<'a> Builder<'a> {
cargo.env("RUSTC_PRINT_STEP_TIMINGS", "1");
}
if self.config.backtrace_on_ice {
cargo.env("RUSTC_BACKTRACE_ON_ICE", "1");
}
cargo.env("RUSTC_VERBOSE", format!("{}", self.verbosity));
// in std, we want to avoid denying warnings for stage 0 as that makes cfg's painful.

View File

@ -72,6 +72,7 @@ pub struct Config {
pub dry_run: bool,
pub deny_warnings: bool,
pub backtrace_on_ice: bool,
// llvm codegen options
pub llvm_enabled: bool,
@ -306,6 +307,7 @@ struct Rust {
wasm_syscall: Option<bool>,
lld: Option<bool>,
deny_warnings: Option<bool>,
backtrace_on_ice: Option<bool>,
}
/// TOML representation of how each build target is configured.
@ -531,6 +533,7 @@ impl Config {
config.musl_root = rust.musl_root.clone().map(PathBuf::from);
config.save_toolstates = rust.save_toolstates.clone().map(PathBuf::from);
set(&mut config.deny_warnings, rust.deny_warnings.or(flags.warnings));
set(&mut config.backtrace_on_ice, rust.backtrace_on_ice);
if let Some(ref backends) = rust.codegen_backends {
config.rust_codegen_backends = backends.iter()

View File

@ -122,12 +122,10 @@ struct JOBOBJECT_BASIC_LIMIT_INFORMATION {
}
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.
// This mode is inherited by all child processes.
let mode = SetErrorMode(SEM_NOGPFAULTERRORBOX); // read inherited flags
SetErrorMode(mode | SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
// Enable the Windows Error Reporting dialog which msys disables,
// so we can JIT debug rustc
let mode = SetErrorMode(0);
SetErrorMode(mode & !SEM_NOGPFAULTERRORBOX);
// Create a new job object for us to use
let job = CreateJobObjectW(0 as *mut _, 0 as *const _);

View File

@ -58,6 +58,17 @@ fn panic_hook(info: &panic::PanicInfo) {
if backtrace {
TyCtxt::try_print_query_stack();
}
#[cfg(windows)]
unsafe {
if env::var("RUSTC_BREAK_ON_ICE").is_ok() {
extern "system" {
fn DebugBreak();
}
// Trigger a debugger if we crashed during bootstrap
DebugBreak();
}
}
}
}

View File

@ -65,7 +65,6 @@
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![feature(rustc_diagnostic_macros)]
#![feature(staged_api)]
#[macro_use] extern crate syntax;

View File

@ -128,8 +128,6 @@ impl<'a> Registry<'a> {
/// This can be used in place of `register_syntax_extension` to register legacy custom derives
/// (i.e. attribute syntax extensions whose name begins with `derive_`). Legacy custom
/// derives defined by this function do not trigger deprecation warnings when used.
#[unstable(feature = "rustc_private", issue = "27812")]
#[rustc_deprecated(since = "1.15.0", reason = "replaced by macros 1.1 (RFC 1861)")]
pub fn register_custom_derive(&mut self, name: ast::Name, extension: SyntaxExtension) {
assert!(name.as_str().starts_with("derive_"));
self.whitelisted_custom_derives.push(name);

View File

@ -19,5 +19,6 @@ rustfix = "0.2"
libc = "0.2"
[target.'cfg(windows)'.dependencies]
lazy_static = "1.0"
miow = "0.3"
winapi = { version = "0.3", features = ["winerror"] }

View File

@ -23,6 +23,9 @@ extern crate libc;
extern crate log;
extern crate regex;
#[macro_use]
#[cfg(windows)]
extern crate lazy_static;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
extern crate test;

View File

@ -38,6 +38,39 @@ use std::str;
use extract_gdb_version;
#[cfg(windows)]
fn disable_error_reporting<F: FnOnce() -> R, R>(f: F) -> R {
use std::sync::Mutex;
const SEM_NOGPFAULTERRORBOX: u32 = 0x0002;
extern "system" {
fn SetErrorMode(mode: u32) -> u32;
}
lazy_static! {
static ref LOCK: Mutex<()> = {
Mutex::new(())
};
}
// Error mode is a global variable, so lock it so only one thread will change it
let _lock = LOCK.lock().unwrap();
// Tell Windows to not show any UI on errors (such as terminating abnormally).
// This is important for running tests, since some of them use abnormal
// termination by design. This mode is inherited by all child processes.
unsafe {
let old_mode = SetErrorMode(SEM_NOGPFAULTERRORBOX); // read inherited flags
SetErrorMode(old_mode | SEM_NOGPFAULTERRORBOX);
let r = f();
SetErrorMode(old_mode);
r
}
}
#[cfg(not(windows))]
fn disable_error_reporting<F: FnOnce() -> R, R>(f: F) -> R {
f()
}
/// The name of the environment variable that holds dynamic library locations.
pub fn dylib_env_var() -> &'static str {
if cfg!(windows) {
@ -1578,8 +1611,7 @@ impl<'test> TestCx<'test> {
let newpath = env::join_paths(&path).unwrap();
command.env(dylib_env_var(), newpath);
let mut child = command
.spawn()
let mut child = disable_error_reporting(|| command.spawn())
.expect(&format!("failed to exec `{:?}`", &command));
if let Some(input) = input {
child

View File

@ -73,6 +73,7 @@ static WHITELIST: &'static [Crate] = &[
Crate("flate2"),
Crate("fuchsia-zircon"),
Crate("fuchsia-zircon-sys"),
Crate("getopts"),
Crate("humantime"),
Crate("jobserver"),
Crate("kernel32-sys"),