James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame^] | 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 2 | From: PJ Reiniger <pj.reiniger@gmail.com> |
| 3 | Date: Sun, 8 May 2022 19:30:43 -0400 |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame^] | 4 | Subject: [PATCH 22/31] OS-specific changes |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 5 | |
| 6 | --- |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame^] | 7 | llvm/lib/Support/ErrorHandling.cpp | 16 +++++++--------- |
| 8 | 1 file changed, 7 insertions(+), 9 deletions(-) |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 9 | |
| 10 | diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame^] | 11 | index e253d6f7a5ca3aee75823efdb9717dcd93fff5dc..5c08e469e2e44b27e69f4aa974bc59deb8217c9b 100644 |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 12 | --- a/llvm/lib/Support/ErrorHandling.cpp |
| 13 | +++ b/llvm/lib/Support/ErrorHandling.cpp |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame^] | 14 | @@ -96,15 +96,7 @@ void llvm::report_fatal_error(std::string_view Reason, bool GenCrashDiag) { |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 15 | fmt::print(stderr, "LLVM ERROR: {}\n", Reason); |
| 16 | } |
| 17 | |
| 18 | - // If we reached here, we are failing ungracefully. Run the interrupt handlers |
| 19 | - // to make sure any special cleanups get done, in particular that we remove |
| 20 | - // files registered with RemoveFileOnSignal. |
| 21 | - sys::RunInterruptHandlers(); |
| 22 | - |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame^] | 23 | - if (GenCrashDiag) |
| 24 | - abort(); |
| 25 | - else |
| 26 | - exit(1); |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 27 | + exit(1); |
| 28 | } |
| 29 | |
| 30 | void llvm::install_bad_alloc_error_handler(fatal_error_handler_t handler, |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame^] | 31 | @@ -141,9 +133,15 @@ void llvm::report_bad_alloc_error(const char *Reason, bool GenCrashDiag) { |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 32 | // an OOM to stderr and abort. |
| 33 | const char *OOMMessage = "LLVM ERROR: out of memory\n"; |
| 34 | const char *Newline = "\n"; |
| 35 | +#ifdef _WIN32 |
| 36 | + (void)!::_write(2, OOMMessage, strlen(OOMMessage)); |
| 37 | + (void)!::_write(2, Reason, strlen(Reason)); |
| 38 | + (void)!::_write(2, Newline, strlen(Newline)); |
| 39 | +#else |
| 40 | (void)!::write(2, OOMMessage, strlen(OOMMessage)); |
| 41 | (void)!::write(2, Reason, strlen(Reason)); |
| 42 | (void)!::write(2, Newline, strlen(Newline)); |
| 43 | +#endif |
| 44 | abort(); |
| 45 | } |
| 46 | |