Improve driver debugability (#2290)

llvm::InitLLVM starts getting stacks on assertion errors. Tieing errs to outs causes outs to be flushed when errs is used (avoiding munging out incompletely flushed output).
This commit is contained in:
Jon Ross-Perkins
2022-10-17 14:59:34 -07:00
committed by GitHub
parent c451a5004d
commit 1e866347e0
+11 -1
View File
@@ -7,7 +7,7 @@
#include "common/bazel_working_dir.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/InitLLVM.h"
#include "toolchain/driver/driver.h"
auto main(int argc, char** argv) -> int {
@@ -17,6 +17,16 @@ auto main(int argc, char** argv) -> int {
Carbon::SetWorkingDirForBazel();
llvm::setBugReportMsg(
"Please report issues to "
"https://github.com/carbon-language/carbon-lang/issues and include the "
"crash backtrace.\n");
llvm::InitLLVM init_llvm(argc, argv);
// Printing to stderr should flush stdout. This is most noticeable when stderr
// is piped to stdout.
llvm::errs().tie(&llvm::outs());
llvm::SmallVector<llvm::StringRef, 16> args(argv + 1, argv + argc);
Carbon::Driver driver;
bool success = driver.RunFullCommand(args);