mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-19 11:35:51 -04:00
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 b11386f9be
.
Differential Revision: https://reviews.llvm.org/D70492
This commit is contained in:
parent
e8d1578131
commit
d3fec7fb45
@ -64,15 +64,15 @@ LinkerDriver *driver;
|
|||||||
|
|
||||||
bool link(ArrayRef<const char *> args, bool canExitEarly, raw_ostream &stdoutOS,
|
bool link(ArrayRef<const char *> args, bool canExitEarly, raw_ostream &stdoutOS,
|
||||||
raw_ostream &stderrOS) {
|
raw_ostream &stderrOS) {
|
||||||
|
lld::stdoutOS = &stdoutOS;
|
||||||
|
lld::stderrOS = &stderrOS;
|
||||||
|
|
||||||
errorHandler().logName = args::getFilenameWithoutExe(args[0]);
|
errorHandler().logName = args::getFilenameWithoutExe(args[0]);
|
||||||
errorHandler().errorLimitExceededMsg =
|
errorHandler().errorLimitExceededMsg =
|
||||||
"too many errors emitted, stopping now"
|
"too many errors emitted, stopping now"
|
||||||
" (use /errorlimit:0 to see all errors)";
|
" (use /errorlimit:0 to see all errors)";
|
||||||
errorHandler().exitEarly = canExitEarly;
|
errorHandler().exitEarly = canExitEarly;
|
||||||
enableColors(stderrOS.has_colors());
|
stderrOS.enable_colors(stderrOS.has_colors());
|
||||||
|
|
||||||
lld::stdoutOS = &stdoutOS;
|
|
||||||
lld::stderrOS = &stderrOS;
|
|
||||||
|
|
||||||
config = make<Configuration>();
|
config = make<Configuration>();
|
||||||
symtab = make<SymbolTable>();
|
symtab = make<SymbolTable>();
|
||||||
|
@ -773,15 +773,15 @@ static void handleColorDiagnostics(opt::InputArgList &args) {
|
|||||||
if (!arg)
|
if (!arg)
|
||||||
return;
|
return;
|
||||||
if (arg->getOption().getID() == OPT_color_diagnostics) {
|
if (arg->getOption().getID() == OPT_color_diagnostics) {
|
||||||
enableColors(true);
|
lld::errs().enable_colors(true);
|
||||||
} else if (arg->getOption().getID() == OPT_no_color_diagnostics) {
|
} else if (arg->getOption().getID() == OPT_no_color_diagnostics) {
|
||||||
enableColors(false);
|
lld::errs().enable_colors(false);
|
||||||
} else {
|
} else {
|
||||||
StringRef s = arg->getValue();
|
StringRef s = arg->getValue();
|
||||||
if (s == "always")
|
if (s == "always")
|
||||||
enableColors(true);
|
lld::errs().enable_colors(true);
|
||||||
else if (s == "never")
|
else if (s == "never")
|
||||||
enableColors(false);
|
lld::errs().enable_colors(false);
|
||||||
else if (s != "auto")
|
else if (s != "auto")
|
||||||
error("unknown option: --color-diagnostics=" + s);
|
error("unknown option: --color-diagnostics=" + s);
|
||||||
}
|
}
|
||||||
|
@ -51,8 +51,6 @@ ErrorHandler &lld::errorHandler() {
|
|||||||
return handler;
|
return handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lld::enableColors(bool enable) { lld::errs().enable_colors(enable); }
|
|
||||||
|
|
||||||
void lld::exitLld(int val) {
|
void lld::exitLld(int val) {
|
||||||
// Delete any temporary file, while keeping the memory mapping open.
|
// Delete any temporary file, while keeping the memory mapping open.
|
||||||
if (errorHandler().outputBuffer)
|
if (errorHandler().outputBuffer)
|
||||||
|
@ -77,15 +77,15 @@ static void readConfigs(opt::InputArgList &args);
|
|||||||
|
|
||||||
bool link(ArrayRef<const char *> args, bool canExitEarly, raw_ostream &stdoutOS,
|
bool link(ArrayRef<const char *> args, bool canExitEarly, raw_ostream &stdoutOS,
|
||||||
raw_ostream &stderrOS) {
|
raw_ostream &stderrOS) {
|
||||||
|
lld::stdoutOS = &stdoutOS;
|
||||||
|
lld::stderrOS = &stderrOS;
|
||||||
|
|
||||||
errorHandler().logName = args::getFilenameWithoutExe(args[0]);
|
errorHandler().logName = args::getFilenameWithoutExe(args[0]);
|
||||||
errorHandler().errorLimitExceededMsg =
|
errorHandler().errorLimitExceededMsg =
|
||||||
"too many errors emitted, stopping now (use "
|
"too many errors emitted, stopping now (use "
|
||||||
"-error-limit=0 to see all errors)";
|
"-error-limit=0 to see all errors)";
|
||||||
errorHandler().exitEarly = canExitEarly;
|
errorHandler().exitEarly = canExitEarly;
|
||||||
enableColors(stderrOS.has_colors());
|
stderrOS.enable_colors(stderrOS.has_colors());
|
||||||
|
|
||||||
lld::stdoutOS = &stdoutOS;
|
|
||||||
lld::stderrOS = &stderrOS;
|
|
||||||
|
|
||||||
inputSections.clear();
|
inputSections.clear();
|
||||||
outputSections.clear();
|
outputSections.clear();
|
||||||
|
@ -59,15 +59,15 @@ static void handleColorDiagnostics(opt::InputArgList &args) {
|
|||||||
if (!arg)
|
if (!arg)
|
||||||
return;
|
return;
|
||||||
if (arg->getOption().getID() == OPT_color_diagnostics) {
|
if (arg->getOption().getID() == OPT_color_diagnostics) {
|
||||||
enableColors(true);
|
lld::errs().enable_colors(true);
|
||||||
} else if (arg->getOption().getID() == OPT_no_color_diagnostics) {
|
} else if (arg->getOption().getID() == OPT_no_color_diagnostics) {
|
||||||
enableColors(false);
|
lld::errs().enable_colors(false);
|
||||||
} else {
|
} else {
|
||||||
StringRef s = arg->getValue();
|
StringRef s = arg->getValue();
|
||||||
if (s == "always")
|
if (s == "always")
|
||||||
enableColors(true);
|
lld::errs().enable_colors(true);
|
||||||
else if (s == "never")
|
else if (s == "never")
|
||||||
enableColors(false);
|
lld::errs().enable_colors(false);
|
||||||
else if (s != "auto")
|
else if (s != "auto")
|
||||||
error("unknown option: --color-diagnostics=" + s);
|
error("unknown option: --color-diagnostics=" + s);
|
||||||
}
|
}
|
||||||
|
@ -161,10 +161,11 @@ searchLibrary(StringRef name, ArrayRef<StringRef> searchPaths, bool bStatic) {
|
|||||||
// then call coff::link.
|
// then call coff::link.
|
||||||
bool mingw::link(ArrayRef<const char *> argsArr, bool canExitEarly,
|
bool mingw::link(ArrayRef<const char *> argsArr, bool canExitEarly,
|
||||||
raw_ostream &stdoutOS, raw_ostream &stderrOS) {
|
raw_ostream &stdoutOS, raw_ostream &stderrOS) {
|
||||||
enableColors(stderrOS.has_colors());
|
|
||||||
lld::stdoutOS = &stdoutOS;
|
lld::stdoutOS = &stdoutOS;
|
||||||
lld::stderrOS = &stderrOS;
|
lld::stderrOS = &stderrOS;
|
||||||
|
|
||||||
|
stderrOS.enable_colors(stderrOS.has_colors());
|
||||||
|
|
||||||
MinGWOptTable parser;
|
MinGWOptTable parser;
|
||||||
opt::InputArgList args = parser.parse(argsArr.slice(1));
|
opt::InputArgList args = parser.parse(argsArr.slice(1));
|
||||||
|
|
||||||
|
@ -117,8 +117,6 @@ private:
|
|||||||
/// Returns the default error handler.
|
/// Returns the default error handler.
|
||||||
ErrorHandler &errorHandler();
|
ErrorHandler &errorHandler();
|
||||||
|
|
||||||
void enableColors(bool enable);
|
|
||||||
|
|
||||||
inline void error(const Twine &msg) { errorHandler().error(msg); }
|
inline void error(const Twine &msg) { errorHandler().error(msg); }
|
||||||
inline LLVM_ATTRIBUTE_NORETURN void fatal(const Twine &msg) {
|
inline LLVM_ATTRIBUTE_NORETURN void fatal(const Twine &msg) {
|
||||||
errorHandler().fatal(msg);
|
errorHandler().fatal(msg);
|
||||||
|
@ -1145,15 +1145,15 @@ static void createFiles(MachOLinkingContext &ctx, bool Implicit) {
|
|||||||
/// This is where the link is actually performed.
|
/// This is where the link is actually performed.
|
||||||
bool link(llvm::ArrayRef<const char *> args, bool CanExitEarly,
|
bool link(llvm::ArrayRef<const char *> args, bool CanExitEarly,
|
||||||
raw_ostream &StdoutOS, raw_ostream &StderrOS) {
|
raw_ostream &StdoutOS, raw_ostream &StderrOS) {
|
||||||
|
lld::stdoutOS = &StdoutOS;
|
||||||
|
lld::stderrOS = &StderrOS;
|
||||||
|
|
||||||
errorHandler().logName = args::getFilenameWithoutExe(args[0]);
|
errorHandler().logName = args::getFilenameWithoutExe(args[0]);
|
||||||
errorHandler().errorLimitExceededMsg =
|
errorHandler().errorLimitExceededMsg =
|
||||||
"too many errors emitted, stopping now (use "
|
"too many errors emitted, stopping now (use "
|
||||||
"'-error-limit 0' to see all errors)";
|
"'-error-limit 0' to see all errors)";
|
||||||
errorHandler().exitEarly = CanExitEarly;
|
errorHandler().exitEarly = CanExitEarly;
|
||||||
enableColors(StderrOS.has_colors());
|
StderrOS.enable_colors(StderrOS.has_colors());
|
||||||
|
|
||||||
lld::stdoutOS = &StdoutOS;
|
|
||||||
lld::stderrOS = &StderrOS;
|
|
||||||
|
|
||||||
MachOLinkingContext ctx;
|
MachOLinkingContext ctx;
|
||||||
if (!parse(args, ctx))
|
if (!parse(args, ctx))
|
||||||
|
@ -80,14 +80,14 @@ private:
|
|||||||
|
|
||||||
bool link(ArrayRef<const char *> args, bool canExitEarly, raw_ostream &stdoutOS,
|
bool link(ArrayRef<const char *> args, bool canExitEarly, raw_ostream &stdoutOS,
|
||||||
raw_ostream &stderrOS) {
|
raw_ostream &stderrOS) {
|
||||||
|
lld::stdoutOS = &stdoutOS;
|
||||||
|
lld::stderrOS = &stderrOS;
|
||||||
|
|
||||||
errorHandler().logName = args::getFilenameWithoutExe(args[0]);
|
errorHandler().logName = args::getFilenameWithoutExe(args[0]);
|
||||||
errorHandler().errorLimitExceededMsg =
|
errorHandler().errorLimitExceededMsg =
|
||||||
"too many errors emitted, stopping now (use "
|
"too many errors emitted, stopping now (use "
|
||||||
"-error-limit=0 to see all errors)";
|
"-error-limit=0 to see all errors)";
|
||||||
enableColors(stderrOS.has_colors());
|
stderrOS.enable_colors(stderrOS.has_colors());
|
||||||
|
|
||||||
lld::stdoutOS = &stdoutOS;
|
|
||||||
lld::stderrOS = &stderrOS;
|
|
||||||
|
|
||||||
config = make<Configuration>();
|
config = make<Configuration>();
|
||||||
symtab = make<SymbolTable>();
|
symtab = make<SymbolTable>();
|
||||||
@ -135,15 +135,15 @@ static void handleColorDiagnostics(opt::InputArgList &args) {
|
|||||||
if (!arg)
|
if (!arg)
|
||||||
return;
|
return;
|
||||||
if (arg->getOption().getID() == OPT_color_diagnostics) {
|
if (arg->getOption().getID() == OPT_color_diagnostics) {
|
||||||
enableColors(true);
|
lld::errs().enable_colors(true);
|
||||||
} else if (arg->getOption().getID() == OPT_no_color_diagnostics) {
|
} else if (arg->getOption().getID() == OPT_no_color_diagnostics) {
|
||||||
enableColors(false);
|
lld::errs().enable_colors(false);
|
||||||
} else {
|
} else {
|
||||||
StringRef s = arg->getValue();
|
StringRef s = arg->getValue();
|
||||||
if (s == "always")
|
if (s == "always")
|
||||||
enableColors(true);
|
lld::errs().enable_colors(true);
|
||||||
else if (s == "never")
|
else if (s == "never")
|
||||||
enableColors(false);
|
lld::errs().enable_colors(false);
|
||||||
else if (s != "auto")
|
else if (s != "auto")
|
||||||
error("unknown option: --color-diagnostics=" + s);
|
error("unknown option: --color-diagnostics=" + s);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user