Files
carbon-lang/toolchain/driver/driver_main.cpp
T
Jon Ross-Perkins 1e866347e0 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).
2022-10-17 14:59:34 -07:00

35 lines
1.0 KiB
C++

// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include <cstdlib>
#include "common/bazel_working_dir.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/InitLLVM.h"
#include "toolchain/driver/driver.h"
auto main(int argc, char** argv) -> int {
if (argc < 1) {
return EXIT_FAILURE;
}
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);
return success ? EXIT_SUCCESS : EXIT_FAILURE;
}