[llvm-gsymutil] Add gsymutil to llvm driver build
authorAlex Brachet <abrachet@google.com>
Fri, 28 Apr 2023 15:15:16 +0000 (15:15 +0000)
committerAlex Brachet <abrachet@google.com>
Fri, 28 Apr 2023 15:15:16 +0000 (15:15 +0000)
Differential Revision: https://reviews.llvm.org/D149283

llvm/tools/llvm-gsymutil/CMakeLists.txt
llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
llvm/utils/gn/secondary/llvm/tools/llvm-gsymutil/BUILD.gn
utils/bazel/llvm-project-overlay/llvm/BUILD.bazel

index 1ec9592..7f8a21a 100644 (file)
@@ -18,4 +18,6 @@ add_llvm_tool(llvm-gsymutil
 
   DEPENDS
   GSYMUtilOptsTableGen
+
+  GENERATE_DRIVER
   )
index f3b7932..68d36f2 100644 (file)
@@ -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 @@ static void doLookup(GsymReader &Gsym, uint64_t Addr, raw_ostream &OS) {
     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);
index 2fe2543..733e554 100644 (file)
@@ -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",
index b45d436..3ebc98e 100644 (file)
@@ -3461,12 +3461,21 @@ gentbl(
     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 = [