If stdout is used as an output file for several outputs (like dep file, output file, etc.) , it causes a crash in llvm::raw_fd_ostream::~raw_fd_ostream(), when destructor tries to close file descriptor, which already is closed in another stream.
Here is the part of the code where it happens:
raw_fd_ostream::~raw_fd_ostream() { if (FD >= 0) { flush(); if (ShouldClose && sys::Process::SafelyCloseFileDescriptor(FD)) error_detected(); } ... if (has_error()) report_fatal_error("IO failure on output stream.", /*GenCrashDiag=*/false); }
if stdout is already closed sys::Process::SafelyCloseFileDescriptor() cannot close stdout for the second time and an error flag is set for the stream. It makes the destructor to emit IO failure on output stream. fatal error message.