std.os.abort no longer calls msvcrt abort() when linking libc

closes #2071
master
Andrew Kelley 2019-07-05 12:53:36 -04:00
parent 72800f176e
commit 0d84d52e37
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9
1 changed files with 6 additions and 3 deletions

View File

@ -138,15 +138,18 @@ fn getRandomBytesDevURandom(buf: []u8) !void {
/// it raises SIGABRT followed by SIGKILL and finally lo
pub fn abort() noreturn {
@setCold(true);
if (builtin.link_libc) {
system.abort();
}
// MSVCRT abort() sometimes opens a popup window which is undesirable, so
// even when linking libc on Windows we use our own abort implementation.
// See https://github.com/ziglang/zig/issues/2071 for more details.
if (windows.is_the_target) {
if (builtin.mode == .Debug) {
@breakpoint();
}
windows.kernel32.ExitProcess(3);
}
if (builtin.link_libc) {
system.abort();
}
if (builtin.os == .uefi) {
// TODO there must be a better thing to do here than loop forever
while (true) {}