diff options
author | James Y Knight <jyknight@google.com> | 2019-11-20 10:08:18 -0500 |
---|---|---|
committer | James Y Knight <jyknight@google.com> | 2019-11-21 10:55:03 -0500 |
commit | d3fec7fb456138c83b84e38ce785ea6bfa59c30b (patch) | |
tree | 0bb11c72231faf17331602bf5c5c3e7098cb9d59 /lld/lib | |
parent | e8d1578131247d089209952476ba9191ad0295be (diff) | |
download | llvm-project-d3fec7fb456138c83b84e38ce785ea6bfa59c30b.tar.gz |
LLD: Don't use the stderrOS stream in link before it's reassigned.
Remove the lld::enableColors function, as it just obscures which
stream it's affecting, and replace with explicit calls to the stream's
enable_colors.
Also, assign the stderrOS and stdoutOS globals first in link function,
just to ensure nothing might use them.
(Either change individually fixes the issue of using the old
stream, but both together seems best.)
Follow-up to b11386f9be9b2dc7276a758d64f66833da10bdea.
Differential Revision: https://reviews.llvm.org/D70492
Diffstat (limited to 'lld/lib')
-rw-r--r-- | lld/lib/Driver/DarwinLdDriver.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lld/lib/Driver/DarwinLdDriver.cpp b/lld/lib/Driver/DarwinLdDriver.cpp index d372e6c94c59..10e0aa3d9fee 100644 --- a/lld/lib/Driver/DarwinLdDriver.cpp +++ b/lld/lib/Driver/DarwinLdDriver.cpp @@ -1145,15 +1145,15 @@ static void createFiles(MachOLinkingContext &ctx, bool Implicit) { /// This is where the link is actually performed. bool link(llvm::ArrayRef<const char *> args, bool CanExitEarly, raw_ostream &StdoutOS, raw_ostream &StderrOS) { + lld::stdoutOS = &StdoutOS; + lld::stderrOS = &StderrOS; + errorHandler().logName = args::getFilenameWithoutExe(args[0]); errorHandler().errorLimitExceededMsg = "too many errors emitted, stopping now (use " "'-error-limit 0' to see all errors)"; errorHandler().exitEarly = CanExitEarly; - enableColors(StderrOS.has_colors()); - - lld::stdoutOS = &StdoutOS; - lld::stderrOS = &StderrOS; + StderrOS.enable_colors(StderrOS.has_colors()); MachOLinkingContext ctx; if (!parse(args, ctx)) |