Skip to content

Misc tweaks #50276

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

Merged
merged 2 commits into from
May 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down
1 change: 1 addition & 0 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/bootstrap/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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()
Expand Down
10 changes: 4 additions & 6 deletions src/bootstrap/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _);
Expand Down
11 changes: 11 additions & 0 deletions src/librustc/util/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
}

Expand Down
1 change: 0 additions & 1 deletion src/librustc_plugin/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 0 additions & 2 deletions src/librustc_plugin/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-make-fulldeps/libtest-json/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ OUTPUT_FILE := $(TMPDIR)/libtest-json-output.json

all:
$(RUSTC) --test f.rs
$(call RUN,f) -Z unstable-options --test-threads=1 --format=json > $(OUTPUT_FILE) || true
RUST_BACKTRACE=0 $(call RUN,f) -Z unstable-options --test-threads=1 --format=json > $(OUTPUT_FILE) || true

cat $(OUTPUT_FILE) | "$(PYTHON)" validate_json.py

Expand Down
1 change: 1 addition & 0 deletions src/tools/compiletest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
3 changes: 3 additions & 0 deletions src/tools/compiletest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
36 changes: 34 additions & 2 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<()> = {
Copy link
Member

@kennytm kennytm May 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot to use std::sync::Mutex;.

error[E0433]: failed to resolve. Use of undeclared type or module `Mutex`
  --> tools\compiletest\src\runtest.rs:50:13
   |
50 |             Mutex::new(())
   |             ^^^^^ Use of undeclared type or module `Mutex`
error[E0412]: cannot find type `Mutex` in this scope
  --> tools\compiletest\src\runtest.rs:49:26
   |
49 |         static ref LOCK: Mutex<()> = {
   |                          ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
   |
11 | use std::sync::Mutex;
   |
error[E0599]: no method named `lock` found for type `runtest::disable_error_reporting::LOCK` in the current scope
  --> tools\compiletest\src\runtest.rs:54:22
   |
48 | /     lazy_static! {
49 | |         static ref LOCK: Mutex<()> = {
50 | |             Mutex::new(())
51 | |         };
52 | |     }
   | |_____- method `lock` not found for this
53 |       // Error mode is a global variable, so lock it so only one thread will change it
54 |       let _lock = LOCK.lock().unwrap();
   |                        ^^^^
   |
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: aborting due to 3 previous errors

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) {
Expand Down Expand Up @@ -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())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this mean that we're only executing one test at a time since this is globally serialized?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. spawn doesn't wait for the completion of the process.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah oops yes, indeed!

.expect(&format!("failed to exec `{:?}`", &command));
if let Some(input) = input {
child
Expand Down
1 change: 1 addition & 0 deletions src/tools/tidy/src/deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down