diff --git a/llvm/tools/llvm-gsymutil/CMakeLists.txt b/llvm/tools/llvm-gsymutil/CMakeLists.txt --- a/llvm/tools/llvm-gsymutil/CMakeLists.txt +++ b/llvm/tools/llvm-gsymutil/CMakeLists.txt @@ -18,4 +18,6 @@ DEPENDS GSYMUtilOptsTableGen + + GENERATE_DRIVER ) diff --git a/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp b/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp --- a/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp +++ b/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp @@ -19,6 +19,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Format.h" +#include "llvm/Support/LLVMDriver.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/PrettyStackTrace.h" @@ -492,7 +493,7 @@ OS << "\n"; } -int main(int argc, char **argv) { +int llvm_gsymutil_main(int argc, char **argv, const llvm::ToolContext &) { // Print a stack trace if we signal out. sys::PrintStackTraceOnErrorSignal(argv[0]); PrettyStackTraceProgram X(argc, argv); diff --git a/llvm/utils/gn/secondary/llvm/tools/llvm-gsymutil/BUILD.gn b/llvm/utils/gn/secondary/llvm/tools/llvm-gsymutil/BUILD.gn --- a/llvm/utils/gn/secondary/llvm/tools/llvm-gsymutil/BUILD.gn +++ b/llvm/utils/gn/secondary/llvm/tools/llvm-gsymutil/BUILD.gn @@ -1,11 +1,12 @@ import("//llvm/utils/TableGen/tablegen.gni") +import("//llvm/utils/gn/build/driver_executable.gni") tablegen("Opts") { visibility = [ ":llvm-gsymutil" ] args = [ "-gen-opt-parser-defs" ] } -executable("llvm-gsymutil") { +driver_executable("llvm-gsymutil") { deps = [ ":Opts", "//llvm/lib/DebugInfo/DWARF", diff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel @@ -3461,12 +3461,21 @@ td_srcs = ["include/llvm/Option/OptParser.td"], ) +expand_template( + name = "gsymutil_main", + out = "llvm-gsymutil-driver.cpp", + substitutions = { + "@TOOL_NAME@": "llvm_gsymutil", + }, + template = "cmake/modules/llvm-driver-template.cpp.in", +) + cc_binary( name = "llvm-gsymutil", srcs = glob([ "tools/llvm-gsymutil/*.cpp", "tools/llvm-gsymutil/*.h", - ]), + ]) + ["llvm-gsymutil-driver.cpp"], copts = llvm_copts, stamp = 0, deps = [