From 3c6f47d6b879ddd2842925d2e5da54657d9e5631 Mon Sep 17 00:00:00 2001 From: Alexandre Ganea <37383324+aganea@users.noreply.github.com> Date: Thu, 11 Jan 2024 19:08:28 -0500 Subject: [PATCH] [llvm-driver] Fix usage of `InitLLVM` on Windows (#76306) Previously, some tools such as `clang` or `lld` which require strict order for certain command-line options, such as `clang -cc1` or `lld -flavor`, would not longer work on Windows, when these tools were linked as part of `llvm-driver`. This was caused by `InitLLVM` which was part of the `*_main()` function of these tools, which in turn calls `windows::GetCommandLineArguments`. That function completly replaces argc/argv by new UTF-8 contents, so any ajustements to argc/argv made by `llvm-driver` prior to calling these tools was reset. `InitLLVM` is now called by the `llvm-driver`. Any tool that participates in (or is part of) the `llvm-driver` doesn't call `InitLLVM` anymore. --- clang/tools/clang-scan-deps/ClangScanDeps.cpp | 2 -- clang/tools/driver/driver.cpp | 2 -- lld/Common/DriverDispatcher.cpp | 1 - lld/tools/lld/lld.cpp | 2 -- llvm/cmake/modules/llvm-driver-template.cpp.in | 2 ++ llvm/lib/Support/InitLLVM.cpp | 5 +++++ llvm/tools/dsymutil/dsymutil.cpp | 3 --- llvm/tools/llvm-ar/llvm-ar.cpp | 2 -- llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp | 2 -- llvm/tools/llvm-debuginfod/llvm-debuginfod.cpp | 2 -- llvm/tools/llvm-driver/llvm-driver.cpp | 6 +++++- llvm/tools/llvm-dwp/llvm-dwp.cpp | 3 --- llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp | 2 -- llvm/tools/llvm-lipo/llvm-lipo.cpp | 2 -- llvm/tools/llvm-ml/llvm-ml.cpp | 2 -- llvm/tools/llvm-mt/llvm-mt.cpp | 3 --- llvm/tools/llvm-nm/llvm-nm.cpp | 2 -- llvm/tools/llvm-objcopy/llvm-objcopy.cpp | 2 -- llvm/tools/llvm-objdump/llvm-objdump.cpp | 2 -- llvm/tools/llvm-profdata/llvm-profdata.cpp | 2 -- llvm/tools/llvm-rc/llvm-rc.cpp | 2 -- llvm/tools/llvm-readobj/llvm-readobj.cpp | 2 -- llvm/tools/llvm-size/llvm-size.cpp | 2 -- llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp | 2 -- llvm/tools/sancov/sancov.cpp | 3 --- 25 files changed, 12 insertions(+), 48 deletions(-) diff --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp b/clang/tools/clang-scan-deps/ClangScanDeps.cpp index 75aa4ae97c618..fb42dc1085afb 100644 --- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp +++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp @@ -20,7 +20,6 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/FileUtilities.h" #include "llvm/Support/Format.h" -#include "llvm/Support/InitLLVM.h" #include "llvm/Support/JSON.h" #include "llvm/Support/LLVMDriver.h" #include "llvm/Support/Program.h" @@ -699,7 +698,6 @@ static std::string getModuleCachePath(ArrayRef Args) { // form specified command line after the positional parameter "--". static std::unique_ptr getCompilationDataBase(int argc, char **argv, std::string &ErrorMessage) { - llvm::InitLLVM X(argc, argv); ParseArgs(argc, argv); if (!CompilationDB.empty()) diff --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp index 4adc7f7ad0dac..a46d5169719bc 100644 --- a/clang/tools/driver/driver.cpp +++ b/clang/tools/driver/driver.cpp @@ -36,7 +36,6 @@ #include "llvm/Support/CrashRecoveryContext.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FileSystem.h" -#include "llvm/Support/InitLLVM.h" #include "llvm/Support/LLVMDriver.h" #include "llvm/Support/Path.h" #include "llvm/Support/PrettyStackTrace.h" @@ -377,7 +376,6 @@ static int ExecuteCC1Tool(SmallVectorImpl &ArgV, int clang_main(int Argc, char **Argv, const llvm::ToolContext &ToolContext) { noteBottomOfStack(); - llvm::InitLLVM X(Argc, Argv); llvm::setBugReportMsg("PLEASE submit a bug report to " BUG_REPORT_URL " and include the crash backtrace, preprocessed " "source, and associated run script.\n"); diff --git a/lld/Common/DriverDispatcher.cpp b/lld/Common/DriverDispatcher.cpp index 379a4c6ddabea..435acfd277654 100644 --- a/lld/Common/DriverDispatcher.cpp +++ b/lld/Common/DriverDispatcher.cpp @@ -16,7 +16,6 @@ #include "llvm/ADT/Twine.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/CrashRecoveryContext.h" -#include "llvm/Support/InitLLVM.h" #include "llvm/Support/Path.h" #include "llvm/Support/Process.h" #include "llvm/TargetParser/Host.h" diff --git a/lld/tools/lld/lld.cpp b/lld/tools/lld/lld.cpp index a0a7cb0be8f13..d6800fa1eea4b 100644 --- a/lld/tools/lld/lld.cpp +++ b/lld/tools/lld/lld.cpp @@ -33,7 +33,6 @@ #include "llvm/ADT/Twine.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/CrashRecoveryContext.h" -#include "llvm/Support/InitLLVM.h" #include "llvm/Support/LLVMDriver.h" #include "llvm/Support/Path.h" #include "llvm/Support/PluginLoader.h" @@ -74,7 +73,6 @@ LLD_HAS_DRIVER(macho) LLD_HAS_DRIVER(wasm) int lld_main(int argc, char **argv, const llvm::ToolContext &) { - InitLLVM x(argc, argv); sys::Process::UseANSIEscapeCodes(true); if (::getenv("FORCE_LLD_DIAGNOSTICS_CRASH")) { diff --git a/llvm/cmake/modules/llvm-driver-template.cpp.in b/llvm/cmake/modules/llvm-driver-template.cpp.in index 16c4fb3471463..71aca6cd140cb 100644 --- a/llvm/cmake/modules/llvm-driver-template.cpp.in +++ b/llvm/cmake/modules/llvm-driver-template.cpp.in @@ -8,9 +8,11 @@ #include "llvm/Support/LLVMDriver.h" #include "llvm/ADT/ArrayRef.h" +#include "llvm/Support/InitLLVM.h" int @TOOL_NAME@_main(int argc, char **, const llvm::ToolContext &); int main(int argc, char **argv) { + llvm::InitLLVM X(argc, argv); return @TOOL_NAME@_main(argc, argv, {argv[0], nullptr, false}); } diff --git a/llvm/lib/Support/InitLLVM.cpp b/llvm/lib/Support/InitLLVM.cpp index 7f475f42f3cb8..b7e463a19122d 100644 --- a/llvm/lib/Support/InitLLVM.cpp +++ b/llvm/lib/Support/InitLLVM.cpp @@ -38,6 +38,11 @@ using namespace llvm::sys; InitLLVM::InitLLVM(int &Argc, const char **&Argv, bool InstallPipeSignalExitHandler) { +#ifndef NDEBUG + static std::atomic Initialized{false}; + assert(!Initialized && "InitLLVM was already initialized!"); + Initialized = true; +#endif #ifdef __MVS__ // Bring stdin/stdout/stderr into a known state. sys::AddSignalHandler(CleanupStdHandles, nullptr); diff --git a/llvm/tools/dsymutil/dsymutil.cpp b/llvm/tools/dsymutil/dsymutil.cpp index a461d9e20a212..d4428c1089681 100644 --- a/llvm/tools/dsymutil/dsymutil.cpp +++ b/llvm/tools/dsymutil/dsymutil.cpp @@ -37,7 +37,6 @@ #include "llvm/Support/FileCollector.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/FormatVariadic.h" -#include "llvm/Support/InitLLVM.h" #include "llvm/Support/LLVMDriver.h" #include "llvm/Support/Path.h" #include "llvm/Support/TargetSelect.h" @@ -608,8 +607,6 @@ getOutputFileName(StringRef InputFile, const DsymutilOptions &Options) { } int dsymutil_main(int argc, char **argv, const llvm::ToolContext &) { - InitLLVM X(argc, argv); - // Parse arguments. DsymutilOptTable T; unsigned MAI; diff --git a/llvm/tools/llvm-ar/llvm-ar.cpp b/llvm/tools/llvm-ar/llvm-ar.cpp index 299b7856ec0ba..c8800303bc1e4 100644 --- a/llvm/tools/llvm-ar/llvm-ar.cpp +++ b/llvm/tools/llvm-ar/llvm-ar.cpp @@ -25,7 +25,6 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/Format.h" #include "llvm/Support/FormatVariadic.h" -#include "llvm/Support/InitLLVM.h" #include "llvm/Support/LLVMDriver.h" #include "llvm/Support/LineIterator.h" #include "llvm/Support/MemoryBuffer.h" @@ -1500,7 +1499,6 @@ static int ranlib_main(int argc, char **argv) { } int llvm_ar_main(int argc, char **argv, const llvm::ToolContext &) { - InitLLVM X(argc, argv); ToolName = argv[0]; llvm::InitializeAllTargetInfos(); diff --git a/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp b/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp index 26a1f2f4afebd..d63f507619a0e 100644 --- a/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp +++ b/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp @@ -13,7 +13,6 @@ #include "llvm/Option/ArgList.h" #include "llvm/Option/Option.h" #include "llvm/Support/CommandLine.h" -#include "llvm/Support/InitLLVM.h" #include "llvm/Support/LLVMDriver.h" #include "llvm/Support/WithColor.h" #include "llvm/Support/raw_ostream.h" @@ -146,7 +145,6 @@ static void demangleLine(llvm::raw_ostream &OS, StringRef Mangled, bool Split) { } int llvm_cxxfilt_main(int argc, char **argv, const llvm::ToolContext &) { - InitLLVM X(argc, argv); BumpPtrAllocator A; StringSaver Saver(A); CxxfiltOptTable Tbl; diff --git a/llvm/tools/llvm-debuginfod/llvm-debuginfod.cpp b/llvm/tools/llvm-debuginfod/llvm-debuginfod.cpp index b9e2c6747187e..9d347dbd68f39 100644 --- a/llvm/tools/llvm-debuginfod/llvm-debuginfod.cpp +++ b/llvm/tools/llvm-debuginfod/llvm-debuginfod.cpp @@ -22,7 +22,6 @@ #include "llvm/Option/ArgList.h" #include "llvm/Option/Option.h" #include "llvm/Support/CommandLine.h" -#include "llvm/Support/InitLLVM.h" #include "llvm/Support/LLVMDriver.h" #include "llvm/Support/ThreadPool.h" @@ -121,7 +120,6 @@ static void parseArgs(int argc, char **argv) { } int llvm_debuginfod_main(int argc, char **argv, const llvm::ToolContext &) { - InitLLVM X(argc, argv); HTTPClient::initialize(); parseArgs(argc, argv); diff --git a/llvm/tools/llvm-driver/llvm-driver.cpp b/llvm/tools/llvm-driver/llvm-driver.cpp index a0f1ca831d93b..53a8b9357e378 100644 --- a/llvm/tools/llvm-driver/llvm-driver.cpp +++ b/llvm/tools/llvm-driver/llvm-driver.cpp @@ -10,6 +10,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/InitLLVM.h" #include "llvm/Support/LLVMDriver.h" #include "llvm/Support/Path.h" #include "llvm/Support/WithColor.h" @@ -79,4 +80,7 @@ static int findTool(int Argc, char **Argv, const char *Argv0) { return 1; } -int main(int Argc, char **Argv) { return findTool(Argc, Argv, Argv[0]); } +int main(int Argc, char **Argv) { + llvm::InitLLVM X(Argc, Argv); + return findTool(Argc, Argv, Argv[0]); +} diff --git a/llvm/tools/llvm-dwp/llvm-dwp.cpp b/llvm/tools/llvm-dwp/llvm-dwp.cpp index a6b8643a59038..81556b3ad4bcb 100644 --- a/llvm/tools/llvm-dwp/llvm-dwp.cpp +++ b/llvm/tools/llvm-dwp/llvm-dwp.cpp @@ -27,7 +27,6 @@ #include "llvm/Option/Option.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/FileSystem.h" -#include "llvm/Support/InitLLVM.h" #include "llvm/Support/LLVMDriver.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/TargetSelect.h" @@ -120,8 +119,6 @@ static Expected readTargetTriple(StringRef FileName) { } int llvm_dwp_main(int argc, char **argv, const llvm::ToolContext &) { - InitLLVM X(argc, argv); - DwpOptTable Tbl; llvm::BumpPtrAllocator A; llvm::StringSaver Saver{A}; diff --git a/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp b/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp index 45e04d8f9dd04..77ae9b41d8885 100644 --- a/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp +++ b/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp @@ -23,7 +23,6 @@ #include "llvm/Option/ArgList.h" #include "llvm/Option/Option.h" #include "llvm/Support/CommandLine.h" -#include "llvm/Support/InitLLVM.h" #include "llvm/Support/LLVMDriver.h" #include "llvm/Support/LineIterator.h" #include "llvm/Support/TargetSelect.h" @@ -727,7 +726,6 @@ static Expected parseCommandLine(int Argc, char **Argv) { } int llvm_libtool_darwin_main(int Argc, char **Argv, const llvm::ToolContext &) { - InitLLVM X(Argc, Argv); Expected ConfigOrErr = parseCommandLine(Argc, Argv); if (!ConfigOrErr) { WithColor::defaultErrorHandler(ConfigOrErr.takeError()); diff --git a/llvm/tools/llvm-lipo/llvm-lipo.cpp b/llvm/tools/llvm-lipo/llvm-lipo.cpp index 7e3275773b8ad..083a922af0c4c 100644 --- a/llvm/tools/llvm-lipo/llvm-lipo.cpp +++ b/llvm/tools/llvm-lipo/llvm-lipo.cpp @@ -26,7 +26,6 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/Error.h" #include "llvm/Support/FileOutputBuffer.h" -#include "llvm/Support/InitLLVM.h" #include "llvm/Support/LLVMDriver.h" #include "llvm/Support/TargetSelect.h" #include "llvm/Support/WithColor.h" @@ -724,7 +723,6 @@ replaceSlices(LLVMContext &LLVMCtx, } int llvm_lipo_main(int argc, char **argv, const llvm::ToolContext &) { - InitLLVM X(argc, argv); llvm::InitializeAllTargetInfos(); llvm::InitializeAllTargetMCs(); llvm::InitializeAllAsmParsers(); diff --git a/llvm/tools/llvm-ml/llvm-ml.cpp b/llvm/tools/llvm-ml/llvm-ml.cpp index 1c713304e4ea1..1cac576f54e77 100644 --- a/llvm/tools/llvm-ml/llvm-ml.cpp +++ b/llvm/tools/llvm-ml/llvm-ml.cpp @@ -34,7 +34,6 @@ #include "llvm/Support/FileUtilities.h" #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/FormattedStream.h" -#include "llvm/Support/InitLLVM.h" #include "llvm/Support/LLVMDriver.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" @@ -187,7 +186,6 @@ static int AssembleInput(StringRef ProgName, const Target *TheTarget, } int llvm_ml_main(int Argc, char **Argv, const llvm::ToolContext &) { - InitLLVM X(Argc, Argv); StringRef ProgName = sys::path::filename(Argv[0]); // Initialize targets and assembly printers/parsers. diff --git a/llvm/tools/llvm-mt/llvm-mt.cpp b/llvm/tools/llvm-mt/llvm-mt.cpp index 246e092898b3b..158088dc77d85 100644 --- a/llvm/tools/llvm-mt/llvm-mt.cpp +++ b/llvm/tools/llvm-mt/llvm-mt.cpp @@ -16,7 +16,6 @@ #include "llvm/Option/Option.h" #include "llvm/Support/Error.h" #include "llvm/Support/FileOutputBuffer.h" -#include "llvm/Support/InitLLVM.h" #include "llvm/Support/LLVMDriver.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" @@ -77,8 +76,6 @@ static void error(Error EC) { } int llvm_mt_main(int Argc, char **Argv, const llvm::ToolContext &) { - InitLLVM X(Argc, Argv); - CvtResOptTable T; unsigned MAI, MAC; ArrayRef ArgsArr = ArrayRef(Argv + 1, Argc - 1); diff --git a/llvm/tools/llvm-nm/llvm-nm.cpp b/llvm/tools/llvm-nm/llvm-nm.cpp index 19ee5374979c8..da5998b70ea3f 100644 --- a/llvm/tools/llvm-nm/llvm-nm.cpp +++ b/llvm/tools/llvm-nm/llvm-nm.cpp @@ -42,7 +42,6 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Format.h" -#include "llvm/Support/InitLLVM.h" #include "llvm/Support/LLVMDriver.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Program.h" @@ -2405,7 +2404,6 @@ exportSymbolNamesFromFiles(const std::vector &InputFilenames) { } int llvm_nm_main(int argc, char **argv, const llvm::ToolContext &) { - InitLLVM X(argc, argv); BumpPtrAllocator A; StringSaver Saver(A); NmOptTable Tbl; diff --git a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp index 558359eca3cd7..730f423daa12f 100644 --- a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp +++ b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp @@ -42,7 +42,6 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorOr.h" #include "llvm/Support/FileUtilities.h" -#include "llvm/Support/InitLLVM.h" #include "llvm/Support/LLVMDriver.h" #include "llvm/Support/Memory.h" #include "llvm/Support/Path.h" @@ -224,7 +223,6 @@ static Error executeObjcopy(ConfigManager &ConfigMgr) { } int llvm_objcopy_main(int argc, char **argv, const llvm::ToolContext &) { - InitLLVM X(argc, argv); ToolName = argv[0]; // Expand response files. diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index 7467a6062b5a8..8944965ccf80a 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -71,7 +71,6 @@ #include "llvm/Support/Format.h" #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/GraphWriter.h" -#include "llvm/Support/InitLLVM.h" #include "llvm/Support/LLVMDriver.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/SourceMgr.h" @@ -3417,7 +3416,6 @@ static void parseObjdumpOptions(const llvm::opt::InputArgList &InputArgs) { int llvm_objdump_main(int argc, char **argv, const llvm::ToolContext &) { using namespace llvm; - InitLLVM X(argc, argv); ToolName = argv[0]; std::unique_ptr T; diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp index 05e96f48cf124..e6dc81ba1f5b0 100644 --- a/llvm/tools/llvm-profdata/llvm-profdata.cpp +++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp @@ -30,7 +30,6 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/Format.h" #include "llvm/Support/FormattedStream.h" -#include "llvm/Support/InitLLVM.h" #include "llvm/Support/LLVMDriver.h" #include "llvm/Support/MD5.h" #include "llvm/Support/MemoryBuffer.h" @@ -3176,7 +3175,6 @@ static int order_main(int argc, const char *argv[]) { int llvm_profdata_main(int argc, char **argvNonConst, const llvm::ToolContext &) { const char **argv = const_cast(argvNonConst); - InitLLVM X(argc, argv); StringRef ProgName(sys::path::filename(argv[0])); diff --git a/llvm/tools/llvm-rc/llvm-rc.cpp b/llvm/tools/llvm-rc/llvm-rc.cpp index 78ab96492acc7..ec36676636498 100644 --- a/llvm/tools/llvm-rc/llvm-rc.cpp +++ b/llvm/tools/llvm-rc/llvm-rc.cpp @@ -26,7 +26,6 @@ #include "llvm/Support/Error.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/FileUtilities.h" -#include "llvm/Support/InitLLVM.h" #include "llvm/Support/LLVMDriver.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" @@ -731,7 +730,6 @@ void doCvtres(std::string Src, std::string Dest, std::string TargetTriple) { } // anonymous namespace int llvm_rc_main(int Argc, char **Argv, const llvm::ToolContext &) { - InitLLVM X(Argc, Argv); ExitOnErr.setBanner("llvm-rc: "); char **DashDash = std::find_if(Argv + 1, Argv + Argc, diff --git a/llvm/tools/llvm-readobj/llvm-readobj.cpp b/llvm/tools/llvm-readobj/llvm-readobj.cpp index ca633ceff9080..f9d605d35244b 100644 --- a/llvm/tools/llvm-readobj/llvm-readobj.cpp +++ b/llvm/tools/llvm-readobj/llvm-readobj.cpp @@ -42,7 +42,6 @@ #include "llvm/Support/Errc.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/FormatVariadic.h" -#include "llvm/Support/InitLLVM.h" #include "llvm/Support/LLVMDriver.h" #include "llvm/Support/Path.h" #include "llvm/Support/ScopedPrinter.h" @@ -633,7 +632,6 @@ std::unique_ptr createWriter() { } int llvm_readobj_main(int argc, char **argv, const llvm::ToolContext &) { - InitLLVM X(argc, argv); BumpPtrAllocator A; StringSaver Saver(A); ReadobjOptTable Tbl; diff --git a/llvm/tools/llvm-size/llvm-size.cpp b/llvm/tools/llvm-size/llvm-size.cpp index c0d1a1b104b89..78b207eeeb121 100644 --- a/llvm/tools/llvm-size/llvm-size.cpp +++ b/llvm/tools/llvm-size/llvm-size.cpp @@ -25,7 +25,6 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Format.h" -#include "llvm/Support/InitLLVM.h" #include "llvm/Support/LLVMDriver.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/WithColor.h" @@ -863,7 +862,6 @@ static void printBerkeleyTotals() { } int llvm_size_main(int argc, char **argv, const llvm::ToolContext &) { - InitLLVM X(argc, argv); BumpPtrAllocator A; StringSaver Saver(A); SizeOptTable Tbl; diff --git a/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp b/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp index 74cc2da4e1ca2..b98bdbc388faf 100644 --- a/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp +++ b/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp @@ -34,7 +34,6 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/Errc.h" #include "llvm/Support/FileSystem.h" -#include "llvm/Support/InitLLVM.h" #include "llvm/Support/LLVMDriver.h" #include "llvm/Support/Path.h" #include "llvm/Support/StringSaver.h" @@ -462,7 +461,6 @@ static void filterMarkup(const opt::InputArgList &Args, LLVMSymbolizer &Symboliz } int llvm_symbolizer_main(int argc, char **argv, const llvm::ToolContext &) { - InitLLVM X(argc, argv); sys::InitializeCOMRAII COM(sys::COMThreadingMode::MultiThreaded); ToolName = argv[0]; diff --git a/llvm/tools/sancov/sancov.cpp b/llvm/tools/sancov/sancov.cpp index d30bdf3e5c60d..e5b0875d46a11 100644 --- a/llvm/tools/sancov/sancov.cpp +++ b/llvm/tools/sancov/sancov.cpp @@ -36,7 +36,6 @@ #include "llvm/Support/Errc.h" #include "llvm/Support/ErrorOr.h" #include "llvm/Support/FileSystem.h" -#include "llvm/Support/InitLLVM.h" #include "llvm/Support/JSON.h" #include "llvm/Support/LLVMDriver.h" #include "llvm/Support/MD5.h" @@ -1215,8 +1214,6 @@ static void parseArgs(int Argc, char **Argv) { } int sancov_main(int Argc, char **Argv, const llvm::ToolContext &) { - llvm::InitLLVM X(Argc, Argv); - llvm::InitializeAllTargetInfos(); llvm::InitializeAllTargetMCs(); llvm::InitializeAllDisassemblers();