From 0f3d8e236043f71962adbaab13f73b05a38a3efc Mon Sep 17 00:00:00 2001 From: Martin Storsjo Date: Fri, 24 Aug 2018 18:36:42 +0000 Subject: [PATCH] [Common] Discard the temp file while keeping the memory mapping open, on errors Differential Revision: https://reviews.llvm.org/D51095 llvm-svn: 340635 --- lld/Common/ErrorHandler.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lld/Common/ErrorHandler.cpp b/lld/Common/ErrorHandler.cpp index d1cb3dbbe03c..c059516daf94 100644 --- a/lld/Common/ErrorHandler.cpp +++ b/lld/Common/ErrorHandler.cpp @@ -47,8 +47,9 @@ ErrorHandler &lld::errorHandler() { } void lld::exitLld(int Val) { - // Delete the output buffer so that any tempory file is deleted. - errorHandler().OutputBuffer.reset(); + // Delete any temporary file, while keeping the memory mapping open. + if (errorHandler().OutputBuffer) + errorHandler().OutputBuffer->discard(); // Dealloc/destroy ManagedStatic variables before calling // _exit(). In a non-LTO build, this is a nop. In an LTO