aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff options
context:
space:
mode:
authorAnton Korobeynikov <asl@math.spbu.ru>2008-06-06 07:24:01 +0000
committerAnton Korobeynikov <asl@math.spbu.ru>2008-06-06 07:24:01 +0000
commit5b3e396c245d94eff601bcc465bfd9e752f8bd78 (patch)
tree818f208ecdb570431256562e86036fa2b4dfdf03 /llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
parent5e8644071d5fffdbd5d659155613957cb14af6fa (diff)
downloadllvm-5b3e396c245d94eff601bcc465bfd9e752f8bd78.zip
llvm-5b3e396c245d94eff601bcc465bfd9e752f8bd78.tar.gz
llvm-5b3e396c245d94eff601bcc465bfd9e752f8bd78.tar.bz2
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! llvm-svn: 52038
Diffstat (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp')
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriter.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index df644d0..0030aca 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/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());