diff --git a/llvm/tools/dsymutil/CMakeLists.txt b/llvm/tools/dsymutil/CMakeLists.txt --- a/llvm/tools/dsymutil/CMakeLists.txt +++ b/llvm/tools/dsymutil/CMakeLists.txt @@ -36,9 +36,10 @@ intrinsics_gen ${tablegen_deps} DsymutilTableGen + GENERATE_DRIVER ) -if(APPLE) +if(APPLE AND NOT LLVM_TOOL_LLVM_DRIVER_BUILD) target_link_libraries(dsymutil PRIVATE "-framework CoreFoundation") endif(APPLE) diff --git a/llvm/tools/dsymutil/dsymutil.cpp b/llvm/tools/dsymutil/dsymutil.cpp --- a/llvm/tools/dsymutil/dsymutil.cpp +++ b/llvm/tools/dsymutil/dsymutil.cpp @@ -595,7 +595,7 @@ return OutputLocation(std::string(Path.str()), ResourceDir); } -int main(int argc, char **argv) { +int dsymutil_main(int argc, char **argv, const llvm::ToolContext &) { InitLLVM X(argc, argv); // Parse arguments. diff --git a/llvm/tools/llvm-debuginfod/CMakeLists.txt b/llvm/tools/llvm-debuginfod/CMakeLists.txt --- a/llvm/tools/llvm-debuginfod/CMakeLists.txt +++ b/llvm/tools/llvm-debuginfod/CMakeLists.txt @@ -11,8 +11,13 @@ DEPENDS DebugInfodOptsTableGen + GENERATE_DRIVER ) -target_link_libraries(llvm-debuginfod PRIVATE LLVMDebuginfod) + +if(NOT LLVM_TOOL_LLVM_DRIVER_BUILD) + target_link_libraries(llvm-debuginfod PRIVATE LLVMDebuginfod) +endif() + if(LLVM_INSTALL_BINUTILS_SYMLINKS) add_llvm_tool_symlink(debuginfod llvm-debuginfod) endif() diff --git a/llvm/tools/llvm-debuginfod/llvm-debuginfod.cpp b/llvm/tools/llvm-debuginfod/llvm-debuginfod.cpp --- a/llvm/tools/llvm-debuginfod/llvm-debuginfod.cpp +++ b/llvm/tools/llvm-debuginfod/llvm-debuginfod.cpp @@ -23,6 +23,7 @@ #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" using namespace llvm; @@ -119,7 +120,7 @@ HostInterface = Args.getLastArgValue(OPT_host_interface, "0.0.0.0"); } -int main(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/CMakeLists.txt b/llvm/tools/llvm-driver/CMakeLists.txt --- a/llvm/tools/llvm-driver/CMakeLists.txt +++ b/llvm/tools/llvm-driver/CMakeLists.txt @@ -25,6 +25,12 @@ set_target_properties(llvm-driver PROPERTIES OUTPUT_NAME llvm) target_link_libraries(llvm-driver PUBLIC ${LLVM_DRIVER_OBJLIBS}) +target_link_libraries(llvm-driver PUBLIC LLVMDebuginfod) + +if(LLVM_HAVE_LIBXAR) + # used by llvm-objdump + target_link_libraries(llvm-driver PUBLIC ${XAR_LIB}) +endif() if(APPLE) # dsymutil uses some CoreFoundation stuff on Darwin... diff --git a/llvm/tools/llvm-ml/CMakeLists.txt b/llvm/tools/llvm-ml/CMakeLists.txt --- a/llvm/tools/llvm-ml/CMakeLists.txt +++ b/llvm/tools/llvm-ml/CMakeLists.txt @@ -18,4 +18,7 @@ add_llvm_tool(llvm-ml llvm-ml.cpp Disassembler.cpp + DEPENDS + MLTableGen + GENERATE_DRIVER ) diff --git a/llvm/tools/llvm-ml/llvm-ml.cpp b/llvm/tools/llvm-ml/llvm-ml.cpp --- a/llvm/tools/llvm-ml/llvm-ml.cpp +++ b/llvm/tools/llvm-ml/llvm-ml.cpp @@ -35,6 +35,7 @@ #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" #include "llvm/Support/Process.h" @@ -185,7 +186,7 @@ return Res; } -int main(int Argc, char **Argv) { +int llvm_ml_main(int Argc, char **Argv, const llvm::ToolContext &) { InitLLVM X(Argc, Argv); StringRef ProgName = sys::path::filename(Argv[0]); diff --git a/llvm/tools/llvm-objdump/CMakeLists.txt b/llvm/tools/llvm-objdump/CMakeLists.txt --- a/llvm/tools/llvm-objdump/CMakeLists.txt +++ b/llvm/tools/llvm-objdump/CMakeLists.txt @@ -34,11 +34,14 @@ DEPENDS ObjdumpOptsTableGen OtoolOptsTableGen + GENERATE_DRIVER ) -target_link_libraries(llvm-objdump PRIVATE LLVMDebuginfod) +if(NOT LLVM_TOOL_LLVM_DRIVER_BUILD) + target_link_libraries(llvm-objdump PRIVATE LLVMDebuginfod) +endif() -if(LLVM_HAVE_LIBXAR) +if(LLVM_HAVE_LIBXAR AND NOT LLVM_TOOL_LLVM_DRIVER_BUILD) target_link_libraries(llvm-objdump PRIVATE ${XAR_LIB}) endif() diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -73,6 +73,7 @@ #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" #include "llvm/Support/StringSaver.h" @@ -3247,7 +3248,7 @@ InputFilenames.push_back("a.out"); } -int main(int argc, char **argv) { +int llvm_objdump_main(int argc, char **argv, const llvm::ToolContext &) { using namespace llvm; InitLLVM X(argc, argv); diff --git a/llvm/tools/llvm-symbolizer/CMakeLists.txt b/llvm/tools/llvm-symbolizer/CMakeLists.txt --- a/llvm/tools/llvm-symbolizer/CMakeLists.txt +++ b/llvm/tools/llvm-symbolizer/CMakeLists.txt @@ -20,9 +20,12 @@ DEPENDS SymbolizerOptsTableGen + GENERATE_DRIVER ) -target_link_libraries(llvm-symbolizer PRIVATE LLVMDebuginfod) +if(NOT LLVM_TOOL_LLVM_DRIVER_BUILD) + target_link_libraries(llvm-symbolizer PRIVATE LLVMDebuginfod) +endif() add_llvm_tool_symlink(llvm-addr2line llvm-symbolizer) diff --git a/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp b/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp --- a/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp +++ b/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp @@ -34,6 +34,7 @@ #include "llvm/Support/Debug.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" #include "llvm/Support/WithColor.h" @@ -395,7 +396,7 @@ Filter.finish(); } -int main(int argc, char **argv) { +int llvm_symbolizer_main(int argc, char **argv, const llvm::ToolContext &) { InitLLVM X(argc, argv); sys::InitializeCOMRAII COM(sys::COMThreadingMode::MultiThreaded);