[PATCH] D81525: [Support] Ensure errs() is constructed after outs() and don't rerun tie when errs() is called
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 11 13:47:54 PDT 2020
MaskRay added a comment.
In D81525#2088267 <https://reviews.llvm.org/D81525#2088267>, @amaiorano wrote:
> I posted this on the GitHub PR, but was told the main discussion about this bug is here:
> https://github.com/llvm/llvm-project/commit/1ce831912c797df1cb6d313d8e576a3f86175b6d#r39838454
>
> Not sure a separate InitializeAndTie struct is needed when you can use an immediately-invoked lambda:
>
> raw_fd_ostream &llvm::errs() {
> // Set standard error to be unbuffered and tied to outs() by default.
> static auto S = [] {
> raw_fd_ostream s(STDERR_FILENO, false, true);
> s.tie(&outs());
> return s;
> }();
> return S;
> }
>
>
> I'm assuming 's' can be returned by value here, of course, otherwise we could make it static and return by reference from the lambda.
A lambda does not work. raw_fd_ostream does not have a copy constructor.
> Unless there is an immediate resolution (and the discussion seems to indicate that it is worth taking our time here), can we revert the patch that introduces a TSAN failure?
@mehdi_amini Pushing this patch will fix the issue.
Can you be more specific about concurrent outs() or outs()+errs() calls?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D81525/new/
https://reviews.llvm.org/D81525
More information about the llvm-commits
mailing list