From: Anton Korobeynikov Date: Fri, 6 Jun 2008 07:24:01 +0000 (+0000) Subject: Turn stdout into binary mode during bitcode emission. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b0a882f540e015e35ab90d0b549f3d1c24acdb9c;p=oota-llvm.git Turn stdout into binary mode during bitcode emission. This is necessary on windows targets, since stdout is in text mode there. Patch by Julien Lerouge! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52038 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp index df644d00b92..0030aca3bc5 100644 --- a/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -23,6 +23,7 @@ #include "llvm/TypeSymbolTable.h" #include "llvm/ValueSymbolTable.h" #include "llvm/Support/MathExtras.h" +#include "llvm/System/Program.h" using namespace llvm; /// These are manifest constants used by the bitcode writer. They do not need to @@ -1292,6 +1293,10 @@ void llvm::WriteBitcodeToFile(const Module *M, std::ostream &Out) { // Emit the module. WriteModule(M, Stream); + // If writing to stdout, set binary mode. + if (llvm::cout == Out) + sys::Program::ChangeStdoutToBinary(); + // Write the generated bitstream to "Out". Out.write((char*)&Buffer.front(), Buffer.size());