Index: clang/tools/driver/driver.cpp =================================================================== --- clang/tools/driver/driver.cpp +++ clang/tools/driver/driver.cpp @@ -37,6 +37,7 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/Host.h" #include "llvm/Support/InitLLVM.h" +#include "llvm/Support/LLVMDriver.h" #include "llvm/Support/Path.h" #include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/Process.h" @@ -329,7 +330,7 @@ return 1; } -int clang_main(int Argc, char **Argv) { +int clang_main(int Argc, char **Argv, const llvm::LLVMDriverExtraArgs &) { noteBottomOfStack(); llvm::InitLLVM X(Argc, Argv); llvm::setBugReportMsg("PLEASE submit a bug report to " BUG_REPORT_URL Index: lld/tools/lld/lld.cpp =================================================================== --- lld/tools/lld/lld.cpp +++ lld/tools/lld/lld.cpp @@ -37,6 +37,7 @@ #include "llvm/Support/CrashRecoveryContext.h" #include "llvm/Support/Host.h" #include "llvm/Support/InitLLVM.h" +#include "llvm/Support/LLVMDriver.h" #include "llvm/Support/Path.h" #include "llvm/Support/PluginLoader.h" #include "llvm/Support/Process.h" @@ -212,7 +213,7 @@ return v; } -int lld_main(int argc, char **argv) { +int lld_main(int argc, char **argv, const llvm::LLVMDriverExtraArgs &) { InitLLVM x(argc, argv); sys::Process::UseANSIEscapeCodes(true); Index: llvm/cmake/modules/llvm-driver-template.cpp.in =================================================================== --- llvm/cmake/modules/llvm-driver-template.cpp.in +++ llvm/cmake/modules/llvm-driver-template.cpp.in @@ -6,6 +6,8 @@ // //===----------------------------------------------------------------------===// -int @TOOL_NAME@_main(int argc, char **argv); +#include "llvm/Support/LLVMDriver.h" -int main(int argc, char **argv) { return @TOOL_NAME@_main(argc, argv); } +int @TOOL_NAME@_main(int argc, char **argv, const llvm::LLVMDriverExtraArgs &); + +int main(int argc, char **argv) { return @TOOL_NAME@_main(argc, argv, {}); } Index: llvm/include/llvm/Support/LLVMDriver.h =================================================================== --- /dev/null +++ llvm/include/llvm/Support/LLVMDriver.h @@ -0,0 +1,18 @@ +//===- LLVMDriver.h ---------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_LLVMDRIVER_H +#define LLVM_SUPPORT_LLVMDRIVER_H + +namespace llvm { + +struct LLVMDriverExtraArgs {}; + +} // namespace llvm + +#endif Index: llvm/tools/dsymutil/dsymutil.cpp =================================================================== --- llvm/tools/dsymutil/dsymutil.cpp +++ llvm/tools/dsymutil/dsymutil.cpp @@ -37,6 +37,7 @@ #include "llvm/Support/FileCollector.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/InitLLVM.h" +#include "llvm/Support/LLVMDriver.h" #include "llvm/Support/Path.h" #include "llvm/Support/TargetSelect.h" #include "llvm/Support/ThreadPool.h" @@ -546,7 +547,7 @@ return OutputLocation(std::string(Path.str()), ResourceDir); } -int dsymutil_main(int argc, char **argv) { +int dsymutil_main(int argc, char **argv, const llvm::LLVMDriverExtraArgs &) { InitLLVM X(argc, argv); // Parse arguments. Index: llvm/tools/llvm-ar/llvm-ar.cpp =================================================================== --- llvm/tools/llvm-ar/llvm-ar.cpp +++ llvm/tools/llvm-ar/llvm-ar.cpp @@ -36,6 +36,7 @@ #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/Host.h" #include "llvm/Support/InitLLVM.h" +#include "llvm/Support/LLVMDriver.h" #include "llvm/Support/LineIterator.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" @@ -1444,7 +1445,7 @@ return 0; } -int llvm_ar_main(int argc, char **argv) { +int llvm_ar_main(int argc, char **argv, const llvm::LLVMDriverExtraArgs &) { InitLLVM X(argc, argv); ToolName = argv[0]; Index: llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp =================================================================== --- llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp +++ llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp @@ -15,6 +15,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/Host.h" #include "llvm/Support/InitLLVM.h" +#include "llvm/Support/LLVMDriver.h" #include "llvm/Support/WithColor.h" #include "llvm/Support/raw_ostream.h" #include @@ -140,7 +141,8 @@ OS.flush(); } -int llvm_cxxfilt_main(int argc, char **argv) { +int llvm_cxxfilt_main(int argc, char **argv, + const llvm::LLVMDriverExtraArgs &) { InitLLVM X(argc, argv); BumpPtrAllocator A; StringSaver Saver(A); Index: llvm/tools/llvm-driver/llvm-driver.cpp =================================================================== --- llvm/tools/llvm-driver/llvm-driver.cpp +++ llvm/tools/llvm-driver/llvm-driver.cpp @@ -11,12 +11,14 @@ #include "llvm/ADT/StringSwitch.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/LLVMDriver.h" #include "llvm/Support/Path.h" #include "llvm/Support/WithColor.h" using namespace llvm; -#define LLVM_DRIVER_TOOL(tool, entry) int entry##_main(int argc, char **argv); +#define LLVM_DRIVER_TOOL(tool, entry) \ + int entry##_main(int argc, char **argv, const llvm::LLVMDriverExtraArgs &); #include "LLVMDriverTools.def" constexpr char subcommands[] = @@ -62,7 +64,7 @@ #define LLVM_DRIVER_TOOL(tool, entry) \ if (Is(tool)) \ - return entry##_main(Argc, Argv); + return entry##_main(Argc, Argv, {}); #include "LLVMDriverTools.def" if (Is("llvm")) Index: llvm/tools/llvm-ifs/llvm-ifs.cpp =================================================================== --- llvm/tools/llvm-ifs/llvm-ifs.cpp +++ llvm/tools/llvm-ifs/llvm-ifs.cpp @@ -23,6 +23,7 @@ #include "llvm/Support/Errc.h" #include "llvm/Support/Error.h" #include "llvm/Support/FileOutputBuffer.h" +#include "llvm/Support/LLVMDriver.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" #include "llvm/Support/VersionTuple.h" @@ -376,7 +377,7 @@ return Config; } -int llvm_ifs_main(int argc, char **argv) { +int llvm_ifs_main(int argc, char **argv, const llvm::LLVMDriverExtraArgs &) { DriverConfig Config = parseArgs(argc, argv); if (Config.InputFilePaths.empty()) Index: llvm/tools/llvm-lipo/llvm-lipo.cpp =================================================================== --- llvm/tools/llvm-lipo/llvm-lipo.cpp +++ llvm/tools/llvm-lipo/llvm-lipo.cpp @@ -28,6 +28,7 @@ #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" #include "llvm/TextAPI/Architecture.h" @@ -719,7 +720,7 @@ exit(EXIT_SUCCESS); } -int llvm_lipo_main(int argc, char **argv) { +int llvm_lipo_main(int argc, char **argv, const llvm::LLVMDriverExtraArgs &) { InitLLVM X(argc, argv); llvm::InitializeAllTargetInfos(); llvm::InitializeAllTargetMCs(); Index: llvm/tools/llvm-mt/llvm-mt.cpp =================================================================== --- llvm/tools/llvm-mt/llvm-mt.cpp +++ llvm/tools/llvm-mt/llvm-mt.cpp @@ -17,6 +17,7 @@ #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" #include "llvm/Support/PrettyStackTrace.h" @@ -79,7 +80,7 @@ }); } -int llvm_mt_main(int Argc, char **Argv) { +int llvm_mt_main(int Argc, char **Argv, const llvm::LLVMDriverExtraArgs &) { InitLLVM X(Argc, Argv); CvtResOptTable T; Index: llvm/tools/llvm-nm/llvm-nm.cpp =================================================================== --- llvm/tools/llvm-nm/llvm-nm.cpp +++ llvm/tools/llvm-nm/llvm-nm.cpp @@ -42,6 +42,7 @@ #include "llvm/Support/Format.h" #include "llvm/Support/Host.h" #include "llvm/Support/InitLLVM.h" +#include "llvm/Support/LLVMDriver.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Program.h" #include "llvm/Support/Signals.h" @@ -2297,7 +2298,7 @@ printExportSymbolList(SymbolList); } -int llvm_nm_main(int argc, char **argv) { +int llvm_nm_main(int argc, char **argv, const llvm::LLVMDriverExtraArgs &) { InitLLVM X(argc, argv); BumpPtrAllocator A; StringSaver Saver(A); Index: llvm/tools/llvm-objcopy/llvm-objcopy.cpp =================================================================== --- llvm/tools/llvm-objcopy/llvm-objcopy.cpp +++ llvm/tools/llvm-objcopy/llvm-objcopy.cpp @@ -44,6 +44,7 @@ #include "llvm/Support/FileUtilities.h" #include "llvm/Support/Host.h" #include "llvm/Support/InitLLVM.h" +#include "llvm/Support/LLVMDriver.h" #include "llvm/Support/Memory.h" #include "llvm/Support/Path.h" #include "llvm/Support/Process.h" @@ -223,7 +224,8 @@ return Error::success(); } -int llvm_objcopy_main(int argc, char **argv) { +int llvm_objcopy_main(int argc, char **argv, + const llvm::LLVMDriverExtraArgs &) { InitLLVM X(argc, argv); ToolName = argv[0]; Index: llvm/tools/llvm-profdata/llvm-profdata.cpp =================================================================== --- llvm/tools/llvm-profdata/llvm-profdata.cpp +++ llvm/tools/llvm-profdata/llvm-profdata.cpp @@ -31,6 +31,7 @@ #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" #include "llvm/Support/Path.h" @@ -2859,7 +2860,8 @@ return showMemProfProfile(Filename, ProfiledBinary, SFormat, OS); } -int llvm_profdata_main(int argc, char **argvNonConst) { +int llvm_profdata_main(int argc, char **argvNonConst, + const llvm::LLVMDriverExtraArgs &) { const char **argv = const_cast(argvNonConst); InitLLVM X(argc, argv); Index: llvm/tools/llvm-rc/llvm-rc.cpp =================================================================== --- llvm/tools/llvm-rc/llvm-rc.cpp +++ llvm/tools/llvm-rc/llvm-rc.cpp @@ -27,6 +27,7 @@ #include "llvm/Support/FileUtilities.h" #include "llvm/Support/Host.h" #include "llvm/Support/InitLLVM.h" +#include "llvm/Support/LLVMDriver.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" #include "llvm/Support/PrettyStackTrace.h" @@ -724,7 +725,7 @@ } // anonymous namespace -int llvm_rc_main(int Argc, char **Argv) { +int llvm_rc_main(int Argc, char **Argv, const llvm::LLVMDriverExtraArgs &) { InitLLVM X(Argc, Argv); ExitOnErr.setBanner("llvm-rc: "); Index: llvm/tools/llvm-readobj/llvm-readobj.cpp =================================================================== --- llvm/tools/llvm-readobj/llvm-readobj.cpp +++ llvm/tools/llvm-readobj/llvm-readobj.cpp @@ -44,6 +44,7 @@ #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" #include "llvm/Support/WithColor.h" @@ -620,7 +621,8 @@ return std::make_unique(fouts()); } -int llvm_readobj_main(int argc, char **argv) { +int llvm_readobj_main(int argc, char **argv, + const llvm::LLVMDriverExtraArgs &) { InitLLVM X(argc, argv); BumpPtrAllocator A; StringSaver Saver(A); Index: llvm/tools/llvm-size/llvm-size.cpp =================================================================== --- llvm/tools/llvm-size/llvm-size.cpp +++ llvm/tools/llvm-size/llvm-size.cpp @@ -26,6 +26,7 @@ #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" #include "llvm/Support/raw_ostream.h" @@ -866,7 +867,7 @@ << "(TOTALS)\n"; } -int llvm_size_main(int argc, char **argv) { +int llvm_size_main(int argc, char **argv, const llvm::LLVMDriverExtraArgs &) { InitLLVM X(argc, argv); BumpPtrAllocator A; StringSaver Saver(A);