[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.
This commit is contained in:
Fangrui Song
2020-06-11 15:19:05 -07:00
parent 7fac1acc61
commit 030897523d
2 changed files with 4 additions and 1 deletions

View File

@@ -878,7 +878,6 @@ raw_fd_ostream &llvm::outs() {
raw_fd_ostream &llvm::errs() {
// Set standard error to be unbuffered and tied to outs() by default.
static raw_fd_ostream S(STDERR_FILENO, false, true);
S.tie(&outs());
return S;
}

View File

@@ -606,6 +606,10 @@ static std::vector<std::string> expandBundle(const std::string &InputPath) {
int main(int argc, char **argv) {
InitLLVM X(argc, argv);
// Flush outs() when printing to errs(). This avoids interleaving output
// between the two.
errs().tie(&outs());
llvm::InitializeAllTargetInfos();
llvm::InitializeAllTargetMCs();