From e1eff1b0e89bf2350dcf4d7933f1984f2c37c9c4 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Thu, 27 Jan 2022 16:53:17 -0800 Subject: [PATCH 1/2] Windows: Disable LLVM crash dialog boxes. --- compiler/rustc_codegen_llvm/src/llvm/ffi.rs | 1 + compiler/rustc_codegen_llvm/src/llvm_util.rs | 1 + compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index 2b10218879038..367c86a1dc942 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -987,6 +987,7 @@ pub type SelfProfileAfterPassCallback = unsafe extern "C" fn(*mut c_void); extern "C" { pub fn LLVMRustInstallFatalErrorHandler(); + pub fn LLVMRustDisableSystemDialogsOnCrash(); // Create and destroy contexts. pub fn LLVMRustContextCreate(shouldDiscardNames: bool) -> &'static mut Context; diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index d49df29f4534e..437f9a9e4cce0 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -46,6 +46,7 @@ unsafe fn configure_llvm(sess: &Session) { let mut llvm_args = Vec::with_capacity(n_args + 1); llvm::LLVMRustInstallFatalErrorHandler(); + llvm::LLVMRustDisableSystemDialogsOnCrash(); fn llvm_arg_to_arg_name(full_arg: &str) -> &str { full_arg.trim().split(|c: char| c == '=' || c.is_whitespace()).next().unwrap_or("") diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index dcd6327c92f6a..d871290744f8b 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -76,6 +76,10 @@ extern "C" void LLVMRustInstallFatalErrorHandler() { install_fatal_error_handler(FatalErrorHandler); } +extern "C" void LLVMRustDisableSystemDialogsOnCrash() { + sys::DisableSystemDialogsOnCrash(); +} + extern "C" char *LLVMRustGetLastError(void) { char *Ret = LastError; LastError = nullptr; From c64d6bf5af368066af7ecc2f69555b1721cfd0b5 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Thu, 3 Feb 2022 07:03:44 -0800 Subject: [PATCH 2/2] Only disable dialogs on CI. The "CI" environment var isn't universal (for example, I think Azure uses TF_BUILD). However, we are mostly concerned with rust-lang/rust's own CI which currently is GitHub Actions which does set "CI". And I think most other providers use "CI" as well. --- compiler/rustc_codegen_llvm/src/llvm_util.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index 437f9a9e4cce0..f91fad2d9c963 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -46,7 +46,12 @@ unsafe fn configure_llvm(sess: &Session) { let mut llvm_args = Vec::with_capacity(n_args + 1); llvm::LLVMRustInstallFatalErrorHandler(); - llvm::LLVMRustDisableSystemDialogsOnCrash(); + // On Windows, an LLVM assertion will open an Abort/Retry/Ignore dialog + // box for the purpose of launching a debugger. However, on CI this will + // cause it to hang until it times out, which can take several hours. + if std::env::var_os("CI").is_some() { + llvm::LLVMRustDisableSystemDialogsOnCrash(); + } fn llvm_arg_to_arg_name(full_arg: &str) -> &str { full_arg.trim().split(|c: char| c == '=' || c.is_whitespace()).next().unwrap_or("")