Make sure to set stdout to binary when writing bitcode files via
authorDaniel Dunbar <daniel@zuster.org>
Thu, 23 Oct 2008 19:37:34 +0000 (19:37 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 23 Oct 2008 19:37:34 +0000 (19:37 +0000)
std::ostream API.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58042 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Bitcode/Writer/BitcodeWriter.cpp

index 913c2bcbf4eb3c989a955209d04b043d64165b27..279e447873cab76fc90b4097f95d852e64366816 100644 (file)
@@ -1332,6 +1332,9 @@ static void EmitDarwinBCTrailer(BitstreamWriter &Stream, unsigned BufferSize) {
 /// stream.
 void llvm::WriteBitcodeToFile(const Module *M, std::ostream &Out) {
   raw_os_ostream RawOut(Out);
+  // If writing to stdout, set binary mode.
+  if (llvm::cout == Out)
+    sys::Program::ChangeStdoutToBinary();
   WriteBitcodeToFile(M, RawOut);
 }