Open output file correctly. This is extremely important for
authorAnton Korobeynikov <asl@math.spbu.ru>
Mon, 3 Dec 2007 14:28:26 +0000 (14:28 +0000)
committerAnton Korobeynikov <asl@math.spbu.ru>
Mon, 3 Dec 2007 14:28:26 +0000 (14:28 +0000)
windows-based hosts, where files are opened in text mode by default.

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

lib/Bitcode/Writer/BitWriter.cpp

index aadd878e153e09a08fb8b5ad7cfe1f22b166ed0d..f35b80749e9cf097b60344fe229f772c559bc2d7 100644 (file)
@@ -36,7 +36,7 @@ int LLVMWriteBitcodeToFile(LLVMModuleRef M, const char *Path) {
 // non-GCC. Some C++ stdlibs even have ofstream::ofstream(int fd).
 int LLVMWriteBitcodeToFileHandle(LLVMModuleRef M, int FileHandle) {
   __gnu_cxx::stdio_filebuf<char> Buffer(FileHandle, std::ios_base::out);
-  std::ostream OS(&Buffer);
+  std::ostream OS(&Buffer, std::ios::out | std::ios::trunc | std::ios::binary);
   
   if (!OS.fail())
     WriteBitcodeToFile(unwrap(M), OS);