Skip to content

Commit 0308975

Browse files
committed
[Support] Don't tie errs() to outs() by default
This reverts part of D81156. Accessing errs() concurrently was safe before and racy after D81156. (`errs() << 'a'` is always racy) Accessing outs() and errs() concurrently was safe before and racy after D81156. Don't tie errs() to outs() by default to fix the fallout. llvm-dwarfdump is single-threaded and opting in the tie behavior is safe.
1 parent 7fac1ac commit 0308975

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

llvm/lib/Support/raw_ostream.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,6 @@ raw_fd_ostream &llvm::outs() {
878878
raw_fd_ostream &llvm::errs() {
879879
// Set standard error to be unbuffered and tied to outs() by default.
880880
static raw_fd_ostream S(STDERR_FILENO, false, true);
881-
S.tie(&outs());
882881
return S;
883882
}
884883

llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,10 @@ static std::vector<std::string> expandBundle(const std::string &InputPath) {
606606
int main(int argc, char **argv) {
607607
InitLLVM X(argc, argv);
608608

609+
// Flush outs() when printing to errs(). This avoids interleaving output
610+
// between the two.
611+
errs().tie(&outs());
612+
609613
llvm::InitializeAllTargetInfos();
610614
llvm::InitializeAllTargetMCs();
611615

0 commit comments

Comments
 (0)