From 4f750f6ebc412869ce6bb28331313a9c9a9d9af7 Mon Sep 17 00:00:00 2001 From: Abhina Sreeskantharajan Date: Fri, 19 Mar 2021 08:09:01 -0400 Subject: [SystemZ][z/OS] Distinguish between text and binary files on z/OS This patch consists of the initial changes to help distinguish between text and binary content correctly on z/OS. I would like to get feedback from Windows users on setting OF_None for all ToolOutputFiles. This seems to have been done as an optimization to prevent CRLF translation on Windows in the past. Reviewed By: zibi Differential Revision: https://reviews.llvm.org/D97785 --- llvm/lib/Support/ToolOutputFile.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'llvm/lib/Support/ToolOutputFile.cpp') diff --git a/llvm/lib/Support/ToolOutputFile.cpp b/llvm/lib/Support/ToolOutputFile.cpp index c2ca97a..3735aac 100644 --- a/llvm/lib/Support/ToolOutputFile.cpp +++ b/llvm/lib/Support/ToolOutputFile.cpp @@ -11,6 +11,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/ToolOutputFile.h" +#include "llvm/ADT/Triple.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Signals.h" using namespace llvm; @@ -45,7 +46,12 @@ ToolOutputFile::ToolOutputFile(StringRef Filename, std::error_code &EC, EC = std::error_code(); return; } - OSHolder.emplace(Filename, EC, Flags); + + // On Windows, we set the OF_None flag even for text files to avoid + // CRLF translation. + OSHolder.emplace( + Filename, EC, + llvm::Triple(LLVM_HOST_TRIPLE).isOSWindows() ? sys::fs::OF_None : Flags); OS = OSHolder.getPointer(); // If open fails, no cleanup is needed. if (EC) -- cgit v1.1