diff options
author | Yaron Keren <yaron.keren@gmail.com> | 2017-03-30 19:30:51 +0000 |
---|---|---|
committer | Yaron Keren <yaron.keren@gmail.com> | 2017-03-30 19:30:51 +0000 |
commit | 9d27c47b4647d8f1cab49250daebd22056fb9844 (patch) | |
tree | 11dd4279c892eae19a5c7682d7b9ac97fa420275 /llvm/lib/Support/raw_ostream.cpp | |
parent | b87602032a3d2819190f741be871876a4f67d09f (diff) | |
download | bcm5719-llvm-9d27c47b4647d8f1cab49250daebd22056fb9844.tar.gz bcm5719-llvm-9d27c47b4647d8f1cab49250daebd22056fb9844.zip |
Following r297661, disable dup workaround to disable duplicate STDOUT fd closing and instead directly prevent closing of STD* file descriptors.
We do not want to close STDOUT as there may have been several uses of it
such as the case: llc %s -o=- -pass-remarks-output=- -filetype=asm
which cause multiple closes of STDOUT_FILENO and/or use-after-close of it.
Using dup() in getFD doesn't work as we end up with original STDOUT_FILENO
open anyhow.
reviewed by Rafael Espindola
Differential Revision: https://reviews.llvm.org/D31505
llvm-svn: 299098
Diffstat (limited to 'llvm/lib/Support/raw_ostream.cpp')
-rw-r--r-- | llvm/lib/Support/raw_ostream.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp index 5deab5de4f6..d804a006824 100644 --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp @@ -473,7 +473,7 @@ static int getFD(StringRef Filename, std::error_code &EC, // possible. if (!(Flags & sys::fs::F_Text)) sys::ChangeStdoutToBinary(); - return dup(STDOUT_FILENO); + return STDOUT_FILENO; } int FD; @@ -497,6 +497,13 @@ raw_fd_ostream::raw_fd_ostream(int fd, bool shouldClose, bool unbuffered) ShouldClose = false; return; } + // We do not want to close STDOUT as there may have been several uses of it + // such as the case: llc %s -o=- -pass-remarks-output=- -filetype=asm + // which cause multiple closes of STDOUT_FILENO and/or use-after-close of it. + // Using dup() in getFD doesn't work as we end up with original STDOUT_FILENO + // open anyhow. + if (FD <= STDERR_FILENO) + ShouldClose = false; // Get the starting position. off_t loc = ::lseek(FD, 0, SEEK_CUR); |