diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp
index 2e151118d6a..2181ccec0b1 100644
--- a/lib/Support/raw_ostream.cpp
+++ b/lib/Support/raw_ostream.cpp
@@ -343,7 +343,7 @@ raw_fd_ostream::raw_fd_ostream(const char *Filename, std::string &ErrorInfo,
   
   int OpenFlags = O_WRONLY|O_CREAT;
 #ifdef O_BINARY
-  if (Binary)
+  if (Flags & F_Binary)
     OpenFlags |= O_BINARY;
 #endif