Skip to content

Commit 24c5f15

Browse files
committed
Auto merge of #50276 - Zoxc:build-cleanup, r=alexcrichton
Misc tweaks This: - ~~Add explicit dependencies on `getops`~~ - Fixes the libtest-json test when `RUST_BACKTRACE=1` is set - ~~Sets `opt-level` to `3`~~ - Removes the use of `staged_api` from `rustc_plugin` - ~~Enables the Windows Error Reporting dialog when running rustc during bootstrapping~~ - Disables Windows Error Reporting dialog when running compiletest tests - Enables backtraces when running rustc during bootstrapping - ~~Removes the `librustc` dependency on `libtest`~~ - Triggers JIT debugging on Windows if rustc panics during bootstrapping r? @alexcrichton
2 parents fa30ae5 + e24cbe2 commit 24c5f15

File tree

14 files changed

+73
-12
lines changed

14 files changed

+73
-12
lines changed

config.toml.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,9 @@
346346
# Whether to deny warnings in crates
347347
#deny-warnings = true
348348

349+
# Print backtrace on internal compiler errors during bootstrap
350+
#backtrace-on-ice = false
351+
349352
# =============================================================================
350353
# Options for specific targets
351354
#

src/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bootstrap/bin/rustc.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ fn main() {
107107
env::join_paths(&dylib_path).unwrap());
108108
let mut maybe_crate = None;
109109

110+
// Print backtrace in case of ICE
111+
if env::var("RUSTC_BACKTRACE_ON_ICE").is_ok() && env::var("RUST_BACKTRACE").is_err() {
112+
cmd.env("RUST_BACKTRACE", "1");
113+
}
114+
115+
cmd.env("RUSTC_BREAK_ON_ICE", "1");
116+
110117
if let Some(target) = target {
111118
// The stage0 compiler has a special sysroot distinct from what we
112119
// actually downloaded, so we just always pass the `--sysroot` option.

src/bootstrap/builder.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,10 @@ impl<'a> Builder<'a> {
706706
cargo.env("RUSTC_PRINT_STEP_TIMINGS", "1");
707707
}
708708

709+
if self.config.backtrace_on_ice {
710+
cargo.env("RUSTC_BACKTRACE_ON_ICE", "1");
711+
}
712+
709713
cargo.env("RUSTC_VERBOSE", format!("{}", self.verbosity));
710714

711715
// in std, we want to avoid denying warnings for stage 0 as that makes cfg's painful.

src/bootstrap/config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ pub struct Config {
7272
pub dry_run: bool,
7373

7474
pub deny_warnings: bool,
75+
pub backtrace_on_ice: bool,
7576

7677
// llvm codegen options
7778
pub llvm_enabled: bool,
@@ -306,6 +307,7 @@ struct Rust {
306307
wasm_syscall: Option<bool>,
307308
lld: Option<bool>,
308309
deny_warnings: Option<bool>,
310+
backtrace_on_ice: Option<bool>,
309311
}
310312

311313
/// TOML representation of how each build target is configured.
@@ -531,6 +533,7 @@ impl Config {
531533
config.musl_root = rust.musl_root.clone().map(PathBuf::from);
532534
config.save_toolstates = rust.save_toolstates.clone().map(PathBuf::from);
533535
set(&mut config.deny_warnings, rust.deny_warnings.or(flags.warnings));
536+
set(&mut config.backtrace_on_ice, rust.backtrace_on_ice);
534537

535538
if let Some(ref backends) = rust.codegen_backends {
536539
config.rust_codegen_backends = backends.iter()

src/bootstrap/job.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,10 @@ struct JOBOBJECT_BASIC_LIMIT_INFORMATION {
122122
}
123123

124124
pub unsafe fn setup(build: &mut Build) {
125-
// Tell Windows to not show any UI on errors (such as not finding a required dll
126-
// during startup or terminating abnormally). This is important for running tests,
127-
// since some of them use abnormal termination by design.
128-
// This mode is inherited by all child processes.
129-
let mode = SetErrorMode(SEM_NOGPFAULTERRORBOX); // read inherited flags
130-
SetErrorMode(mode | SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
125+
// Enable the Windows Error Reporting dialog which msys disables,
126+
// so we can JIT debug rustc
127+
let mode = SetErrorMode(0);
128+
SetErrorMode(mode & !SEM_NOGPFAULTERRORBOX);
131129

132130
// Create a new job object for us to use
133131
let job = CreateJobObjectW(0 as *mut _, 0 as *const _);

src/librustc/util/common.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ fn panic_hook(info: &panic::PanicInfo) {
5858
if backtrace {
5959
TyCtxt::try_print_query_stack();
6060
}
61+
62+
#[cfg(windows)]
63+
unsafe {
64+
if env::var("RUSTC_BREAK_ON_ICE").is_ok() {
65+
extern "system" {
66+
fn DebugBreak();
67+
}
68+
// Trigger a debugger if we crashed during bootstrap
69+
DebugBreak();
70+
}
71+
}
6172
}
6273
}
6374

src/librustc_plugin/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
html_root_url = "https://doc.rust-lang.org/nightly/")]
6666

6767
#![feature(rustc_diagnostic_macros)]
68-
#![feature(staged_api)]
6968

7069
#[macro_use] extern crate syntax;
7170

src/librustc_plugin/registry.rs

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

src/test/run-make-fulldeps/libtest-json/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ OUTPUT_FILE := $(TMPDIR)/libtest-json-output.json
66

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

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

0 commit comments

Comments
 (0)