std::string *ErrMsg = 0);
/// WriteBitcodeToFile - Write the specified module to the specified
- /// raw output stream.
+ /// raw output stream. For streams where it matters, the given stream
+ /// should be in "binary" mode.
void WriteBitcodeToFile(const Module *M, raw_ostream &Out);
/// WriteBitcodeToStream - Write the specified module to the specified
WriteBitcodeToStream( M, Stream );
- // If writing to stdout, set binary mode.
- if (&llvm::outs() == &Out)
- sys::Program::ChangeStdoutToBinary();
-
// Write the generated bitstream to "Out".
Out.write((char*)&Buffer.front(), Buffer.size());
}
// Figure out what stream we are supposed to write to...
- // FIXME: outs() is not binary!
raw_ostream *Out = 0;
bool DeleteStream = false;
if (!NoOutput && !AnalyzeOnly) {
if (OutputFilename == "-") {
- Out = &outs(); // Default to printing to stdout...
+ // Print to stdout.
+ Out = &outs();
+ // If we're printing a bitcode file, switch stdout to binary mode.
+ // FIXME: This switches outs() globally, not just for the bitcode output.
+ if (!OutputAssembly)
+ sys::Program::ChangeStdoutToBinary();
} else {
if (NoOutput || AnalyzeOnly) {
errs() << "WARNING: The -o (output filename) option is ignored when\n"