[llvm] 9449f44 - gn build: Add support for building LLDB on Linux.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 8 19:35:29 PDT 2021


Author: Peter Collingbourne
Date: 2021-09-08T19:33:51-07:00
New Revision: 9449f441fc9b7eff6e84b00b4c2488041fbb34f4

URL: https://github.com/llvm/llvm-project/commit/9449f441fc9b7eff6e84b00b4c2488041fbb34f4
DIFF: https://github.com/llvm/llvm-project/commit/9449f441fc9b7eff6e84b00b4c2488041fbb34f4.diff

LOG: gn build: Add support for building LLDB on Linux.

On Linux, LLDB depends on lldb-server at runtime (on Mac, the dependency on
a debug server presumably comes via the system debugserver), so I added it
to deps.

Differential Revision: https://reviews.llvm.org/D109463

Added: 
    llvm/utils/gn/secondary/lldb/source/Plugins/Platform/Linux/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/Process/Linux/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/Process/POSIX/BUILD.gn

Modified: 
    llvm/utils/gn/secondary/BUILD.gn
    llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Initialization/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/ObjectFile/JIT/BUILD.gn
    llvm/utils/gn/secondary/lldb/tools/driver/BUILD.gn
    llvm/utils/gn/secondary/lldb/tools/lldb-server/BUILD.gn

Removed: 
    


################################################################################
diff  --git a/llvm/utils/gn/secondary/BUILD.gn b/llvm/utils/gn/secondary/BUILD.gn
index b60851946e168..d5b47138ead11 100644
--- a/llvm/utils/gn/secondary/BUILD.gn
+++ b/llvm/utils/gn/secondary/BUILD.gn
@@ -20,7 +20,7 @@ group("default") {
       "//libcxxabi",
     ]
   }
