diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp @@ -636,6 +636,11 @@ // Check if this is a console device. This is not equivalent to isatty. IsWindowsConsole = ::GetFileType((HANDLE)::_get_osfhandle(fd)) == FILE_TYPE_CHAR; + + // If this isn't a Windows console device, don't try to use API to set color. + // Switch to ANSI escape codes instead. + if (!IsWindowsConsole) + llvm::sys::Process::UseANSIEscapeCodes(true); #endif // Get the starting position.