Exclude errs and outs from per-thread FS
The per-thread filesystem is useful if you're hitting the filesystem. If you are writing to stdout/stderrs, multi-threading is going to cause all sorts of crazy issues anyways the per-thread filesystem gets us nothing but bugs.
This change adds an option to exclude raw_fd_ostreams from the per-thread filesystem on creation. If opted-out they will fallback to using the normal POSIX C interfaces. This change also removes the RAII construct used to flush stdout and stderr and close stdout. Closing stdout is not required on any platform, modern LLVM also excludes closing stdout & stderr on all platforms.
:white_check_mark: Build DirectXShaderCompiler 1.0.1028 completed (commit https://github.com/microsoft/DirectXShaderCompiler/commit/3b5c349947 by @llvm-beanz)
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
You can test this locally with the following command:
git-clang-format --diff 8d38549821491c95d7a36535ad932717198097e5 b2dc4706ab7bb6e2c7bbddbaff5ab9b337026491 -- include/llvm/Support/raw_ostream.h lib/Support/raw_ostream.cpp tools/clang/tools/driver/driver.cpp tools/clang/utils/TableGen/TableGen.cpp tools/llvm-as/llvm-as.cpp tools/opt/opt.cpp utils/FileCheck/FileCheck.cpp
View the diff from clang-format here.
diff --git a/include/llvm/Support/raw_ostream.h b/include/llvm/Support/raw_ostream.h
index 4f9612d5..58155c18 100644
--- a/include/llvm/Support/raw_ostream.h
+++ b/include/llvm/Support/raw_ostream.h
@@ -405,12 +405,13 @@ public:
/// file descriptor when it is done (this is necessary to detect
/// output errors).
raw_fd_ostream(StringRef Filename, std::error_code &EC,
- sys::fs::OpenFlags Flags, bool perThread=true); // HLSL Change
+ sys::fs::OpenFlags Flags,
+ bool perThread = true); // HLSL Change
/// FD is the file descriptor that this writes to. If ShouldClose is true,
/// this closes the file when the stream is destroyed.
- raw_fd_ostream(int fd, bool shouldClose, bool unbuffered=false,
- bool perThread=true); // HLSL Change - Opt-out for thread FS
+ raw_fd_ostream(int fd, bool shouldClose, bool unbuffered = false,
+ bool perThread = true); // HLSL Change - Opt-out for thread FS
~raw_fd_ostream() override;
diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp
index 22dc380e..c44f90b8 100644
--- a/lib/Support/raw_ostream.cpp
+++ b/lib/Support/raw_ostream.cpp
@@ -560,10 +560,10 @@ raw_fd_ostream::raw_fd_ostream(StringRef Filename, std::error_code &EC,
sys::fs::OpenFlags Flags, bool perThread)
: raw_fd_ostream(getFD(Filename, EC, Flags), true, false, perThread) {}
-
/// FD is the file descriptor that this writes to. If ShouldClose is true, this
/// closes the file when the stream is destroyed.
-raw_fd_ostream::raw_fd_ostream(int fd, bool shouldClose, bool unbuffered, bool perThread)
+raw_fd_ostream::raw_fd_ostream(int fd, bool shouldClose, bool unbuffered,
+ bool perThread)
: raw_pwrite_stream(unbuffered), FD(fd), ShouldClose(shouldClose),
Error(false), UseAtomicWrites(false), UsePerThreadFS(perThread) {
// HLSL Change End - Add opt-out for per-thread FS
Abandoning because I'm not going to follow up on this.