-  if (current_os == "mac") {
+  if (current_os == "linux" || current_os == "mac") {
     deps += [ "//lldb/test" ]
   }
   if (current_os == "linux" || current_os == "android") {

diff  --git a/llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn b/llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn
index 0875aa3cd31bb..f51980c1ca872 100644
--- a/llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn
+++ b/llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn
@@ -12,7 +12,6 @@ write_cmake_config("Config") {
     # FIXME: Actual values for everything.
     "LLDB_EDITLINE_USE_WCHAR=",
     "LLDB_HAVE_EL_RFUNC_T=",
-    "HAVE_PPOLL=",
     "HAVE_PTSNAME_R=",
     "HAVE_PROCESS_VM_READV=",
     "HAVE_NR_PROCESS_VM_READV=",
@@ -44,15 +43,25 @@ write_cmake_config("Config") {
 
   if (current_os == "win") {
     values += [
-      "HAVE_SYS_EVENT_H=",
       "LLDB_ENABLE_POSIX=",
       "LLDB_ENABLE_TERMIOS=",
     ]
   } else {
     values += [
-      "HAVE_SYS_EVENT_H=1",
       "LLDB_ENABLE_POSIX=1",
       "LLDB_ENABLE_TERMIOS=1",
     ]
   }
+  
+  if (current_os == "win" || current_os == "linux" || current_os == "android") {
+    values += [ "HAVE_SYS_EVENT_H=" ]
+  } else {
+    values += [ "HAVE_SYS_EVENT_H=1" ]
+  }
+
+  if (current_os == "linux" || current_os == "android") {
+    values += [ "HAVE_PPOLL=1" ]
+  } else {
+    values += [ "HAVE_PPOLL=" ]
+  }
 }

diff  --git a/llvm/utils/gn/secondary/lldb/source/Initialization/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Initialization/BUILD.gn
index 2f1de05abc84d..de93cc567b2a2 100644
--- a/llvm/utils/gn/secondary/lldb/source/Initialization/BUILD.gn
+++ b/llvm/utils/gn/secondary/lldb/source/Initialization/BUILD.gn
@@ -7,10 +7,12 @@ static_library("Initialization") {
     "//lldb/source/Plugins/Process/gdb-remote",
 
     # XXX:
-    # lldbPluginProcessPOSIX on linux/android
     # lldbPluginProcessWindowsCommon on win
     "//llvm/lib/Support",
   ]
+  if (current_os == "linux" || current_os == "android") {
+    deps += [ "//lldb/source/Plugins/Process/POSIX" ]
+  }
 
   # SystemInitializerCommon.cpp includes headers from Plugins/Process/....
   include_dirs = [ ".." ]

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/BUILD.gn
index 3d72011937488..594be6170363a 100644
--- a/llvm/utils/gn/secondary/lldb/source/Plugins/BUILD.gn
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/BUILD.gn
@@ -108,6 +108,10 @@ lldb_plugins += [
     "//lldb/source/Plugins/ObjectFile/wasm",
     "ObjectFileWasm",
   ],
+  [
+    "//lldb/source/Plugins/Platform/Linux",
+    "PlatformLinux",
+  ],
   [
     "//lldb/source/Plugins/Platform/MacOSX",
     "PlatformMacOSX",

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/ObjectFile/JIT/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/ObjectFile/JIT/BUILD.gn
index 1b6254c41217a..4e5357aa9f10d 100644
--- a/llvm/utils/gn/secondary/lldb/source/Plugins/ObjectFile/JIT/BUILD.gn
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/ObjectFile/JIT/BUILD.gn
@@ -10,4 +10,6 @@ static_library("JIT") {
     "//llvm/lib/Support",
   ]
   sources = [ "ObjectFileJIT.cpp" ]
+  # For Utility/UuidCompatibility.h.
+  include_dirs = [ "//lldb/source" ]
 }

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/Platform/Linux/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/Platform/Linux/BUILD.gn
new file mode 100644
index 0000000000000..a115e58453e1b
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/Platform/Linux/BUILD.gn
@@ -0,0 +1,18 @@
+static_library("Linux") {
+  output_name = "lldbPluginPlatformLinux"
+  configs += [
+    "//llvm/utils/gn/build:clang_code",
+    "//llvm/utils/gn/build:lldb_code",
+  ]
+  deps = [
+    "//lldb/source/Breakpoint",
+    "//lldb/source/Core",
+    "//lldb/source/Host",
+    "//lldb/source/Interpreter",
+    "//lldb/source/Target",
+    "//lldb/source/Plugins/Platform/POSIX",
+  ]
+  # Reaches into Plugins/Platform/POSIX.
+  include_dirs = [ "//lldb/source" ]
+  sources = [ "PlatformLinux.cpp" ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/Process/Linux/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/Process/Linux/BUILD.gn
new file mode 100644
index 0000000000000..c80449916f8da
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/Process/Linux/BUILD.gn
@@ -0,0 +1,29 @@
+static_library("Linux") {
+  output_name = "lldbPluginProcessLinux"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Host",
+    "//lldb/source/Symbol",
+    "//lldb/source/Target",
+    "//lldb/source/Utility",
+    "//lldb/source/Plugins/Process/POSIX",
+    "//lldb/source/Plugins/Process/Utility",
+    "//llvm/lib/Support",
+  ]
+  # Uses source-relative includes for own headers.
+  include_dirs = [ "//lldb/source" ]
+  sources = [
+    "IntelPTManager.cpp",
+    "NativeProcessLinux.cpp",
+    "NativeRegisterContextLinux.cpp",
+    "NativeRegisterContextLinux_arm.cpp",
+    "NativeRegisterContextLinux_arm64.cpp",
+    "NativeRegisterContextLinux_ppc64le.cpp",
+    "NativeRegisterContextLinux_s390x.cpp",
+    "NativeRegisterContextLinux_x86_64.cpp",
+    "NativeThreadLinux.cpp",
+    "SingleStepCheck.cpp",
+  ]
+}
+

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/Process/POSIX/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/Process/POSIX/BUILD.gn
new file mode 100644
index 0000000000000..2be26de4fae2c
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/Process/POSIX/BUILD.gn
@@ -0,0 +1,17 @@
+static_library("POSIX") {
+  output_name = "lldbPluginProcessPOSIX"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Utility",
+    "//lldb/source/Plugins/Process/Utility",
+    "//llvm/lib/Support",
+  ]
+  # Reaches into Plugins/Platform/Process/Utility.
+  include_dirs = [ "//lldb/source" ]
+  sources = [
+    "CrashReason.cpp",
+    "NativeProcessELF.cpp",
+    "ProcessMessage.cpp",
+    "ProcessPOSIXLog.cpp",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/tools/driver/BUILD.gn b/llvm/utils/gn/secondary/lldb/tools/driver/BUILD.gn
index 1b82637bfc04e..7d78145ce566f 100644
--- a/llvm/utils/gn/secondary/lldb/tools/driver/BUILD.gn
+++ b/llvm/utils/gn/secondary/lldb/tools/driver/BUILD.gn
@@ -7,7 +7,7 @@ tablegen("Options") {
   args = [ "-gen-opt-parser-defs" ]
 }
 
-if (host_os == "mac") {
+if (current_os == "mac") {
   write_cmake_config("write_info_plist") {
     input = "lldb-Info.plist.in"
     output = "$target_gen_dir/lldb-Info.plist"
@@ -25,12 +25,15 @@ executable("lldb") {
     "//llvm/lib/Support",
     "//llvm/utils/gn/build/libs/xar",
   ]
-  if (host_os == "mac") {
+  if (current_os == "mac") {
     deps += [ ":write_info_plist" ]
     plist = get_target_outputs(":write_info_plist")
     ldflags = [ "-Wl,-sectcreate,__TEXT,__info_plist," +
                 rebase_path(plist[0], root_out_dir) ]
   }
+  if (current_os == "linux") {
+    deps += [ "//lldb/tools/lldb-server" ]
+  }
 
   sources = [
     "Driver.cpp",

diff  --git a/llvm/utils/gn/secondary/lldb/tools/lldb-server/BUILD.gn b/llvm/utils/gn/secondary/lldb/tools/lldb-server/BUILD.gn
index 6ed291f4dd715..5129c71d97ad5 100644
--- a/llvm/utils/gn/secondary/lldb/tools/lldb-server/BUILD.gn
+++ b/llvm/utils/gn/secondary/lldb/tools/lldb-server/BUILD.gn
@@ -29,13 +29,13 @@ executable("lldb-server") {
     "//lldb/source/Plugins/Language/CPlusPlus",
   ]
 
-  #if (current_os == "android" || current_os == "linux") {
-    #deps += [ "//lldb/source/Plugins/Process/Linux" ]
+  if (current_os == "android" || current_os == "linux") {
+    deps += [ "//lldb/source/Plugins/Process/Linux" ]
     #} else if (current_os == "freebsd") {
     #deps += [ "//lldb/source/Plugins/Process/FreeBSD" ]
     #} else if (current_os == "netbsd") {
     #deps += [ "//lldb/source/Plugins/Process/NetBSD" ]
-  #}
+  }
 
   if (current_os == "mac") {
     deps += [ "//lldb/source/Plugins/ObjectFile/Mach-O" ]


        


More information about the llvm-commits mailing list