[llvm] [llvm-cgdata] Fix the build in the non-driver mode (PR #100077)

Petr Hosek via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 23 01:25:53 PDT 2024


https://github.com/petrhosek updated https://github.com/llvm/llvm-project/pull/100077

>From 5c300d529b7c13c06cfa19ddbe3009d2e5f18046 Mon Sep 17 00:00:00 2001
From: Petr Hosek <phosek at google.com>
Date: Tue, 23 Jul 2024 08:21:09 +0000
Subject: [PATCH] [llvm-cgdata] Remove GENERATE_DRIVER option

This tool shouldn't be used in the driver build until it is converted to
use `OptTable` for option parsing, otherwise the `cl::opt` options might
conflict with options in other tools resulting in link failures.

This is a reland of #100066.
---
 llvm/tools/llvm-cgdata/CMakeLists.txt  | 1 -
 llvm/tools/llvm-cgdata/llvm-cgdata.cpp | 6 +++---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/llvm/tools/llvm-cgdata/CMakeLists.txt b/llvm/tools/llvm-cgdata/CMakeLists.txt
index 4f1f7ff635bc3..966384278b9ab 100644
--- a/llvm/tools/llvm-cgdata/CMakeLists.txt
+++ b/llvm/tools/llvm-cgdata/CMakeLists.txt
@@ -11,5 +11,4 @@ add_llvm_tool(llvm-cgdata
 
   DEPENDS
   intrinsics_gen
-  GENERATE_DRIVER
   )
diff --git a/llvm/tools/llvm-cgdata/llvm-cgdata.cpp b/llvm/tools/llvm-cgdata/llvm-cgdata.cpp
index 3303ffd9d863b..4ad0357b95d86 100644
--- a/llvm/tools/llvm-cgdata/llvm-cgdata.cpp
+++ b/llvm/tools/llvm-cgdata/llvm-cgdata.cpp
@@ -18,7 +18,7 @@
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/Object/Archive.h"
 #include "llvm/Support/CommandLine.h"
-#include "llvm/Support/LLVMDriver.h"
+#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/WithColor.h"
@@ -240,8 +240,8 @@ static int show_main(int argc, const char *argv[]) {
   return 0;
 }
 
-int llvm_cgdata_main(int argc, char **argvNonConst, const llvm::ToolContext &) {
-  const char **argv = const_cast<const char **>(argvNonConst);
+int main(int argc, const char **argv) {
+  llvm::InitLLVM X(argc, argv);
 
   StringRef ProgName(sys::path::filename(argv[0]));
 



More information about the llvm-commits mailing list