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
This commit is contained in:
Anton Korobeynikov 2008-06-06 07:24:01 +00:00
parent 3e9eeaf6c9
commit b207a716ee

View File

@ -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());