Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."

This reverts commit r230044 while dealing with buildbot breakage.

Conflicts:
	test/Modules/module_container.m

llvm-svn: 230052
diff --git a/clang/lib/Serialization/GeneratePCH.cpp b/clang/lib/Serialization/GeneratePCH.cpp
index 0cd01dc..b5031fd 100644
--- a/clang/lib/Serialization/GeneratePCH.cpp
+++ b/clang/lib/Serialization/GeneratePCH.cpp
@@ -19,6 +19,7 @@
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Sema/SemaConsumer.h"
 #include "llvm/Bitcode/BitstreamWriter.h"
+#include "llvm/Support/raw_ostream.h"
 #include <string>
 
 using namespace clang;
@@ -27,11 +28,10 @@
                            StringRef OutputFile,
                            clang::Module *Module,
                            StringRef isysroot,
-                           bool AllowASTWithErrors)
+                           raw_ostream *OS, bool AllowASTWithErrors)
   : PP(PP), OutputFile(OutputFile), Module(Module), 
-    isysroot(isysroot.str()),
-    SemaPtr(nullptr), Stream(Buffer),
-    Writer(Stream),
+    isysroot(isysroot.str()), Out(OS), 
+    SemaPtr(nullptr), Stream(Buffer), Writer(Stream),
     AllowASTWithErrors(AllowASTWithErrors),
     HasEmittedPCH(false) {
 }
@@ -52,8 +52,14 @@
   assert(SemaPtr && "No Sema?");
   Writer.WriteAST(*SemaPtr, OutputFile, Module, isysroot, hasErrors);
 
-  if (SerializationFinishedCallback)
-    SerializationFinishedCallback(&Buffer);
+  // Write the generated bitstream to "Out".
+  Out->write((char *)&Buffer.front(), Buffer.size());
+
+  // Make sure it hits disk now.
+  Out->flush();
+
+  // Free up some memory, in case the process is kept alive.
+  Buffer.clear();
 
   HasEmittedPCH = true;
 }