[llvm] cfe0284 - [gn build] Add build files for LLDB

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 7 12:25:16 PDT 2021


Author: Nico Weber
Date: 2021-09-07T15:25:04-04:00
New Revision: cfe02847496b856aa1628cae854997833043ec32

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

LOG: [gn build] Add build files for LLDB

This is enough to get the lit-based tests to pass on macOS.

Doesn't yet add build targets for:
- Any LLDB unit tests
- swig bindings
- various targets not needed by lit tests

LLDB has many dependency cycles, something GN doesn't allow. For
that reason, I've omitted some dependency edges. Hopefully we can
clean up the cycles one day.

LLDB has a public/private header distinction, but mostly ignores it.
Many libraries include private headers from other modules.

Since LLDB is the first target the LLVM/GN build that uses Objective-C++
code, add some machinery to the toolchain file to handle that.

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

Added: 
    llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn
    llvm/utils/gn/secondary/lldb/include/lldb/Host/libedit.gni
    llvm/utils/gn/secondary/lldb/source/API/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Breakpoint/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Commands/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Core/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/DataFormatters/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Expression/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Host/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Host/macosx/objcxx/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Initialization/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Interpreter/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/ABI/X86/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/Architecture/PPC64/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/Disassembler/LLVMC/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/DynamicLoader/Static/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/ExpressionParser/Clang/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/Instruction/ARM/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/JITLoader/GDB/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/Language/CPlusPlus/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/Language/ClangCommon/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/Language/ObjC/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/Language/ObjCPlusPlus/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/LanguageRuntime/CPlusPlus/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/LanguageRuntime/ObjC/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/ObjectContainer/BSD-Archive/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/ObjectContainer/Universal-Mach-O/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/ObjectFile/Breakpad/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/ObjectFile/ELF/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/ObjectFile/JIT/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/ObjectFile/Mach-O/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/ObjectFile/PDB/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/ObjectFile/PECOFF/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/ObjectFile/wasm/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/Platform/MacOSX/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/Platform/MacOSX/objcxx/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/Platform/POSIX/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/Platform/Windows/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/Process/Utility/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/Process/elf-core/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/Process/gdb-remote/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/Process/mach-core/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/Process/minidump/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/ScriptInterpreter/None/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/SymbolFile/Breakpad/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/SymbolFile/DWARF/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/SymbolFile/NativePDB/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/SymbolFile/PDB/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/SymbolFile/Symtab/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/SymbolVendor/ELF/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/SymbolVendor/MacOSX/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/SymbolVendor/wasm/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/TypeSystem/Clang/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/UnwindAssembly/InstEmulation/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Plugins/UnwindAssembly/x86/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Symbol/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Target/BUILD.gn
    llvm/utils/gn/secondary/lldb/source/Utility/BUILD.gn
    llvm/utils/gn/secondary/lldb/test/BUILD.gn
    llvm/utils/gn/secondary/lldb/test/lldb_lit_site_cfg_files.gni
    llvm/utils/gn/secondary/lldb/tools/argdumper/BUILD.gn
    llvm/utils/gn/secondary/lldb/tools/driver/BUILD.gn
    llvm/utils/gn/secondary/lldb/tools/lldb-server/BUILD.gn
    llvm/utils/gn/secondary/lldb/tools/lldb-test/BUILD.gn
    llvm/utils/gn/secondary/lldb/tools/lldb-vscode/BUILD.gn
    llvm/utils/gn/secondary/lldb/utils/TableGen/BUILD.gn
    llvm/utils/gn/secondary/lldb/utils/TableGen/lldb_tablegen.gni
    llvm/utils/gn/secondary/lldb/utils/lit-cpuid/BUILD.gn

Modified: 
    lldb/source/Symbol/CMakeLists.txt
    llvm/utils/gn/build/BUILD.gn
    llvm/utils/gn/build/toolchain/BUILD.gn
    llvm/utils/gn/secondary/BUILD.gn
    llvm/utils/gn/secondary/llvm/utils/llvm-lit/BUILD.gn

Removed: 
    


################################################################################
diff  --git a/lldb/source/Symbol/CMakeLists.txt b/lldb/source/Symbol/CMakeLists.txt
index c983ceb519c92..d40fe41c815a1 100644
--- a/lldb/source/Symbol/CMakeLists.txt
+++ b/lldb/source/Symbol/CMakeLists.txt
@@ -1,7 +1,9 @@
 set(LLVM_OPTIONAL_SOURCES LocateSymbolFileMacOSX.cpp)
 
 if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
-  set(PLATFORM_SOURCES LocateSymbolFileMacOSX.cpp)
+  set(PLATFORM_SOURCES
+    LocateSymbolFileMacOSX.cpp
+    )
 endif()
 
 add_lldb_library(lldbSymbol

diff  --git a/llvm/utils/gn/build/BUILD.gn b/llvm/utils/gn/build/BUILD.gn
index 31a5741e4524b..9ceed1d8ef856 100644
--- a/llvm/utils/gn/build/BUILD.gn
+++ b/llvm/utils/gn/build/BUILD.gn
@@ -348,12 +348,15 @@ config("compiler_defaults") {
       ]
     }
   }
+
+  cflags_objcc = cflags_cc
 }
 
 config("no_exceptions") {
   if (host_os != "win") {
     cflags_cc = [ "-fno-exceptions" ]
   }
+  cflags_objcc = cflags_cc
 }
 
 config("no_rtti") {
@@ -362,6 +365,7 @@ config("no_rtti") {
   } else {
     cflags_cc = [ "-fno-rtti" ]
   }
+  cflags_objcc = cflags_cc
 }
 
 # To make an archive that can be distributed, you need to remove this config and
@@ -416,6 +420,16 @@ config("crt_code") {
   }
 }
 
+config("lldb_code") {
+  if (host_os != "win") {
+    cflags = [ "-fno-strict-aliasing" ]
+  }
+  include_dirs = [
+    "//lldb/include",
+    "$root_gen_dir/lldb/include",
+  ]
+}
+
 config("warn_covered_switch_default") {
   if (is_clang) {
     cflags = [ "-Wcovered-switch-default" ]

diff  --git a/llvm/utils/gn/build/toolchain/BUILD.gn b/llvm/utils/gn/build/toolchain/BUILD.gn
index 077bc9db3e3be..35fbb2d1a6653 100644
--- a/llvm/utils/gn/build/toolchain/BUILD.gn
+++ b/llvm/utils/gn/build/toolchain/BUILD.gn
@@ -51,6 +51,14 @@ template("unix_toolchain") {
       outputs = [ "{{source_out_dir}}/{{label_name}}.{{source_name_part}}.o" ]
     }
 
+    tool("objcxx") {
+      depfile = "{{output}}.d"
+      command = "$cxx -MMD -MF $depfile -o {{output}} -c {{source}} {{defines}} {{include_dirs}} {{cflags}} {{cflags_objcc}}"
+      depsformat = "gcc"
+      description = "OBJCXX {{output}}"
+      outputs = [ "{{source_out_dir}}/{{label_name}}.{{source_name_part}}.o" ]
+    }
+
     tool("asm") {
       depfile = "{{output}}.d"
       command = "$cc -MMD -MF $depfile -o {{output}} -c {{source}} {{defines}} {{include_dirs}} {{asmflags}}"

diff  --git a/llvm/utils/gn/secondary/BUILD.gn b/llvm/utils/gn/secondary/BUILD.gn
index 16b4c986d7475..b60851946e168 100644
--- a/llvm/utils/gn/secondary/BUILD.gn
+++ b/llvm/utils/gn/secondary/BUILD.gn
@@ -20,6 +20,9 @@ group("default") {
       "//libcxxabi",
     ]
   }
+  if (current_os == "mac") {
+    deps += [ "//lldb/test" ]
+  }
   if (current_os == "linux" || current_os == "android") {
     deps += [ "//compiler-rt/test/hwasan" ]
   }

diff  --git a/llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn b/llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn
new file mode 100644
index 0000000000000..0875aa3cd31bb
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn
@@ -0,0 +1,58 @@
+import("//llvm/utils/gn/build/libs/xml/enable.gni")
+import("//llvm/utils/gn/build/write_cmake_config.gni")
+import("libedit.gni")
+
+# In lldb/cmake/modules/LLDBGenerateConfig.cmake,
+# brought in by lldb/cmake/modules/LLDBConfig.cmake,
+# brought in by lldb/CMakeLists.txt in the CMake build.
+write_cmake_config("Config") {
+  input = "Config.h.cmake"
+  output = "$target_gen_dir/Config.h"
+  values = [
+    # 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=",
+    "LLDB_ENABLE_LZMA=",
+    "LLDB_ENABLE_CURSES=",
+    "CURSES_HAVE_NCURSES_CURSES_H=",
+    "LLDB_ENABLE_LUA=",
+    "LLDB_ENABLE_PYTHON=",
+    "LLDB_EMBED_PYTHON_HOME=",
+
+    "LLDB_PYTHON_HOME=",
+
+    "LLVM_LIBDIR_SUFFIX=",
+
+    "HAVE_LIBCOMPRESSION=",
+  ]
+
+  if (lldb_enable_libedit) {
+    values += [ "LLDB_ENABLE_LIBEDIT=1" ]
+  } else {
+    values += [ "LLDB_ENABLE_LIBEDIT=" ]
+  }
+
+  if (llvm_enable_libxml2) {
+    values += [ "LLDB_ENABLE_LIBXML2=1" ]
+  } else {
+    values += [ "LLDB_ENABLE_LIBXML2=" ]
+  }
+
+  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",
+    ]
+  }
+}

diff  --git a/llvm/utils/gn/secondary/lldb/include/lldb/Host/libedit.gni b/llvm/utils/gn/secondary/lldb/include/lldb/Host/libedit.gni
new file mode 100644
index 0000000000000..778faa529c9b9
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/include/lldb/Host/libedit.gni
@@ -0,0 +1,9 @@
+declare_args() {
+  # Whether lldb links against libedit. Set to `true` or `false`, or to
+  # `"default"` to get the platform default.
+  lldb_enable_libedit = "default"
+}
+
+if (lldb_enable_libedit == "default") {
+  lldb_enable_libedit = current_os == "mac"
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/API/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/API/BUILD.gn
new file mode 100644
index 0000000000000..f3911f0e4fab6
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/API/BUILD.gn
@@ -0,0 +1,105 @@
+static_library("liblldb") {
+  # XXX if win -DEXPORT_LIBLLDB
+
+  # XXX LLDB_BUILD_FRAMEWORK
+  # XXX LLDB_ENABLE_PYTHON
+  # XXX LLDB_ENABLE_LUA
+
+  output_name = "liblldb"  # XXX lib prefix?
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/include/lldb/Host:Config",
+    "//lldb/source:lldbBase",
+    "//lldb/source/Breakpoint",
+    "//lldb/source/Core",
+    "//lldb/source/DataFormatters",
+    "//lldb/source/Expression",
+    "//lldb/source/Host",
+    "//lldb/source/Initialization",
+    "//lldb/source/Interpreter",
+    "//lldb/source/Plugins:LldbAllPlugins",
+    "//lldb/source/Symbol",
+    "//lldb/source/Target",
+    "//lldb/source/Utility",
+    "//lldb/tools/argdumper:lldb-argdumper",
+    "//llvm/lib/Support",
+  ]
+
+  # SBTarget.cpp includes Commands-internal header Commands/CommandObjectBreakpoint.h
+  include_dirs = [ ".." ]
+  sources = [
+    "SBAddress.cpp",
+    "SBAttachInfo.cpp",
+    "SBBlock.cpp",
+    "SBBreakpoint.cpp",
+    "SBBreakpointLocation.cpp",
+    "SBBreakpointName.cpp",
+    "SBBreakpointOptionCommon.cpp",
+    "SBBroadcaster.cpp",
+    "SBCommandInterpreter.cpp",
+    "SBCommandInterpreterRunOptions.cpp",
+    "SBCommandReturnObject.cpp",
+    "SBCommunication.cpp",
+    "SBCompileUnit.cpp",
+    "SBData.cpp",
+    "SBDebugger.cpp",
+    "SBDeclaration.cpp",
+    "SBEnvironment.cpp",
+    "SBError.cpp",
+    "SBEvent.cpp",
+    "SBExecutionContext.cpp",
+    "SBExpressionOptions.cpp",
+    "SBFile.cpp",
+    "SBFileSpec.cpp",
+    "SBFileSpecList.cpp",
+    "SBFrame.cpp",
+    "SBFunction.cpp",
+    "SBHostOS.cpp",
+    "SBInstruction.cpp",
+    "SBInstructionList.cpp",
+    "SBLanguageRuntime.cpp",
+    "SBLaunchInfo.cpp",
+    "SBLineEntry.cpp",
+    "SBListener.cpp",
+    "SBMemoryRegionInfo.cpp",
+    "SBMemoryRegionInfoList.cpp",
+    "SBModule.cpp",
+    "SBModuleSpec.cpp",
+    "SBPlatform.cpp",
+    "SBProcess.cpp",
+    "SBProcessInfo.cpp",
+    "SBQueue.cpp",
+    "SBQueueItem.cpp",
+    "SBReproducer.cpp",
+    "SBSection.cpp",
+    "SBSourceManager.cpp",
+    "SBStream.cpp",
+    "SBStringList.cpp",
+    "SBStructuredData.cpp",
+    "SBSymbol.cpp",
+    "SBSymbolContext.cpp",
+    "SBSymbolContextList.cpp",
+    "SBTarget.cpp",
+    "SBThread.cpp",
+    "SBThreadCollection.cpp",
+    "SBThreadPlan.cpp",
+    "SBTrace.cpp",
+    "SBType.cpp",
+    "SBTypeCategory.cpp",
+    "SBTypeEnumMember.cpp",
+    "SBTypeFilter.cpp",
+    "SBTypeFormat.cpp",
+    "SBTypeNameSpecifier.cpp",
+    "SBTypeSummary.cpp",
+    "SBTypeSynthetic.cpp",
+    "SBUnixSignals.cpp",
+    "SBValue.cpp",
+    "SBValueList.cpp",
+    "SBVariablesOptions.cpp",
+    "SBWatchpoint.cpp",
+    "SystemInitializerFull.cpp",
+  ]
+
+  # XXX liblldb.exports or liblldb-private.expoorts
+  # XXX dep on clang resource directory
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/BUILD.gn
new file mode 100644
index 0000000000000..48bb27982906b
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/BUILD.gn
@@ -0,0 +1,30 @@
+import("//llvm/utils/gn/build/write_vcsrevision.gni")
+
+config("write_vcsrevision_config") {
+  # To pick up the generated inc file.
+  include_dirs = [ target_gen_dir ]
+  visibility = [ ":write_vcsrevision" ]
+}
+
+write_vcsrevision("write_vcsversion") {
+  visibility = [ ":lldbBase" ]
+  header = "$target_gen_dir/VCSVersion.inc"
+  names = [ "LLDB" ]
+  public_configs = [ ":write_vcsrevision_config" ]
+}
+
+static_library("lldbBase") {
+  configs += [
+    "//llvm/utils/gn/build:lldb_code",
+
+    # To pick up clang/Basic/Version.h.
+    "//llvm/utils/gn/build:clang_code",
+  ]
+  sources = [ "lldb.cpp" ]
+  deps = [
+    ":write_vcsversion",
+    "//clang/lib/Basic",
+  ]
+
+  # XXX define LLDB_VERSION_STRING
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Breakpoint/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Breakpoint/BUILD.gn
new file mode 100644
index 0000000000000..b8a06582e9856
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Breakpoint/BUILD.gn
@@ -0,0 +1,40 @@
+static_library("Breakpoint") {
+  output_name = "lldbBreakpoint"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/include/lldb/Host:Config",
+    "//lldb/source/Core",
+    "//lldb/source/Expression",
+    "//lldb/source/Interpreter",
+    "//lldb/source/Symbol",
+    "//lldb/source/Target",
+    "//lldb/source/Utility",
+    "//llvm/lib/Support",
+  ]
+  sources = [
+    "Breakpoint.cpp",
+    "BreakpointID.cpp",
+    "BreakpointIDList.cpp",
+    "BreakpointList.cpp",
+    "BreakpointLocation.cpp",
+    "BreakpointLocationCollection.cpp",
+    "BreakpointLocationList.cpp",
+    "BreakpointName.cpp",
+    "BreakpointOptions.cpp",
+    "BreakpointPrecondition.cpp",
+    "BreakpointResolver.cpp",
+    "BreakpointResolverAddress.cpp",
+    "BreakpointResolverFileLine.cpp",
+    "BreakpointResolverFileRegex.cpp",
+    "BreakpointResolverName.cpp",
+    "BreakpointResolverScripted.cpp",
+    "BreakpointSite.cpp",
+    "BreakpointSiteList.cpp",
+    "Stoppoint.cpp",
+    "StoppointCallbackContext.cpp",
+    "StoppointSite.cpp",
+    "Watchpoint.cpp",
+    "WatchpointList.cpp",
+    "WatchpointOptions.cpp",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Commands/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Commands/BUILD.gn
new file mode 100644
index 0000000000000..72c63128460e6
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Commands/BUILD.gn
@@ -0,0 +1,66 @@
+import("//lldb/utils/TableGen/lldb_tablegen.gni")
+
+lldb_tablegen("CommandOptions") {
+  args = [ "-gen-lldb-option-defs" ]
+  td_file = "Options.td"  # FIXME: rename?
+}
+
+static_library("Commands") {
+  output_name = "lldbCommands"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    ":CommandOptions",
+    "//lldb/source:lldbBase",
+    "//llvm/lib/Support",
+
+    #"//lldb/source/Breakpoint", # FIXME: many-hop dependency cycle.
+    "//lldb/source/Core",
+    "//lldb/source/DataFormatters",
+
+    #"//lldb/source/Expression", # FIXME: 2-hop dependency cycle.
+    "//lldb/source/Host",
+
+    #"//lldb/source/Interpreter", # FIXME: Dependency cycle.
+    #"//lldb/source/Symbol", # FIXME: many-hop dependency cycle.
+    #"//lldb/source/Target", # FIXME: 2-hop dependency cycle.
+    "//lldb/source/Utility",
+  ]
+  sources = [
+    "CommandCompletions.cpp",
+    "CommandObjectApropos.cpp",
+    "CommandObjectBreakpoint.cpp",
+    "CommandObjectBreakpointCommand.cpp",
+    "CommandObjectCommands.cpp",
+    "CommandObjectDisassemble.cpp",
+    "CommandObjectExpression.cpp",
+    "CommandObjectFrame.cpp",
+    "CommandObjectGUI.cpp",
+    "CommandObjectHelp.cpp",
+    "CommandObjectLanguage.cpp",
+    "CommandObjectLog.cpp",
+    "CommandObjectMemory.cpp",
+    "CommandObjectMemoryTag.cpp",
+    "CommandObjectMultiword.cpp",
+    "CommandObjectPlatform.cpp",
+    "CommandObjectPlugin.cpp",
+    "CommandObjectProcess.cpp",
+    "CommandObjectQuit.cpp",
+    "CommandObjectRegexCommand.cpp",
+    "CommandObjectRegister.cpp",
+    "CommandObjectReproducer.cpp",
+    "CommandObjectScript.cpp",
+    "CommandObjectSession.cpp",
+    "CommandObjectSettings.cpp",
+    "CommandObjectSource.cpp",
+    "CommandObjectStats.cpp",
+    "CommandObjectTarget.cpp",
+    "CommandObjectThread.cpp",
+    "CommandObjectThreadUtil.cpp",
+    "CommandObjectTrace.cpp",
+    "CommandObjectType.cpp",
+    "CommandObjectVersion.cpp",
+    "CommandObjectWatchpoint.cpp",
+    "CommandObjectWatchpointCommand.cpp",
+    "CommandOptionsProcessLaunch.cpp",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Core/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Core/BUILD.gn
new file mode 100644
index 0000000000000..3a371cfa06ad1
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Core/BUILD.gn
@@ -0,0 +1,94 @@
+import("//lldb/utils/TableGen/lldb_tablegen.gni")
+
+lldb_tablegen("CoreProperties") {
+  args = [ "-gen-lldb-property-defs" ]
+}
+
+lldb_tablegen("CorePropertiesEnum") {
+  args = [ "-gen-lldb-property-enum-defs" ]
+  td_file = "CoreProperties.td"
+}
+
+static_library("Core") {
+  output_name = "lldbCore"
+  configs += [
+    "//llvm/utils/gn/build:clang_code",
+    "//llvm/utils/gn/build:lldb_code",
+  ]
+  deps = [
+    ":CoreProperties",
+    ":CorePropertiesEnum",
+    "//clang/lib/Driver",
+
+    #"//lldb/source/Breakpoint", # Dependency cycle.
+    #"//lldb/source/DataFormatters", # Dependency cycle.
+    #"//lldb/source/Expression", # Dependency cycle.
+    "//lldb/source/Host",
+
+    #"//lldb/source/Interpreter", # Dependency cycle.
+    #"//lldb/source/Symbol", # Dependency cycle.
+    #"//lldb/source/Target", # Dependency cycle.
+    "//lldb/source/Utility",
+    "//llvm/lib/Demangle",
+    "//llvm/lib/Support",
+
+    #"//lldb/source/Plugins/Language/CPlusPlus", # 3-hop dependency cycle.
+    #"//lldb/source/Plugins/Language/ObjC",  # Many-hop dependency cycle.
+
+    # FIXME:
+    #  ${LLDB_CURSES_LIBS}
+  ]
+
+  # FIXME: Link curses, libedit if needed.
+  include_dirs = [ ".." ]
+  sources = [
+    "Address.cpp",
+    "AddressRange.cpp",
+    "AddressResolver.cpp",
+    "AddressResolverFileLine.cpp",
+    "Communication.cpp",
+    "Debugger.cpp",
+    "Declaration.cpp",
+    "Disassembler.cpp",
+    "DumpDataExtractor.cpp",
+    "DumpRegisterValue.cpp",
+    "DynamicLoader.cpp",
+    "EmulateInstruction.cpp",
+    "FileLineResolver.cpp",
+    "FileSpecList.cpp",
+    "FormatEntity.cpp",
+    "Highlighter.cpp",
+    "IOHandler.cpp",
+    "IOHandlerCursesGUI.cpp",
+    "Mangled.cpp",
+    "Module.cpp",
+    "ModuleChild.cpp",
+    "ModuleList.cpp",
+    "Opcode.cpp",
+    "PluginManager.cpp",
+    "Progress.cpp",
+    "RichManglingContext.cpp",
+    "SearchFilter.cpp",
+    "Section.cpp",
+    "SourceLocationSpec.cpp",
+    "SourceManager.cpp",
+    "StreamAsynchronousIO.cpp",
+    "StreamFile.cpp",
+    "UserSettingsController.cpp",
+    "Value.cpp",
+    "ValueObject.cpp",
+    "ValueObjectCast.cpp",
+    "ValueObjectChild.cpp",
+    "ValueObjectConstResult.cpp",
+    "ValueObjectConstResultCast.cpp",
+    "ValueObjectConstResultChild.cpp",
+    "ValueObjectConstResultImpl.cpp",
+    "ValueObjectDynamicValue.cpp",
+    "ValueObjectList.cpp",
+    "ValueObjectMemory.cpp",
+    "ValueObjectRegister.cpp",
+    "ValueObjectSyntheticFilter.cpp",
+    "ValueObjectUpdater.cpp",
+    "ValueObjectVariable.cpp",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/DataFormatters/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/DataFormatters/BUILD.gn
new file mode 100644
index 0000000000000..5dcbc01053fbe
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/DataFormatters/BUILD.gn
@@ -0,0 +1,31 @@
+static_library("DataFormatters") {
+  output_name = "lldbDataFormatters"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Core",
+
+    #"//lldb/source/Interpreter", # FIXME: Dependency cycle.
+    #"//lldb/source/Symbol", # FIXME: 3-hop Dependency cycle (DataFormatters->Symbol->Expression->Interpreter->DataFormatters)
+    #"//lldb/source/Target",  # FIXME: 3-hop Dependency cycle (DataFormatters->Target->Expression->Interpreter->DataFormatters)
+    "//lldb/source/Utility",
+    "//llvm/lib/Support",
+  ]
+  sources = [
+    "CXXFunctionPointer.cpp",
+    "DataVisualization.cpp",
+    "DumpValueObjectOptions.cpp",
+    "FormatCache.cpp",
+    "FormatClasses.cpp",
+    "FormatManager.cpp",
+    "FormattersHelpers.cpp",
+    "LanguageCategory.cpp",
+    "StringPrinter.cpp",
+    "TypeCategory.cpp",
+    "TypeCategoryMap.cpp",
+    "TypeFormat.cpp",
+    "TypeSummary.cpp",
+    "TypeSynthetic.cpp",
+    "ValueObjectPrinter.cpp",
+    "VectorType.cpp",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Expression/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Expression/BUILD.gn
new file mode 100644
index 0000000000000..f58874f794eec
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Expression/BUILD.gn
@@ -0,0 +1,39 @@
+static_library("Expression") {
+  output_name = "lldbExpression"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Host",
+    "//lldb/source/Interpreter",
+    "//lldb/source/Plugins/ObjectFile/JIT",
+
+    #"//lldb/source/Symbol", # FIXME: Dependency cycle.
+    #"//lldb/source/Target", # FIXME: Dependency cycle.
+    "//lldb/source/Utility",
+    "//llvm/lib/ExecutionEngine",
+    "//llvm/lib/IR",
+    "//llvm/lib/Support",
+
+    #"//lldb/source/Plugins/Language/CPlusPlus", # 4-hop dependency cycle.
+
+    # FIXME:
+    # DEPENDS
+    # intrinsics_gen
+  ]
+  include_dirs = [ ".." ]
+  sources = [
+    "DWARFExpression.cpp",
+    "DiagnosticManager.cpp",
+    "Expression.cpp",
+    "ExpressionVariable.cpp",
+    "FunctionCaller.cpp",
+    "IRExecutionUnit.cpp",
+    "IRInterpreter.cpp",
+    "IRMemoryMap.cpp",
+    "LLVMUserExpression.cpp",
+    "Materializer.cpp",
+    "REPL.cpp",
+    "UserExpression.cpp",
+    "UtilityFunction.cpp",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Host/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Host/BUILD.gn
new file mode 100644
index 0000000000000..a747d3c8d8562
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Host/BUILD.gn
@@ -0,0 +1,155 @@
+import("//lldb/include/lldb/Host/libedit.gni")
+
+static_library("Host") {
+  output_name = "lldbHost"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/include/lldb/Host:Config",
+    "//lldb/source/Utility",
+    "//llvm/lib/Object",
+    "//llvm/lib/Support",
+    "//llvm/utils/gn/build/libs/xml",
+
+    # FIXME:
+    # LINK_LIBS
+    #   ${EXTRA_LIBS}
+    #   ${LLDBObjCLibs}
+  ]
+  sources = [
+    "common/File.cpp",
+    "common/FileAction.cpp",
+    "common/FileCache.cpp",
+    "common/FileSystem.cpp",
+    "common/GetOptInc.cpp",
+    "common/Host.cpp",
+    "common/HostInfoBase.cpp",
+    "common/HostNativeThreadBase.cpp",
+    "common/HostProcess.cpp",
+    "common/HostThread.cpp",
+    "common/LZMA.cpp",
+    "common/LockFileBase.cpp",
+    "common/MainLoop.cpp",
+    "common/MonitoringProcessLauncher.cpp",
+    "common/NativeProcessProtocol.cpp",
+    "common/NativeRegisterContext.cpp",
+    "common/NativeThreadProtocol.cpp",
+    "common/NativeWatchpointList.cpp",
+    "common/OptionParser.cpp",
+    "common/PipeBase.cpp",
+    "common/ProcessLaunchInfo.cpp",
+    "common/ProcessRunLock.cpp",
+    "common/PseudoTerminal.cpp",
+    "common/Socket.cpp",
+    "common/SocketAddress.cpp",
+    "common/StringConvert.cpp",
+    "common/TCPSocket.cpp",
+    "common/Terminal.cpp",
+    "common/ThreadLauncher.cpp",
+    "common/UDPSocket.cpp",
+    "common/XML.cpp",
+  ]
+
+  if (lldb_enable_libedit) {
+    libs = [ "edit" ]
+    sources += [ "common/Editline.cpp" ]
+    if (host_os == "mac") {
+      libs += [ "curses" ]  # For USE_SETUPTERM_WORKAROUND :/
+    }
+  }
+
+  sources += [ "posix/ConnectionFileDescriptorPosix.cpp" ]
+
+  if (current_os == "win") {
+    sources += [
+      "windows/ConnectionGenericFileWindows.cpp",
+      "windows/FileSystem.cpp",
+      "windows/Host.cpp",
+      "windows/HostInfoWindows.cpp",
+      "windows/HostProcessWindows.cpp",
+      "windows/HostThreadWindows.cpp",
+      "windows/LockFileWindows.cpp",
+      "windows/PipeWindows.cpp",
+      "windows/ProcessLauncherWindows.cpp",
+      "windows/ProcessRunLock.cpp",
+      "windows/Windows.cpp",
+    ]
+  } else {
+    sources += [
+      "posix/DomainSocket.cpp",
+      "posix/FileSystemPosix.cpp",
+      "posix/HostInfoPosix.cpp",
+      "posix/HostProcessPosix.cpp",
+      "posix/HostThreadPosix.cpp",
+      "posix/LockFilePosix.cpp",
+      "posix/PipePosix.cpp",
+      "posix/ProcessLauncherPosixFork.cpp",
+    ]
+  }
+
+  if (current_os == "mac") {
+    sources += [
+      "macosx/cfcpp/CFCBundle.cpp",
+      "macosx/cfcpp/CFCData.cpp",
+      "macosx/cfcpp/CFCMutableArray.cpp",
+      "macosx/cfcpp/CFCMutableDictionary.cpp",
+      "macosx/cfcpp/CFCMutableSet.cpp",
+      "macosx/cfcpp/CFCString.cpp",
+    ]
+    deps += [ "macosx/objcxx" ]
+
+    # FIXME: Maybe define NO_XPC_SERVICES
+  }
+
+  if (current_os == "linux" || current_os == "android") {
+    sources += [
+      "linux/AbstractSocket.cpp",
+      "linux/Host.cpp",
+      "linux/HostInfoLinux.cpp",
+      "linux/LibcGlue.cpp",
+      "linux/Support.cpp",
+    ]
+  }
+  if (current_os == "android") {
+    sources += [
+      "android/HostInfoAndroid.cpp",
+      "android/LibcGlue.cpp",
+    ]
+  }
+
+  if (current_os == "freebsd") {
+    sources += [
+      "freebsd/Host.cpp",
+      "freebsd/HostInfoFreeBSD.cpp",
+    ]
+  }
+  if (current_os == "netbsd") {
+    sources += [
+      "netbsd/HostInfoNetBSD.cpp",
+      "netbsd/HostNetBSD.cpp",
+    ]
+  }
+  if (current_os == "openbsd") {
+    sources += [
+      "openbsd/Host.cpp",
+      "openbsd/HostInfoOpenBSD.cpp",
+    ]
+  }
+
+  # FIXME:
+  # set(EXTRA_LIBS)
+  # if (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
+  #   list(APPEND EXTRA_LIBS kvm)
+  # endif()
+  # if (HAVE_LIBDL)
+  #   list(APPEND EXTRA_LIBS ${CMAKE_DL_LIBS})
+  # endif()
+  # if (LLDB_ENABLE_LIBEDIT)
+  #   list(APPEND EXTRA_LIBS ${LibEdit_LIBRARIES})
+  # endif()
+  # if (LLDB_ENABLE_LZMA)
+  #   list(APPEND EXTRA_LIBS ${LIBLZMA_LIBRARIES})
+  # endif()
+  # if (WIN32)
+  #   list(APPEND LLDB_SYSTEM_LIBS psapi)
+  # endif()
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Host/macosx/objcxx/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Host/macosx/objcxx/BUILD.gn
new file mode 100644
index 0000000000000..49669109c3b21
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Host/macosx/objcxx/BUILD.gn
@@ -0,0 +1,20 @@
+static_library("objcxx") {
+  output_name = "lldbHostMacOSXObjCXX"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Utility",
+    "//llvm/lib/Support",
+  ]
+  include_dirs = [ "//lldb/source" ]  # Includes internal headers from Utility.
+  cflags_objcc = [ "-fno-objc-exceptions" ]
+  sources = [
+    "Host.mm",
+    "HostInfoMacOSX.mm",
+    "HostThreadMacOSX.mm",
+  ]
+  frameworks = [
+    "Foundation.framework",
+    "CoreServices.framework",
+    "Security.framework",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Initialization/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Initialization/BUILD.gn
new file mode 100644
index 0000000000000..2f1de05abc84d
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Initialization/BUILD.gn
@@ -0,0 +1,22 @@
+static_library("Initialization") {
+  output_name = "lldbInitialization"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Host",
+    "//lldb/source/Plugins/Process/gdb-remote",
+
+    # XXX:
+    # lldbPluginProcessPOSIX on linux/android
+    # lldbPluginProcessWindowsCommon on win
+    "//llvm/lib/Support",
+  ]
+
+  # SystemInitializerCommon.cpp includes headers from Plugins/Process/....
+  include_dirs = [ ".." ]
+  sources = [
+    "SystemInitializer.cpp",
+    "SystemInitializerCommon.cpp",
+    "SystemLifetimeManager.cpp",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Interpreter/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Interpreter/BUILD.gn
new file mode 100644
index 0000000000000..ffe6d0ca5a1bf
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Interpreter/BUILD.gn
@@ -0,0 +1,76 @@
+import("//lldb/utils/TableGen/lldb_tablegen.gni")
+
+lldb_tablegen("InterpreterProperties") {
+  args = [ "-gen-lldb-property-defs" ]
+}
+
+lldb_tablegen("InterpreterPropertiesEnum") {
+  args = [ "-gen-lldb-property-enum-defs" ]
+  td_file = "InterpreterProperties.td"
+}
+
+static_library("Interpreter") {
+  output_name = "lldbInterpreter"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    ":InterpreterProperties",
+    ":InterpreterPropertiesEnum",
+    "//lldb/source/Commands",
+    "//lldb/source/Core",
+    "//lldb/source/DataFormatters",
+    "//lldb/source/Host",
+
+    #"//lldb/source/Target", # FIXME: 2-hop dependency cyle (Interpreter->Target->Expression->Interpreter)
+    "//lldb/source/Utility",
+    "//llvm/lib/Support",
+  ]
+
+  # Reaches into source/Commands implementation details.
+  include_dirs = [ ".." ]
+  sources = [
+    "CommandAlias.cpp",
+    "CommandHistory.cpp",
+    "CommandInterpreter.cpp",
+    "CommandObject.cpp",
+    "CommandOptionValidators.cpp",
+    "CommandReturnObject.cpp",
+    "OptionArgParser.cpp",
+    "OptionGroupArchitecture.cpp",
+    "OptionGroupBoolean.cpp",
+    "OptionGroupFile.cpp",
+    "OptionGroupFormat.cpp",
+    "OptionGroupOutputFile.cpp",
+    "OptionGroupPlatform.cpp",
+    "OptionGroupPythonClassWithDict.cpp",
+    "OptionGroupString.cpp",
+    "OptionGroupUInt64.cpp",
+    "OptionGroupUUID.cpp",
+    "OptionGroupValueObjectDisplay.cpp",
+    "OptionGroupVariable.cpp",
+    "OptionGroupWatchpoint.cpp",
+    "OptionValue.cpp",
+    "OptionValueArch.cpp",
+    "OptionValueArgs.cpp",
+    "OptionValueArray.cpp",
+    "OptionValueBoolean.cpp",
+    "OptionValueChar.cpp",
+    "OptionValueDictionary.cpp",
+    "OptionValueEnumeration.cpp",
+    "OptionValueFileColonLine.cpp",
+    "OptionValueFileSpec.cpp",
+    "OptionValueFileSpecList.cpp",
+    "OptionValueFormat.cpp",
+    "OptionValueFormatEntity.cpp",
+    "OptionValueLanguage.cpp",
+    "OptionValuePathMappings.cpp",
+    "OptionValueProperties.cpp",
+    "OptionValueRegex.cpp",
+    "OptionValueSInt64.cpp",
+    "OptionValueString.cpp",
+    "OptionValueUInt64.cpp",
+    "OptionValueUUID.cpp",
+    "Options.cpp",
+    "Property.cpp",
+    "ScriptInterpreter.cpp",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/ABI/X86/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/ABI/X86/BUILD.gn
new file mode 100644
index 0000000000000..0546481e6dca5
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/ABI/X86/BUILD.gn
@@ -0,0 +1,20 @@
+static_library("X86") {
+  output_name = "lldbPluginABIX86"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Symbol",
+    "//lldb/source/Target",
+    "//llvm/lib/Support",
+  ]
+
+  # Uses source-relative paths for own includes.
+  include_dirs = [ "//lldb/source" ]
+  sources = [
+    "ABIMacOSX_i386.cpp",
+    "ABISysV_i386.cpp",
+    "ABISysV_x86_64.cpp",
+    "ABIWindows_x86_64.cpp",
+    "ABIX86.cpp",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/Architecture/PPC64/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/Architecture/PPC64/BUILD.gn
new file mode 100644
index 0000000000000..e0efd79e9e02e
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/Architecture/PPC64/BUILD.gn
@@ -0,0 +1,15 @@
+static_library("PPC64") {
+  output_name = "lldbPluginArchitecturePPC64"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Plugins/Process/Utility",
+    "//lldb/source/Target",
+    "//lldb/source/Utility",
+    "//llvm/lib/Support",
+  ]
+
+  # Uses source-relative paths for own includes.
+  include_dirs = [ "//lldb/source" ]
+  sources = [ "ArchitecturePPC64.cpp" ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/BUILD.gn
new file mode 100644
index 0000000000000..3d72011937488
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/BUILD.gn
@@ -0,0 +1,230 @@
+import("//llvm/lib/Target/targets.gni")
+import("//llvm/utils/gn/build/write_cmake_config.gni")
+
+# In the CMake build, each plugin calls `add_lldb_library(name PLUGIN ...)`,
+# which implicitly adds the plugin name to the LLDB_PLUGINS list.
+# A few places then query that list and add dependencies on it.
+# lldb/source/Plugins/CMakeList.txt then does string munging on the list of
+# plugin names to generate Plugins.def.
+# In the GN build, we instead have an explicit list of all plugins here.
+# Every entry in this list is a (GN target, LLDB_PLUGIN Plugins.def name) pair.
+lldb_plugins = []
+if (llvm_build_X86) {
+  lldb_plugins += [ [
+        "//lldb/source/Plugins/ABI/X86",
+        "ABIX86",
+      ] ]
+}
+lldb_plugins += [
+  [
+    "//lldb/source/Plugins/Architecture/PPC64",
+    "ArchitecturePPC64",
+  ],
+  [
+    "//lldb/source/Plugins/Disassembler/LLVMC",
+    "DisassemblerLLVMC",
+  ],
+  [
+    "//lldb/source/Plugins/DynamicLoader/Darwin-Kernel",
+    "DynamicLoaderDarwinKernel",
+  ],
+  [
+    "//lldb/source/Plugins/DynamicLoader/MacOSX-DYLD",
+    "DynamicLoaderMacOSXDYLD",
+  ],
+  [
+    "//lldb/source/Plugins/DynamicLoader/POSIX-DYLD",
+    "DynamicLoaderPosixDYLD",
+  ],
+  [
+    "//lldb/source/Plugins/DynamicLoader/Static",
+    "DynamicLoaderStatic",
+  ],
+  [
+    "//lldb/source/Plugins/Instruction/ARM",
+    "InstructionARM",
+  ],
+  [
+    "//lldb/source/Plugins/JITLoader/GDB",
+    "JITLoaderGDB",
+  ],
+  [
+    "//lldb/source/Plugins/Language/CPlusPlus",
+    "CPlusPlusLanguage",
+  ],
+  [
+    "//lldb/source/Plugins/Language/ObjC",
+    "ObjCLanguage",
+  ],
+  [
+    "//lldb/source/Plugins/Language/ObjCPlusPlus",
+    "ObjCPlusPlusLanguage",
+  ],
+  [
+    "//lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI",
+    "CXXItaniumABI",
+  ],
+  [
+    "//lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime",
+    "AppleObjCRuntime",
+  ],
+  [
+    "//lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime",
+    "RenderScriptRuntime",
+  ],
+  [
+    "//lldb/source/Plugins/ObjectContainer/BSD-Archive",
+    "ObjectContainerBSDArchive",
+  ],
+  [
+    "//lldb/source/Plugins/ObjectContainer/Universal-Mach-O",
+    "ObjectContainerMachOArchive",
+  ],
+  [
+    "//lldb/source/Plugins/ObjectFile/Breakpad",
+    "ObjectFileBreakpad",
+  ],
+  [
+    "//lldb/source/Plugins/ObjectFile/ELF",
+    "ObjectFileELF",
+  ],
+  [
+    "//lldb/source/Plugins/ObjectFile/JIT",
+    "ObjectFileJIT",
+  ],
+  [
+    "//lldb/source/Plugins/ObjectFile/Mach-O",
+    "ObjectFileMachO",
+  ],
+  [
+    "//lldb/source/Plugins/ObjectFile/PDB",
+    "ObjectFilePDB",
+  ],
+  [
+    "//lldb/source/Plugins/ObjectFile/PECOFF",
+    "ObjectFilePECOFF",
+  ],
+  [
+    "//lldb/source/Plugins/ObjectFile/wasm",
+    "ObjectFileWasm",
+  ],
+  [
+    "//lldb/source/Plugins/Platform/MacOSX",
+    "PlatformMacOSX",
+  ],
+  [
+    "//lldb/source/Plugins/Platform/Windows",
+    "PlatformWindows",
+  ],
+  [
+    "//lldb/source/Plugins/Process/elf-core",
+    "ProcessElfCore",
+  ],
+  [
+    "//lldb/source/Plugins/Process/gdb-remote",
+    "",  # Uses LLDB_PROCESS_GDB_PLUGIN instead.
+  ],
+  [
+    "//lldb/source/Plugins/Process/mach-core",
+    "ProcessMachCore",
+  ],
+  [
+    "//lldb/source/Plugins/Process/minidump",
+    "ProcessMinidump",
+  ],
+  [
+    "//lldb/source/Plugins/ScriptInterpreter/None",
+    "",  # Uses LLDB_SCRIPT_PLUGIN instead.
+  ],
+  [
+    "//lldb/source/Plugins/SymbolFile/Breakpad",
+    "SymbolFileBreakpad",
+  ],
+  [
+    "//lldb/source/Plugins/SymbolFile/DWARF",
+    "SymbolFileDWARF",
+  ],
+  [
+    "//lldb/source/Plugins/SymbolFile/PDB",
+    "SymbolFilePDB",
+  ],
+  [
+    "//lldb/source/Plugins/SymbolFile/Symtab",
+    "SymbolFileSymtab",
+  ],
+]
+if (current_os == "mac") {
+  lldb_plugins += [ [
+        "//lldb/source/Plugins/SymbolVendor/MacOSX",
+        "SymbolVendorMacOSX",
+      ] ]
+}
+lldb_plugins += [
+  [
+    "//lldb/source/Plugins/SymbolVendor/ELF",
+    "SymbolVendorELF",
+  ],
+
+  [
+    "//lldb/source/Plugins/SymbolVendor/wasm",
+    "SymbolVendorWasm",
+  ],
+
+  [
+    "//lldb/source/Plugins/TypeSystem/Clang",
+    "TypeSystemClang",
+  ],
+
+  [
+    "//lldb/source/Plugins/UnwindAssembly/InstEmulation",
+    "UnwindAssemblyInstEmulation",
+  ],
+  [
+    "//lldb/source/Plugins/UnwindAssembly/x86",
+    "UnwindAssemblyX86",
+  ],
+]
+
+write_cmake_config("Plugins.def") {
+  input = "Plugins.def.in"
+  output = "$target_gen_dir/Plugins.def"
+
+  enum_plugins = ""
+  foreach(plugin, lldb_plugins) {
+    plugin_id = plugin[1]
+    if (plugin_id != "") {
+      # \n is a literal '\' followed by a literal 'n', not a newline character.
+      # write_cmake_config.py replaces it with a real newline.
+      enum_plugins += "LLDB_PLUGIN(" + plugin_id + ")\n"
+    }
+  }
+
+  deps = [ "//lldb/source/Plugins/ScriptInterpreter/None" ]
+  enum_plugins += "LLDB_SCRIPT_PLUGIN(ScriptInterpreterNone)"
+
+  values = [ "LLDB_ENUM_PLUGINS=" + enum_plugins ]
+
+  # These are in separate variables to make sure ProcessWindowsCommon is
+  # initalized after all plugins, but before ProcessGDBRemote.
+  if (current_os == "win") {
+    values += [ "LLDB_PROCESS_WINDOWS_PLUGIN=LLDB_PLUGIN(XXX)" ]
+  } else {
+    values += [ "LLDB_PROCESS_WINDOWS_PLUGIN=" ]
+  }
+  values += [ "LLDB_PROCESS_GDB_PLUGIN=LLDB_PLUGIN(ProcessGDBRemote)" ]
+}
+
+config("AllLldbPlugins_config") {
+  visibility = [ ":AllLldbPlugins" ]
+
+  # To pick up Plugins.def.
+  include_dirs = [ "$root_gen_dir/lldb/source" ]
+}
+
+group("LldbAllPlugins") {
+  deps = [ ":Plugins.def" ]
+  foreach(plugin, lldb_plugins) {
+    deps += [ plugin[0] ]
+  }
+  public_configs = [ ":AllLldbPlugins_config" ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/Disassembler/LLVMC/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/Disassembler/LLVMC/BUILD.gn
new file mode 100644
index 0000000000000..5ba2568ade309
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/Disassembler/LLVMC/BUILD.gn
@@ -0,0 +1,15 @@
+static_library("LLVMC") {
+  output_name = "lldbPluginDisassemblerLLVMC"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Symbol",
+    "//lldb/source/Target",
+    "//llvm/lib/ExecutionEngine/RuntimeDyld",
+    "//llvm/lib/MC",
+    "//llvm/lib/MC/MCDisassembler",
+    "//llvm/lib/Support",
+    "//llvm/lib/Target:TargetsToBuild",
+  ]
+  sources = [ "DisassemblerLLVMC.cpp" ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/BUILD.gn
new file mode 100644
index 0000000000000..76fd9127882c1
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/BUILD.gn
@@ -0,0 +1,32 @@
+import("//lldb/utils/TableGen/lldb_tablegen.gni")
+
+lldb_tablegen("DynamicLoaderDarwinKernelProperties") {
+  args = [ "-gen-lldb-property-defs" ]
+}
+
+lldb_tablegen("DynamicLoaderDarwinKernelPropertiesEnum") {
+  args = [ "-gen-lldb-property-enum-defs" ]
+  td_file = "DynamicLoaderDarwinKernelProperties.td"
+}
+
+static_library("Darwin-Kernel") {
+  output_name = "lldbPluginDynamicLoaderDarwinKernel"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    ":DynamicLoaderDarwinKernelProperties",
+    ":DynamicLoaderDarwinKernelPropertiesEnum",
+    "//lldb/source/Breakpoint",
+    "//lldb/source/Core",
+    "//lldb/source/Host",
+    "//lldb/source/Interpreter",
+    "//lldb/source/Plugins/Platform/MacOSX",
+    "//lldb/source/Symbol",
+    "//lldb/source/Target",
+    "//lldb/source/Utility",
+    "//llvm/lib/Support",
+  ]
+
+  # Reaches into Plugins/Platform/MacOSX.
+  include_dirs = [ "//lldb/source" ]
+  sources = [ "DynamicLoaderDarwinKernel.cpp" ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/BUILD.gn
new file mode 100644
index 0000000000000..f18a6d6930bd9
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/BUILD.gn
@@ -0,0 +1,26 @@
+static_library("MacOSX-DYLD") {
+  output_name = "lldbPluginDynamicLoaderMacOSXDYLD"
+  configs += [
+    "//llvm/utils/gn/build:clang_code",
+    "//llvm/utils/gn/build:lldb_code",
+  ]
+  deps = [
+    "//lldb/source/Breakpoint",
+    "//lldb/source/Core",
+    "//lldb/source/Expression",
+    "//lldb/source/Host",
+    "//lldb/source/Plugins/TypeSystem/Clang",
+    "//lldb/source/Symbol",
+    "//lldb/source/Target",
+    "//lldb/source/Utility",
+    "//llvm/lib/Support",
+  ]
+
+  # Reaches into Plugins/LanguageRuntime/ObjC.
+  include_dirs = [ "//lldb/source" ]
+  sources = [
+    "DynamicLoaderDarwin.cpp",
+    "DynamicLoaderMacOS.cpp",
+    "DynamicLoaderMacOSXDYLD.cpp",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/BUILD.gn
new file mode 100644
index 0000000000000..c5d61a11152b2
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/BUILD.gn
@@ -0,0 +1,25 @@
+static_library("POSIX-DYLD") {
+  output_name = "lldbPluginDynamicLoaderPosixDYLD"
+  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/Plugins/Process/elf-core", # Dependency cycle.
+    "//lldb/source/Plugins/Process/Utility",
+    "//lldb/source/Symbol",
+    "//lldb/source/Target",
+    "//llvm/lib/Support",
+  ]
+
+  # Reaches into Plugins/Process/Utility.
+  include_dirs = [ "//lldb/source" ]
+  sources = [
+    "DYLDRendezvous.cpp",
+    "DynamicLoaderPOSIXDYLD.cpp",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/DynamicLoader/Static/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/DynamicLoader/Static/BUILD.gn
new file mode 100644
index 0000000000000..912d67c2fcc36
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/DynamicLoader/Static/BUILD.gn
@@ -0,0 +1,12 @@
+static_library("Static") {
+  output_name = "lldbPluginDynamicLoaderStatic"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Host",
+    "//lldb/source/Symbol",
+    "//lldb/source/Target",
+    "//lldb/source/Utility",
+  ]
+  sources = [ "DynamicLoaderStatic.cpp" ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/ExpressionParser/Clang/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/ExpressionParser/Clang/BUILD.gn
new file mode 100644
index 0000000000000..b24a9245f297e
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/ExpressionParser/Clang/BUILD.gn
@@ -0,0 +1,68 @@
+static_library("Clang") {
+  output_name = "lldbPluginExpressionParserClang"
+  configs += [
+    "//llvm/utils/gn/build:clang_code",
+    "//llvm/utils/gn/build:lldb_code",
+  ]
+  deps = [
+    "//clang/lib/AST",
+    "//clang/lib/CodeGen",
+    "//clang/lib/Driver",
+    "//clang/lib/Edit",
+    "//clang/lib/Frontend",
+    "//clang/lib/Frontend/Rewrite",
+    "//clang/lib/Lex",
+    "//clang/lib/Parse",
+    "//clang/lib/Rewrite",
+    "//clang/lib/Sema",
+    "//clang/lib/Serialization",
+    "//lldb/source/Core",
+    "//lldb/source/Expression",
+    "//lldb/source/Host",
+    "//lldb/source/Interpreter",
+
+    #"//lldb/source/Plugins/Language/CPlusPlus", # 3-hop dependency cycle
+    "//lldb/source/Plugins/LanguageRuntime/CPlusPlus",
+    "//lldb/source/Plugins/LanguageRuntime/ObjC",
+    "//lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime",
+    "//lldb/source/Symbol",
+    "//lldb/source/Target",
+    "//lldb/source/Utility",
+    "//llvm/lib/ExecutionEngine",
+    "//llvm/lib/ExecutionEngine/MCJIT",
+
+    #"//lldb/source/Plugins/TypeSystem/Clang", # Dependency cycle
+    "//llvm/lib/IR",
+    "//llvm/lib/Support",
+    "//llvm/lib/Transforms/IPO",
+  ]
+
+  # Uses source-relative paths for own includes (!)
+  include_dirs = [ "//lldb/source" ]
+  sources = [
+    "ASTResultSynthesizer.cpp",
+    "ASTStructExtractor.cpp",
+    "ASTUtils.cpp",
+    "ClangASTImporter.cpp",
+    "ClangASTMetadata.cpp",
+    "ClangASTSource.cpp",
+    "ClangDeclVendor.cpp",
+    "ClangExpressionDeclMap.cpp",
+    "ClangExpressionParser.cpp",
+    "ClangExpressionSourceCode.cpp",
+    "ClangExpressionVariable.cpp",
+    "ClangExternalASTSourceCallbacks.cpp",
+    "ClangFunctionCaller.cpp",
+    "ClangHost.cpp",
+    "ClangModulesDeclVendor.cpp",
+    "ClangPersistentVariables.cpp",
+    "ClangUserExpression.cpp",
+    "ClangUtil.cpp",
+    "ClangUtilityFunction.cpp",
+    "CppModuleConfiguration.cpp",
+    "CxxModuleHandler.cpp",
+    "IRDynamicChecks.cpp",
+    "IRForTarget.cpp",
+    "NameSearchContext.cpp",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/Instruction/ARM/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/Instruction/ARM/BUILD.gn
new file mode 100644
index 0000000000000..e33f735924b82
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/Instruction/ARM/BUILD.gn
@@ -0,0 +1,20 @@
+static_library("ARM") {
+  output_name = "lldbPluginInstructionARM"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Host",
+    "//lldb/source/Interpreter",
+    "//lldb/source/Plugins/Process/Utility",
+    "//lldb/source/Symbol",
+    "//lldb/source/Target",
+    "//llvm/lib/Support",
+  ]
+
+  # Reaches into Plugins/Process/Utility.
+  include_dirs = [ "//lldb/source" ]
+  sources = [
+    "EmulateInstructionARM.cpp",
+    "EmulationStateARM.cpp",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/JITLoader/GDB/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/JITLoader/GDB/BUILD.gn
new file mode 100644
index 0000000000000..1278d974695ee
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/JITLoader/GDB/BUILD.gn
@@ -0,0 +1,31 @@
+import("//lldb/utils/TableGen/lldb_tablegen.gni")
+
+lldb_tablegen("JITLoaderGDBProperties") {
+  args = [ "-gen-lldb-property-defs" ]
+}
+
+lldb_tablegen("JITLoaderGDBPropertiesEnum") {
+  args = [ "-gen-lldb-property-enum-defs" ]
+  td_file = "JITLoaderGDBProperties.td"
+}
+
+static_library("GDB") {
+  output_name = "lldbPluginJITLoaderGDB"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    ":JITLoaderGDBProperties",
+    ":JITLoaderGDBPropertiesEnum",
+    "//lldb/source/Breakpoint",
+    "//lldb/source/Core",
+    "//lldb/source/Interpreter",
+    "//lldb/source/Plugins/ObjectFile/Mach-O",
+    "//lldb/source/Symbol",
+    "//lldb/source/Target",
+    "//lldb/source/Utility",
+    "//llvm/lib/Support",
+  ]
+
+  # Reaches into Plugins/ObjectFile/Mach-O.
+  include_dirs = [ "//lldb/source" ]
+  sources = [ "JITLoaderGDB.cpp" ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/Language/CPlusPlus/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/Language/CPlusPlus/BUILD.gn
new file mode 100644
index 0000000000000..7a0d415993893
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/Language/CPlusPlus/BUILD.gn
@@ -0,0 +1,44 @@
+static_library("CPlusPlus") {
+  output_name = "lldbPluginCPlusPlusLanguage"
+  configs += [
+    "//llvm/utils/gn/build:clang_code",
+    "//llvm/utils/gn/build:lldb_code",
+  ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/DataFormatters",
+    "//lldb/source/Host",
+    "//lldb/source/Plugins/Language/ClangCommon",
+    "//lldb/source/Plugins/LanguageRuntime/CPlusPlus",
+    "//lldb/source/Plugins/TypeSystem/Clang",
+    "//lldb/source/Symbol",
+    "//lldb/source/Target",
+    "//lldb/source/Utility",
+    "//llvm/lib/Support",
+  ]
+
+  # Reaches into Plugins/Language/ClangCommon.
+  include_dirs = [ "//lldb/source" ]
+  sources = [
+    "BlockPointer.cpp",
+    "CPlusPlusLanguage.cpp",
+    "CPlusPlusNameParser.cpp",
+    "CxxStringTypes.cpp",
+    "LibCxx.cpp",
+    "LibCxxAtomic.cpp",
+    "LibCxxBitset.cpp",
+    "LibCxxInitializerList.cpp",
+    "LibCxxList.cpp",
+    "LibCxxMap.cpp",
+    "LibCxxOptional.cpp",
+    "LibCxxQueue.cpp",
+    "LibCxxTuple.cpp",
+    "LibCxxUnorderedMap.cpp",
+    "LibCxxVariant.cpp",
+    "LibCxxVector.cpp",
+    "LibStdcpp.cpp",
+    "LibStdcppTuple.cpp",
+    "LibStdcppUniquePointer.cpp",
+    "MSVCUndecoratedNameParser.cpp",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/Language/ClangCommon/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/Language/ClangCommon/BUILD.gn
new file mode 100644
index 0000000000000..616153af9194d
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/Language/ClangCommon/BUILD.gn
@@ -0,0 +1,13 @@
+static_library("ClangCommon") {
+  output_name = "lldbPluginClangCommon"
+  configs += [
+    "//llvm/utils/gn/build:clang_code",
+    "//llvm/utils/gn/build:lldb_code",
+  ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Utility",
+    "//llvm/lib/Support",
+  ]
+  sources = [ "ClangHighlighter.cpp" ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/Language/ObjC/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/Language/ObjC/BUILD.gn
new file mode 100644
index 0000000000000..1704395730aaf
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/Language/ObjC/BUILD.gn
@@ -0,0 +1,39 @@
+static_library("ObjC") {
+  output_name = "lldbPluginObjCLanguage"
+  configs += [
+    "//llvm/utils/gn/build:clang_code",
+    "//llvm/utils/gn/build:lldb_code",
+  ]
+  deps = [
+    "//clang/lib/AST",
+    "//lldb/source/Core",
+    "//lldb/source/DataFormatters",
+    "//lldb/source/Expression",
+    "//lldb/source/Host",
+    "//lldb/source/Plugins/Language/ClangCommon",
+    "//lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime",
+    "//lldb/source/Symbol",
+    "//lldb/source/Target",
+    "//lldb/source/Utility",
+
+    #"//lldb/source/Plugins/TypeSystem/Clang", # 3-hop dependency cycle.
+    "//llvm/lib/Support",
+  ]
+
+  # Uses source-relative includes for own headers.
+  include_dirs = [ "//lldb/source" ]
+  sources = [
+    "CF.cpp",
+    "CFBasicHash.cpp",
+    "Cocoa.cpp",
+    "CoreMedia.cpp",
+    "NSArray.cpp",
+    "NSDictionary.cpp",
+    "NSError.cpp",
+    "NSException.cpp",
+    "NSIndexPath.cpp",
+    "NSSet.cpp",
+    "NSString.cpp",
+    "ObjCLanguage.cpp",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/Language/ObjCPlusPlus/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/Language/ObjCPlusPlus/BUILD.gn
new file mode 100644
index 0000000000000..f6d5aa366d808
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/Language/ObjCPlusPlus/BUILD.gn
@@ -0,0 +1,16 @@
+static_library("ObjCPlusPlus") {
+  output_name = "lldbPluginObjCPlusPlusLanguage"
+  configs += [
+    #"//llvm/utils/gn/build:clang_code",
+    "//llvm/utils/gn/build:lldb_code",
+  ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Plugins/Language/ClangCommon",
+    "//lldb/source/Target",
+  ]
+
+  # Reaches into Plugins/Language/ClangCommon.
+  include_dirs = [ "//lldb/source" ]
+  sources = [ "ObjCPlusPlusLanguage.cpp" ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/LanguageRuntime/CPlusPlus/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/LanguageRuntime/CPlusPlus/BUILD.gn
new file mode 100644
index 0000000000000..9848efef70568
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/LanguageRuntime/CPlusPlus/BUILD.gn
@@ -0,0 +1,10 @@
+static_library("CPlusPlus") {
+  output_name = "lldbPluginCPPRuntime"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Symbol",
+    "//lldb/source/Target",
+  ]
+  sources = [ "CPPLanguageRuntime.cpp" ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/BUILD.gn
new file mode 100644
index 0000000000000..7ca3dc376ba33
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/BUILD.gn
@@ -0,0 +1,20 @@
+static_library("ItaniumABI") {
+  output_name = "lldbPluginCXXItaniumABI"
+  configs += [
+    "//llvm/utils/gn/build:clang_code",
+    "//llvm/utils/gn/build:lldb_code",
+  ]
+  deps = [
+    "//lldb/source/Breakpoint",
+    "//lldb/source/Core",
+    "//lldb/source/Interpreter",
+    "//lldb/source/Plugins/LanguageRuntime/CPlusPlus",
+    "//lldb/source/Plugins/TypeSystem/Clang",
+    "//lldb/source/Symbol",
+    "//lldb/source/Target",
+  ]
+
+  # Reaches into Plugins/LanguageRuntime/CPlusPlus.
+  include_dirs = [ "//lldb/source" ]
+  sources = [ "ItaniumABILanguageRuntime.cpp" ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/BUILD.gn
new file mode 100644
index 0000000000000..632ef5ec71a51
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/BUILD.gn
@@ -0,0 +1,36 @@
+static_library("AppleObjCRuntime") {
+  output_name = "lldbPluginAppleObjCRuntime"
+  configs += [
+    "//llvm/utils/gn/build:clang_code",
+    "//llvm/utils/gn/build:lldb_code",
+  ]
+  deps = [
+    "//clang/lib/AST",
+    "//lldb/source/Breakpoint",
+    "//lldb/source/Core",
+    "//lldb/source/Expression",
+    "//lldb/source/Host",
+    "//lldb/source/Interpreter",
+    "//lldb/source/Plugins/ExpressionParser/Clang",
+    "//lldb/source/Plugins/LanguageRuntime/CPlusPlus",
+    "//lldb/source/Symbol",
+    "//lldb/source/Target",
+    "//lldb/source/Utility",
+
+    #"//lldb/source/Plugins/TypeSystem/Clang", # 4-hop dependency cycle.
+    "//llvm/lib/Support",
+  ]
+
+  # Reaches into Plugins/ExpressionParser/Clang.
+  include_dirs = [ "//lldb/source" ]
+  sources = [
+    "AppleObjCClassDescriptorV2.cpp",
+    "AppleObjCDeclVendor.cpp",
+    "AppleObjCRuntime.cpp",
+    "AppleObjCRuntimeV1.cpp",
+    "AppleObjCRuntimeV2.cpp",
+    "AppleObjCTrampolineHandler.cpp",
+    "AppleObjCTypeEncodingParser.cpp",
+    "AppleThreadPlanStepThroughObjCTrampoline.cpp",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/LanguageRuntime/ObjC/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/LanguageRuntime/ObjC/BUILD.gn
new file mode 100644
index 0000000000000..baedd25ddb3d0
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/LanguageRuntime/ObjC/BUILD.gn
@@ -0,0 +1,17 @@
+static_library("ObjC") {
+  output_name = "lldbPluginObjCRuntime"
+  configs += [
+    "//llvm/utils/gn/build:clang_code",
+    "//llvm/utils/gn/build:lldb_code",
+  ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Symbol",
+    "//lldb/source/Target",
+    "//lldb/source/Utility",
+  ]
+
+  # Reaches into Plugins/TypeSystem/Clang.
+  include_dirs = [ "//lldb/source" ]
+  sources = [ "ObjCLanguageRuntime.cpp" ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/BUILD.gn
new file mode 100644
index 0000000000000..17d43491d5be2
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/BUILD.gn
@@ -0,0 +1,31 @@
+static_library("RenderScriptRuntime") {
+  output_name = "lldbPluginRenderScriptRuntime"
+  configs += [
+    "//llvm/utils/gn/build:clang_code",
+    "//llvm/utils/gn/build:lldb_code",
+  ]
+  deps = [
+    "//clang/lib/Basic",
+    "//lldb/source/Breakpoint",
+    "//lldb/source/Core",
+    "//lldb/source/DataFormatters",
+    "//lldb/source/Expression",
+    "//lldb/source/Host",
+    "//lldb/source/Interpreter",
+    "//lldb/source/Symbol",
+    "//lldb/source/Target",
+    "//llvm/lib/IR",
+    "//llvm/lib/IRReader",
+    "//llvm/lib/Support",
+    "//llvm/lib/Target",
+  ]
+
+  # Reaches into Plugins/LanguageRuntime/CPlusPlus.
+  include_dirs = [ "//lldb/source" ]
+  sources = [
+    "RenderScriptExpressionOpts.cpp",
+    "RenderScriptRuntime.cpp",
+    "RenderScriptScriptGroup.cpp",
+    "RenderScriptx86ABIFixups.cpp",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/ObjectContainer/BSD-Archive/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/ObjectContainer/BSD-Archive/BUILD.gn
new file mode 100644
index 0000000000000..0858c74b5840a
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/ObjectContainer/BSD-Archive/BUILD.gn
@@ -0,0 +1,11 @@
+static_library("BSD-Archive") {
+  output_name = "lldbPluginObjectContainerBSDArchive"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Host",
+    "//lldb/source/Symbol",
+    "//llvm/lib/Support",
+  ]
+  sources = [ "ObjectContainerBSDArchive.cpp" ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/ObjectContainer/Universal-Mach-O/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/ObjectContainer/Universal-Mach-O/BUILD.gn
new file mode 100644
index 0000000000000..2e1495e885dcc
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/ObjectContainer/Universal-Mach-O/BUILD.gn
@@ -0,0 +1,12 @@
+static_library("Universal-Mach-O") {
+  output_name = "lldbPluginObjectContainerMachOArchive"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Host",
+    "//lldb/source/Symbol",
+    "//lldb/source/Target",
+    "//lldb/source/Utility",
+  ]
+  sources = [ "ObjectContainerUniversalMachO.cpp" ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/ObjectFile/Breakpad/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/ObjectFile/Breakpad/BUILD.gn
new file mode 100644
index 0000000000000..9f95465875b8c
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/ObjectFile/Breakpad/BUILD.gn
@@ -0,0 +1,18 @@
+static_library("Breakpad") {
+  output_name = "lldbPluginObjectFileBreakpad"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Host",
+    "//lldb/source/Symbol",
+    "//lldb/source/Utility",
+    "//llvm/lib/Support",
+  ]
+
+  # Reaches into Plugins/Process/Utility.
+  include_dirs = [ "//lldb/source" ]
+  sources = [
+    "BreakpadRecords.cpp",
+    "ObjectFileBreakpad.cpp",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/ObjectFile/ELF/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/ObjectFile/ELF/BUILD.gn
new file mode 100644
index 0000000000000..0eea169ecca4e
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/ObjectFile/ELF/BUILD.gn
@@ -0,0 +1,17 @@
+static_library("ELF") {
+  output_name = "lldbPluginObjectFileELF"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Host",
+    "//lldb/source/Symbol",
+    "//lldb/source/Target",
+    "//llvm/lib/BinaryFormat",
+    "//llvm/lib/Object",
+    "//llvm/lib/Support",
+  ]
+  sources = [
+    "ELFHeader.cpp",
+    "ObjectFileELF.cpp",
+  ]
+}

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
new file mode 100644
index 0000000000000..1b6254c41217a
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/ObjectFile/JIT/BUILD.gn
@@ -0,0 +1,13 @@
+static_library("JIT") {
+  output_name = "lldbPluginObjectFileJIT"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Host",
+
+    #"//lldb/source/Symbol", # 2-hop dependency cycle.
+    #"//lldb/source/Target", # 2-hop dependency cycle.
+    "//llvm/lib/Support",
+  ]
+  sources = [ "ObjectFileJIT.cpp" ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/ObjectFile/Mach-O/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/ObjectFile/Mach-O/BUILD.gn
new file mode 100644
index 0000000000000..39fd4a9ca07d3
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/ObjectFile/Mach-O/BUILD.gn
@@ -0,0 +1,17 @@
+static_library("Mach-O") {
+  output_name = "lldbPluginObjectFileMachO"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Host",
+    "//lldb/source/Plugins/Process/Utility",
+    "//lldb/source/Symbol",
+    "//lldb/source/Target",
+    "//lldb/source/Utility",
+    "//llvm/lib/Support",
+  ]
+
+  # Reaches into Plugins/Process/Utility.
+  include_dirs = [ "//lldb/source" ]
+  sources = [ "ObjectFileMachO.cpp" ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/ObjectFile/PDB/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/ObjectFile/PDB/BUILD.gn
new file mode 100644
index 0000000000000..889cd2ed1a3b3
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/ObjectFile/PDB/BUILD.gn
@@ -0,0 +1,11 @@
+static_library("PDB") {
+  output_name = "lldbPluginObjectFilePDB"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Symbol",
+    "//lldb/source/Utility",
+    "//llvm/lib/Support",
+  ]
+  sources = [ "ObjectFilePDB.cpp" ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/ObjectFile/PECOFF/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/ObjectFile/PECOFF/BUILD.gn
new file mode 100644
index 0000000000000..52b530f9b5e7a
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/ObjectFile/PECOFF/BUILD.gn
@@ -0,0 +1,25 @@
+static_library("PECOFF") {
+  output_name = "lldbPluginObjectFilePECOFF"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Host",
+    "//lldb/source/Symbol",
+    "//lldb/source/Target",
+    "//llvm/lib/BinaryFormat",
+    "//llvm/lib/Support",
+  ]
+
+  # Reaches into Plugins/Process/Utility.
+  include_dirs = [ "//lldb/source" ]
+  sources = [
+    "ObjectFilePECOFF.cpp",
+    "PECallFrameInfo.cpp",
+    "WindowsMiniDump.cpp",
+  ]
+
+  if (current_os == "win") {
+    # Dbghelp is used on windows for writing minidump files.
+    libs = [ "dbghelp" ]
+  }
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/ObjectFile/wasm/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/ObjectFile/wasm/BUILD.gn
new file mode 100644
index 0000000000000..19ca2c08780a5
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/ObjectFile/wasm/BUILD.gn
@@ -0,0 +1,12 @@
+static_library("wasm") {
+  output_name = "lldbPluginObjectFileWasm"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Host",
+    "//lldb/source/Symbol",
+    "//lldb/source/Utility",
+    "//llvm/lib/Support",
+  ]
+  sources = [ "ObjectFileWasm.cpp" ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/Platform/MacOSX/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/Platform/MacOSX/BUILD.gn
new file mode 100644
index 0000000000000..f4a3a0dbeae60
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/Platform/MacOSX/BUILD.gn
@@ -0,0 +1,50 @@
+import("//lldb/utils/TableGen/lldb_tablegen.gni")
+
+lldb_tablegen("PlatformMacOSXProperties") {
+  args = [ "-gen-lldb-property-defs" ]
+}
+
+lldb_tablegen("PlatformMacOSXPropertiesEnum") {
+  args = [ "-gen-lldb-property-enum-defs" ]
+  td_file = "PlatformMacOSXProperties.td"
+}
+
+static_library("MacOSX") {
+  output_name = "lldbPluginPlatformMacOSX"
+  configs += [
+    "//llvm/utils/gn/build:clang_code",
+    "//llvm/utils/gn/build:lldb_code",
+  ]
+  deps = [
+    ":PlatformMacOSXProperties",
+    ":PlatformMacOSXPropertiesEnum",
+    "//clang/lib/Basic",
+    "//lldb/source/Breakpoint",
+    "//lldb/source/Core",
+    "//lldb/source/Host",
+    "//lldb/source/Interpreter",
+    "//lldb/source/Plugins/Platform/POSIX",
+    "//lldb/source/Symbol",
+    "//lldb/source/Target",
+    "//lldb/source/Utility",
+    "//llvm/lib/Support",
+  ]
+
+  # Reaches into Plugins/Platform/POSIX.
+  include_dirs = [ "//lldb/source" ]
+  sources = [
+    "PlatformDarwin.cpp",
+    "PlatformDarwinKernel.cpp",
+    "PlatformMacOSX.cpp",
+    "PlatformRemoteAppleBridge.cpp",
+    "PlatformRemoteAppleTV.cpp",
+    "PlatformRemoteAppleWatch.cpp",
+    "PlatformRemoteDarwinDevice.cpp",
+    "PlatformRemoteMacOSX.cpp",
+    "PlatformRemoteiOS.cpp",
+  ]
+  if (host_os == "mac") {
+    deps += [ "objcxx" ]
+    sources += [ "PlatformAppleSimulator.cpp" ]
+  }
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/Platform/MacOSX/objcxx/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/Platform/MacOSX/objcxx/BUILD.gn
new file mode 100644
index 0000000000000..d383b52bd1f34
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/Platform/MacOSX/objcxx/BUILD.gn
@@ -0,0 +1,14 @@
+static_library("objcxx") {
+  output_name = "lldbPluginPlatformMacOSXObjCXX"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Symbol",
+    "//lldb/source/Target",
+    "//lldb/source/Utility",
+    "//llvm/lib/Object",
+    "//llvm/lib/Support",
+  ]
+  cflags_objcc = [ "-fno-objc-exceptions" ]
+  sources = [ "PlatformiOSSimulatorCoreSimulatorSupport.mm" ]
+}

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

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/Platform/Windows/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/Platform/Windows/BUILD.gn
new file mode 100644
index 0000000000000..2eb1a4d5f10ce
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/Platform/Windows/BUILD.gn
@@ -0,0 +1,14 @@
+static_library("Windows") {
+  output_name = "lldbPluginPlatformWindows"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Breakpoint",
+    "//lldb/source/Core",
+    "//lldb/source/Host",
+    "//lldb/source/Target",
+  ]
+
+  # Reaches into Plugins/TypeSystem/Clang.
+  #include_dirs = [ "//lldb/source" ]
+  sources = [ "PlatformWindows.cpp" ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/Process/Utility/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/Process/Utility/BUILD.gn
new file mode 100644
index 0000000000000..4e4ba5882d48b
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/Process/Utility/BUILD.gn
@@ -0,0 +1,74 @@
+static_library("Utility") {
+  output_name = "lldbPluginProcessUtility"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    #"//lldb/source/Breakpoint", # 3-hop dependency cycle.
+    "//lldb/source/Core",
+    "//lldb/source/DataFormatters",
+    "//lldb/source/Expression",
+    "//lldb/source/Host",
+    "//lldb/source/Symbol",
+
+    #"//lldb/source/Target", # Dependency cycle.
+    "//lldb/source/Utility",
+    "//llvm/lib/Support",
+  ]
+
+  # Uses source-relative includes for own headers.
+  include_dirs = [ "//lldb/source" ]
+  sources = [
+    "AuxVector.cpp",
+    "DynamicRegisterInfo.cpp",
+    "FreeBSDSignals.cpp",
+    "GDBRemoteSignals.cpp",
+    "HistoryThread.cpp",
+    "HistoryUnwind.cpp",
+    "InferiorCallPOSIX.cpp",
+    "LinuxProcMaps.cpp",
+    "LinuxSignals.cpp",
+    "MemoryTagManagerAArch64MTE.cpp",
+    "MipsLinuxSignals.cpp",
+    "NativeProcessSoftwareSingleStep.cpp",
+    "NativeRegisterContextDBReg_arm64.cpp",
+    "NativeRegisterContextDBReg_x86.cpp",
+    "NativeRegisterContextRegisterInfo.cpp",
+    "NetBSDSignals.cpp",
+    "RegisterContextDarwin_arm.cpp",
+    "RegisterContextDarwin_arm64.cpp",
+    "RegisterContextDarwin_i386.cpp",
+    "RegisterContextDarwin_x86_64.cpp",
+    "RegisterContextDummy.cpp",
+    "RegisterContextFreeBSD_i386.cpp",
+    "RegisterContextFreeBSD_mips64.cpp",
+    "RegisterContextFreeBSD_powerpc.cpp",
+    "RegisterContextFreeBSD_x86_64.cpp",
+    "RegisterContextHistory.cpp",
+    "RegisterContextLinux_i386.cpp",
+    "RegisterContextLinux_s390x.cpp",
+    "RegisterContextLinux_x86_64.cpp",
+    "RegisterContextMach_arm.cpp",
+    "RegisterContextMach_i386.cpp",
+    "RegisterContextMach_x86_64.cpp",
+    "RegisterContextMemory.cpp",
+    "RegisterContextNetBSD_i386.cpp",
+    "RegisterContextNetBSD_x86_64.cpp",
+    "RegisterContextOpenBSD_i386.cpp",
+    "RegisterContextOpenBSD_x86_64.cpp",
+    "RegisterContextPOSIX_arm.cpp",
+    "RegisterContextPOSIX_arm64.cpp",
+    "RegisterContextPOSIX_mips64.cpp",
+    "RegisterContextPOSIX_powerpc.cpp",
+    "RegisterContextPOSIX_ppc64le.cpp",
+    "RegisterContextPOSIX_s390x.cpp",
+    "RegisterContextPOSIX_x86.cpp",
+    "RegisterContextThreadMemory.cpp",
+    "RegisterContextWindows_i386.cpp",
+    "RegisterContextWindows_x86_64.cpp",
+    "RegisterContext_x86.cpp",
+    "RegisterInfoPOSIX_arm.cpp",
+    "RegisterInfoPOSIX_arm64.cpp",
+    "RegisterInfoPOSIX_ppc64le.cpp",
+    "StopInfoMachException.cpp",
+    "ThreadMemory.cpp",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/Process/elf-core/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/Process/elf-core/BUILD.gn
new file mode 100644
index 0000000000000..cae531d77a746
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/Process/elf-core/BUILD.gn
@@ -0,0 +1,28 @@
+static_library("elf-core") {
+  output_name = "lldbPluginProcessElfCore"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Plugins/DynamicLoader/POSIX-DYLD",
+    "//lldb/source/Plugins/ObjectFile/ELF",
+    "//lldb/source/Plugins/Process/Utility",
+    "//lldb/source/Target",
+    "//llvm/lib/BinaryFormat",
+    "//llvm/lib/Support",
+  ]
+
+  # Reaches into Plugins/DynamicLoader/POSIX-DYLD.
+  include_dirs = [ "//lldb/source" ]
+  sources = [
+    "ProcessElfCore.cpp",
+    "RegisterContextPOSIXCore_arm.cpp",
+    "RegisterContextPOSIXCore_arm64.cpp",
+    "RegisterContextPOSIXCore_mips64.cpp",
+    "RegisterContextPOSIXCore_powerpc.cpp",
+    "RegisterContextPOSIXCore_ppc64le.cpp",
+    "RegisterContextPOSIXCore_s390x.cpp",
+    "RegisterContextPOSIXCore_x86_64.cpp",
+    "RegisterUtilities.cpp",
+    "ThreadElfCore.cpp",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/Process/gdb-remote/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/Process/gdb-remote/BUILD.gn
new file mode 100644
index 0000000000000..e5daaa0a3019a
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/Process/gdb-remote/BUILD.gn
@@ -0,0 +1,49 @@
+import("//lldb/utils/TableGen/lldb_tablegen.gni")
+
+lldb_tablegen("ProcessGDBRemoteProperties") {
+  args = [ "-gen-lldb-property-defs" ]
+}
+
+lldb_tablegen("ProcessGDBRemotePropertiesEnum") {
+  args = [ "-gen-lldb-property-enum-defs" ]
+  td_file = "ProcessGDBRemoteProperties.td"
+}
+
+static_library("gdb-remote") {
+  output_name = "lldbPluginProcessGDBRemote"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    ":ProcessGDBRemoteProperties",
+    ":ProcessGDBRemotePropertiesEnum",
+    "//lldb/source/Breakpoint",
+    "//lldb/source/Core",
+    "//lldb/source/DataFormatters",
+    "//lldb/source/Host",
+    "//lldb/source/Interpreter",
+    "//lldb/source/Plugins/Platform/MacOSX",
+    "//lldb/source/Plugins/Process/Utility",
+    "//lldb/source/Symbol",
+    "//lldb/source/Target",
+    "//lldb/source/Utility",
+    "//llvm/lib/Support",
+  ]
+
+  # XXX if (have_libcompression) { deps += [ compression } }
+  # Reaches into Plugins/Process/Utility.
+  include_dirs = [ "//lldb/source" ]
+  sources = [
+    "GDBRemoteClientBase.cpp",
+    "GDBRemoteCommunication.cpp",
+    "GDBRemoteCommunicationClient.cpp",
+    "GDBRemoteCommunicationHistory.cpp",
+    "GDBRemoteCommunicationReplayServer.cpp",
+    "GDBRemoteCommunicationServer.cpp",
+    "GDBRemoteCommunicationServerCommon.cpp",
+    "GDBRemoteCommunicationServerLLGS.cpp",
+    "GDBRemoteCommunicationServerPlatform.cpp",
+    "GDBRemoteRegisterContext.cpp",
+    "ProcessGDBRemote.cpp",
+    "ProcessGDBRemoteLog.cpp",
+    "ThreadGDBRemote.cpp",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/Process/mach-core/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/Process/mach-core/BUILD.gn
new file mode 100644
index 0000000000000..fa8f8b49721c3
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/Process/mach-core/BUILD.gn
@@ -0,0 +1,23 @@
+static_library("mach-core") {
+  output_name = "lldbPluginProcessMachCore"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Breakpoint",
+    "//lldb/source/Core",
+    "//lldb/source/Host",
+    "//lldb/source/Plugins/DynamicLoader/Darwin-Kernel",
+    "//lldb/source/Plugins/DynamicLoader/MacOSX-DYLD",
+    "//lldb/source/Plugins/ObjectFile/Mach-O",
+    "//lldb/source/Symbol",
+    "//lldb/source/Target",
+    "//lldb/source/Utility",
+    "//llvm/lib/Support",
+  ]
+
+  # Reaches into Plugins/Process/Utility.
+  include_dirs = [ "//lldb/source" ]
+  sources = [
+    "ProcessMachCore.cpp",
+    "ThreadMachCore.cpp",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/Process/minidump/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/Process/minidump/BUILD.gn
new file mode 100644
index 0000000000000..bb24826d6ff80
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/Process/minidump/BUILD.gn
@@ -0,0 +1,27 @@
+static_library("minidump") {
+  output_name = "lldbPluginProcessMinidump"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Plugins/Process/Utility",
+    "//lldb/source/Plugins/Process/elf-core",
+    "//lldb/source/Target",
+    "//lldb/source/Utility",
+    "//llvm/lib/BinaryFormat",
+    "//llvm/lib/Object",
+    "//llvm/lib/Support",
+  ]
+
+  # Reaches into Plugins/Process/Utility.
+  include_dirs = [ "//lldb/source" ]
+  sources = [
+    "MinidumpParser.cpp",
+    "MinidumpTypes.cpp",
+    "ProcessMinidump.cpp",
+    "RegisterContextMinidump_ARM.cpp",
+    "RegisterContextMinidump_ARM64.cpp",
+    "RegisterContextMinidump_x86_32.cpp",
+    "RegisterContextMinidump_x86_64.cpp",
+    "ThreadMinidump.cpp",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/ScriptInterpreter/None/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/ScriptInterpreter/None/BUILD.gn
new file mode 100644
index 0000000000000..39562819981f4
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/ScriptInterpreter/None/BUILD.gn
@@ -0,0 +1,9 @@
+static_library("None") {
+  output_name = "lldbPluginScriptInterpreterNone"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Interpreter",
+  ]
+  sources = [ "ScriptInterpreterNone.cpp" ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/SymbolFile/Breakpad/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/SymbolFile/Breakpad/BUILD.gn
new file mode 100644
index 0000000000000..6b830231329d8
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/SymbolFile/Breakpad/BUILD.gn
@@ -0,0 +1,16 @@
+static_library("Breakpad") {
+  output_name = "lldbPluginSymbolFileBreakpad"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Host",
+    "//lldb/source/Plugins/ObjectFile/Breakpad",
+    "//lldb/source/Symbol",
+    "//lldb/source/Utility",
+    "//llvm/lib/Support",
+  ]
+
+  # Reaches into Plugins/SymbolFile/Breakpad.
+  include_dirs = [ "//lldb/source" ]
+  sources = [ "SymbolFileBreakpad.cpp" ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/SymbolFile/DWARF/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/SymbolFile/DWARF/BUILD.gn
new file mode 100644
index 0000000000000..c96a132f095fa
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/SymbolFile/DWARF/BUILD.gn
@@ -0,0 +1,76 @@
+import("//lldb/utils/TableGen/lldb_tablegen.gni")
+
+lldb_tablegen("SymbolFileDWARFProperties") {
+  args = [ "-gen-lldb-property-defs" ]
+}
+
+lldb_tablegen("SymbolFileDWARFPropertiesEnum") {
+  args = [ "-gen-lldb-property-enum-defs" ]
+  td_file = "SymbolFileDWARFProperties.td"
+}
+
+static_library("DWARF") {
+  output_name = "lldbPluginSymbolFileDWARF"
+  configs += [
+    "//llvm/utils/gn/build:clang_code",
+    "//llvm/utils/gn/build:lldb_code",
+  ]
+  deps = [
+    ":SymbolFileDWARFProperties",
+    ":SymbolFileDWARFPropertiesEnum",
+    "//clang/lib/AST",
+    "//clang/lib/Basic",
+    "//lldb/source/Core",
+    "//lldb/source/Expression",
+    "//lldb/source/Host",
+    "//lldb/source/Interpreter",
+    "//lldb/source/Plugins/ExpressionParser/Clang",
+
+    #"//lldb/source/Plugins/Language/CPlusPlus", # 3-hop dependency cycle.
+    "//lldb/source/Plugins/Language/ObjC",
+    "//lldb/source/Symbol",
+    "//lldb/source/Target",
+    "//lldb/source/Utility",
+
+    #"//lldb/source/Plugins/TypeSystem/Clang", # Dependency cycle.
+    "//llvm/lib/DebugInfo/DWARF",
+    "//llvm/lib/Support",
+  ]
+
+  # Uses source-relative includes for own headers.
+  include_dirs = [ "//lldb/source" ]
+  sources = [
+    "AppleDWARFIndex.cpp",
+    "DIERef.cpp",
+    "DWARFASTParserClang.cpp",
+    "DWARFAbbreviationDeclaration.cpp",
+    "DWARFAttribute.cpp",
+    "DWARFBaseDIE.cpp",
+    "DWARFCompileUnit.cpp",
+    "DWARFContext.cpp",
+    "DWARFDIE.cpp",
+    "DWARFDataExtractor.cpp",
+    "DWARFDebugAbbrev.cpp",
+    "DWARFDebugArangeSet.cpp",
+    "DWARFDebugAranges.cpp",
+    "DWARFDebugInfo.cpp",
+    "DWARFDebugInfoEntry.cpp",
+    "DWARFDebugMacro.cpp",
+    "DWARFDebugRanges.cpp",
+    "DWARFDeclContext.cpp",
+    "DWARFDefines.cpp",
+    "DWARFFormValue.cpp",
+    "DWARFIndex.cpp",
+    "DWARFTypeUnit.cpp",
+    "DWARFUnit.cpp",
+    "DebugNamesDWARFIndex.cpp",
+    "HashedNameToDIE.cpp",
+    "LogChannelDWARF.cpp",
+    "ManualDWARFIndex.cpp",
+    "NameToDIE.cpp",
+    "SymbolFileDWARF.cpp",
+    "SymbolFileDWARFDebugMap.cpp",
+    "SymbolFileDWARFDwo.cpp",
+    "UniqueDWARFASTType.cpp",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/SymbolFile/NativePDB/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/SymbolFile/NativePDB/BUILD.gn
new file mode 100644
index 0000000000000..cf43087193f7a
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/SymbolFile/NativePDB/BUILD.gn
@@ -0,0 +1,35 @@
+static_library("NativePDB") {
+  output_name = "lldbPluginSymbolFileNativePDB"
+  configs += [
+    "//llvm/utils/gn/build:clang_code",
+    "//llvm/utils/gn/build:lldb_code",
+  ]
+  deps = [
+    "//clang/lib/AST",
+    "//clang/lib/Lex",
+    "//lldb/source/Core",
+    "//lldb/source/Plugins/ObjectFile/PDB",
+    "//lldb/source/Symbol",
+    "//lldb/source/Utility",
+
+    #"//lldb/source/Plugins/TypeSystem/Clang", # 3-hop dependency cycle.
+    "//llvm/lib/DebugInfo/CodeView",
+    "//llvm/lib/DebugInfo/PDB",
+    "//llvm/lib/Support",
+  ]
+
+  # Reaches into Plugins/ExpressionParser.
+  include_dirs = [ "//lldb/source" ]
+  sources = [
+    "CodeViewRegisterMapping.cpp",
+    "CompileUnitIndex.cpp",
+    "DWARFLocationExpression.cpp",
+    "PdbAstBuilder.cpp",
+    "PdbFPOProgramToDWARFExpression.cpp",
+    "PdbIndex.cpp",
+    "PdbSymUid.cpp",
+    "PdbUtil.cpp",
+    "SymbolFileNativePDB.cpp",
+    "UdtRecordCompleter.cpp",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/SymbolFile/PDB/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/SymbolFile/PDB/BUILD.gn
new file mode 100644
index 0000000000000..4758fb3571265
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/SymbolFile/PDB/BUILD.gn
@@ -0,0 +1,27 @@
+static_library("PDB") {
+  output_name = "lldbPluginSymbolFilePDB"
+  configs += [
+    "//llvm/utils/gn/build:clang_code",
+    "//llvm/utils/gn/build:lldb_code",
+  ]
+  deps = [
+    "//clang/lib/AST",
+    "//clang/lib/Lex",
+    "//lldb/source/Core",
+    "//lldb/source/Plugins/SymbolFile/NativePDB",
+    "//lldb/source/Symbol",
+    "//lldb/source/Utility",
+
+    #"//lldb/source/Plugins/TypeSystem/Clang", # Dependency cycle.
+    "//llvm/lib/DebugInfo/PDB",
+    "//llvm/lib/Support",
+  ]
+
+  # Reaches into Plugins/ExpressionParser/Clang.
+  include_dirs = [ "//lldb/source" ]
+  sources = [
+    "PDBASTParser.cpp",
+    "PDBLocationToDWARFExpression.cpp",
+    "SymbolFilePDB.cpp",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/SymbolFile/Symtab/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/SymbolFile/Symtab/BUILD.gn
new file mode 100644
index 0000000000000..678448536e37c
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/SymbolFile/Symtab/BUILD.gn
@@ -0,0 +1,9 @@
+static_library("Symtab") {
+  output_name = "lldbPluginSymbolFileSymtab"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Symbol",
+  ]
+  sources = [ "SymbolFileSymtab.cpp" ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/SymbolVendor/ELF/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/SymbolVendor/ELF/BUILD.gn
new file mode 100644
index 0000000000000..b5811e3993983
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/SymbolVendor/ELF/BUILD.gn
@@ -0,0 +1,14 @@
+static_library("ELF") {
+  output_name = "lldbPluginSymbolVendorELF"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Host",
+    "//lldb/source/Plugins/ObjectFile/ELF",
+    "//lldb/source/Symbol",
+  ]
+
+  # Reaches into Plugins/ObjectFile/ELF.
+  include_dirs = [ "//lldb/source" ]
+  sources = [ "SymbolVendorELF.cpp" ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/SymbolVendor/MacOSX/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/SymbolVendor/MacOSX/BUILD.gn
new file mode 100644
index 0000000000000..2a8fe621dafee
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/SymbolVendor/MacOSX/BUILD.gn
@@ -0,0 +1,14 @@
+static_library("MacOSX") {
+  output_name = "lldbPluginSymbolVendorMacOSX"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Host",
+    "//lldb/source/Plugins/ObjectFile/Mach-O",
+    "//lldb/source/Symbol",
+  ]
+
+  # Reaches into Plugins/ObjectFile/Mach-O.
+  include_dirs = [ "//lldb/source" ]
+  sources = [ "SymbolVendorMacOSX.cpp" ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/SymbolVendor/wasm/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/SymbolVendor/wasm/BUILD.gn
new file mode 100644
index 0000000000000..baac3d979e00c
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/SymbolVendor/wasm/BUILD.gn
@@ -0,0 +1,14 @@
+static_library("wasm") {
+  output_name = "lldbPluginSymbolVendorWasm"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Host",
+    "//lldb/source/Plugins/ObjectFile/wasm",
+    "//lldb/source/Symbol",
+  ]
+
+  # Reaches into Plugins/ObjectFile/wasm.
+  include_dirs = [ "//lldb/source" ]
+  sources = [ "SymbolVendorWasm.cpp" ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/TypeSystem/Clang/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/TypeSystem/Clang/BUILD.gn
new file mode 100644
index 0000000000000..a1d00d5a9c753
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/TypeSystem/Clang/BUILD.gn
@@ -0,0 +1,26 @@
+static_library("Clang") {
+  output_name = "lldbPluginTypeSystemClang"
+  configs += [
+    "//llvm/utils/gn/build:clang_code",
+    "//llvm/utils/gn/build:lldb_code",
+  ]
+  deps = [
+    "//clang/lib/AST",
+    "//clang/lib/Basic",
+    "//clang/lib/Frontend",
+    "//clang/lib/Sema",
+    "//lldb/source/Core",
+    "//lldb/source/Plugins/ExpressionParser/Clang",
+    "//lldb/source/Plugins/LanguageRuntime/ObjC",
+    "//lldb/source/Plugins/SymbolFile/DWARF",
+    "//lldb/source/Plugins/SymbolFile/PDB",
+    "//lldb/source/Symbol",
+    "//lldb/source/Target",
+    "//lldb/source/Utility",
+    "//llvm/lib/Support",
+  ]
+
+  # Reaches into Plugins/ExpressionParser/Clang.
+  include_dirs = [ "//lldb/source" ]
+  sources = [ "TypeSystemClang.cpp" ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/UnwindAssembly/InstEmulation/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/UnwindAssembly/InstEmulation/BUILD.gn
new file mode 100644
index 0000000000000..72a739ed2de4e
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/UnwindAssembly/InstEmulation/BUILD.gn
@@ -0,0 +1,10 @@
+static_library("InstEmulation") {
+  output_name = "lldbPluginUnwindAssemblyInstEmulation"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Symbol",
+    "//lldb/source/Target",
+  ]
+  sources = [ "UnwindAssemblyInstEmulation.cpp" ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Plugins/UnwindAssembly/x86/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/UnwindAssembly/x86/BUILD.gn
new file mode 100644
index 0000000000000..2503c1e2eaafd
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/UnwindAssembly/x86/BUILD.gn
@@ -0,0 +1,17 @@
+static_library("x86") {
+  output_name = "lldbPluginUnwindAssemblyX86"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Symbol",
+    "//lldb/source/Target",
+    "//lldb/source/Utility",
+    "//llvm/lib/MC",
+    "//llvm/lib/MC/MCDisassembler",
+    "//llvm/lib/Support",
+  ]
+  sources = [
+    "UnwindAssembly-x86.cpp",
+    "x86AssemblyInspectionEngine.cpp",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Symbol/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Symbol/BUILD.gn
new file mode 100644
index 0000000000000..af35e6d086086
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Symbol/BUILD.gn
@@ -0,0 +1,49 @@
+static_library("Symbol") {
+  output_name = "lldbSymbol"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//lldb/source/Core",
+    "//lldb/source/Expression",
+    "//lldb/source/Host",
+
+    #"//lldb/source/Target", # FIXME: Dependency cycle.
+    "//lldb/source/Utility",
+    "//llvm/lib/Support",
+  ]
+  include_dirs = [ ".." ]  # FIXME: Reaches into Utility and Host internals.
+  sources = [
+    "ArmUnwindInfo.cpp",
+    "Block.cpp",
+    "CompactUnwindInfo.cpp",
+    "CompileUnit.cpp",
+    "CompilerDecl.cpp",
+    "CompilerDeclContext.cpp",
+    "CompilerType.cpp",
+    "DWARFCallFrameInfo.cpp",
+    "DebugMacros.cpp",
+    "DeclVendor.cpp",
+    "FuncUnwinders.cpp",
+    "Function.cpp",
+    "LineEntry.cpp",
+    "LineTable.cpp",
+    "LocateSymbolFile.cpp",
+    "ObjectFile.cpp",
+    "PostfixExpression.cpp",
+    "Symbol.cpp",
+    "SymbolContext.cpp",
+    "SymbolFile.cpp",
+    "SymbolVendor.cpp",
+    "Symtab.cpp",
+    "Type.cpp",
+    "TypeList.cpp",
+    "TypeMap.cpp",
+    "TypeSystem.cpp",
+    "UnwindPlan.cpp",
+    "UnwindTable.cpp",
+    "Variable.cpp",
+    "VariableList.cpp",
+  ]
+  if (current_os == "mac") {
+    sources += [ "LocateSymbolFileMacOSX.cpp" ]
+  }
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Target/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Target/BUILD.gn
new file mode 100644
index 0000000000000..7ebde0a5ddf6e
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Target/BUILD.gn
@@ -0,0 +1,100 @@
+import("//lldb/utils/TableGen/lldb_tablegen.gni")
+
+lldb_tablegen("TargetProperties") {
+  args = [ "-gen-lldb-property-defs" ]
+}
+
+lldb_tablegen("TargetPropertiesEnum") {
+  args = [ "-gen-lldb-property-enum-defs" ]
+  td_file = "TargetProperties.td"
+}
+
+static_library("Target") {
+  output_name = "lldbTarget"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    ":TargetProperties",
+    ":TargetPropertiesEnum",
+
+    #"//lldb/source/Breakpoint", # FIXME: Dependency cycle
+    "//lldb/source/Core",
+    "//lldb/source/Core",
+    "//lldb/source/Expression",
+    "//lldb/source/Host",
+    "//lldb/source/Interpreter",
+    "//lldb/source/Plugins/Process/Utility",
+    "//lldb/source/Symbol",
+    "//lldb/source/Utility",
+    "//llvm/lib/MC",
+    "//llvm/lib/Support",
+  ]
+  include_dirs = [ ".." ]  # FIXME: Reaches into Plugins internals.
+  sources = [
+    "ABI.cpp",
+    "AssertFrameRecognizer.cpp",
+    "ExecutionContext.cpp",
+    "InstrumentationRuntime.cpp",
+    "InstrumentationRuntimeStopInfo.cpp",
+    "JITLoader.cpp",
+    "JITLoaderList.cpp",
+    "Language.cpp",
+    "LanguageRuntime.cpp",
+    "Memory.cpp",
+    "MemoryHistory.cpp",
+    "MemoryRegionInfo.cpp",
+    "ModuleCache.cpp",
+    "OperatingSystem.cpp",
+    "PathMappingList.cpp",
+    "Platform.cpp",
+    "Process.cpp",
+    "ProcessTrace.cpp",
+    "Queue.cpp",
+    "QueueItem.cpp",
+    "QueueList.cpp",
+    "RegisterContext.cpp",
+    "RegisterContextUnwind.cpp",
+    "RegisterNumber.cpp",
+    "RemoteAwarePlatform.cpp",
+    "SectionLoadHistory.cpp",
+    "SectionLoadList.cpp",
+    "StackFrame.cpp",
+    "StackFrameList.cpp",
+    "StackFrameRecognizer.cpp",
+    "StackID.cpp",
+    "StopInfo.cpp",
+    "StructuredDataPlugin.cpp",
+    "SystemRuntime.cpp",
+    "Target.cpp",
+    "TargetList.cpp",
+    "Thread.cpp",
+    "ThreadCollection.cpp",
+    "ThreadList.cpp",
+    "ThreadPlan.cpp",
+    "ThreadPlanBase.cpp",
+    "ThreadPlanCallFunction.cpp",
+    "ThreadPlanCallFunctionUsingABI.cpp",
+    "ThreadPlanCallOnFunctionExit.cpp",
+    "ThreadPlanCallUserExpression.cpp",
+    "ThreadPlanPython.cpp",
+    "ThreadPlanRunToAddress.cpp",
+    "ThreadPlanShouldStopHere.cpp",
+    "ThreadPlanStack.cpp",
+    "ThreadPlanStepInRange.cpp",
+    "ThreadPlanStepInstruction.cpp",
+    "ThreadPlanStepOut.cpp",
+    "ThreadPlanStepOverBreakpoint.cpp",
+    "ThreadPlanStepOverRange.cpp",
+    "ThreadPlanStepRange.cpp",
+    "ThreadPlanStepThrough.cpp",
+    "ThreadPlanStepUntil.cpp",
+    "ThreadPlanTracer.cpp",
+    "ThreadSpec.cpp",
+    "Trace.cpp",
+    "TraceCursor.cpp",
+    "TraceExporter.cpp",
+    "TraceInstructionDumper.cpp",
+    "UnixSignals.cpp",
+    "UnwindAssembly.cpp",
+    "UnwindLLDB.cpp",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/source/Utility/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Utility/BUILD.gn
new file mode 100644
index 0000000000000..242111b5b2d2f
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/source/Utility/BUILD.gn
@@ -0,0 +1,85 @@
+static_library("Utility") {
+  output_name = "lldbUtility"
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    "//llvm/lib/BinaryFormat",
+    "//llvm/lib/Support",
+  ]
+  sources = [
+    "ArchSpec.cpp",
+    "Args.cpp",
+    "Baton.cpp",
+    "Broadcaster.cpp",
+    "CompletionRequest.cpp",
+    "Connection.cpp",
+    "ConstString.cpp",
+    "DataBufferHeap.cpp",
+    "DataBufferLLVM.cpp",
+    "DataEncoder.cpp",
+    "DataExtractor.cpp",
+    "Environment.cpp",
+    "Event.cpp",
+    "FileSpec.cpp",
+    "GDBRemote.cpp",
+    "IOObject.cpp",
+    "LLDBAssert.cpp",
+    "Listener.cpp",
+    "Log.cpp",
+    "Logging.cpp",
+    "NameMatches.cpp",
+    "ProcessInfo.cpp",
+    "RegisterValue.cpp",
+    "RegularExpression.cpp",
+    "Reproducer.cpp",
+    "ReproducerInstrumentation.cpp",
+    "ReproducerProvider.cpp",
+    "Scalar.cpp",
+    "SelectHelper.cpp",
+    "State.cpp",
+    "Status.cpp",
+    "Stream.cpp",
+    "StreamCallback.cpp",
+    "StreamString.cpp",
+    "StringExtractor.cpp",
+    "StringExtractorGDBRemote.cpp",
+    "StringLexer.cpp",
+    "StringList.cpp",
+    "StructuredData.cpp",
+    "TildeExpressionResolver.cpp",
+    "Timer.cpp",
+    "TraceGDBRemotePackets.cpp",
+    "TraceIntelPTGDBRemotePackets.cpp",
+    "UUID.cpp",
+    "UnimplementedError.cpp",
+    "UriParser.cpp",
+    "UserID.cpp",
+    "UserIDResolver.cpp",
+    "VASprintf.cpp",
+    "VMRange.cpp",
+    "XcodeSDK.cpp",
+  ]
+
+  # FIXME:
+  # if (APPLE)
+  #   list(APPEND LLDB_SYSTEM_LIBS
+  #        ${FOUNDATION_LIBRARY}
+  #        ${CORE_FOUNDATION_LIBRARY}
+  #        ${CORE_SERVICES_LIBRARY}
+  #        ${SECURITY_LIBRARY}
+  #        ${DEBUG_SYMBOLS_LIBRARY})
+  # endif()
+  #
+  # if(NOT PURE_WINDOWS)
+  #   list(APPEND LLDB_SYSTEM_LIBS ${CMAKE_THREAD_LIBS_INIT})
+  # endif()
+  #
+  # list(APPEND LLDB_SYSTEM_LIBS ${CMAKE_DL_LIBS})
+  #
+  # if (CMAKE_SYSTEM_NAME MATCHES "Windows")
+  #   list(APPEND LLDB_SYSTEM_LIBS ws2_32 rpcrt4)
+  # endif ()
+  #
+  # if (NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB )
+  #     list(APPEND LLDB_SYSTEM_LIBS atomic)
+  # endif()
+}

diff  --git a/llvm/utils/gn/secondary/lldb/test/BUILD.gn b/llvm/utils/gn/secondary/lldb/test/BUILD.gn
new file mode 100644
index 0000000000000..a4af26a164fe2
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/test/BUILD.gn
@@ -0,0 +1,197 @@
+import("//llvm/triples.gni")
+
+#import("//llvm/utils/gn/build/libs/xar/enable.gni")
+import("//llvm/utils/gn/build/libs/xml/enable.gni")
+import("//llvm/utils/gn/build/libs/zlib/enable.gni")
+import("//llvm/utils/gn/build/write_cmake_config.gni")
+import("lldb_lit_site_cfg_files.gni")
+
+# The bits common to writing lit.site.cfg.py.in, API/lit.site.cfg.py,
+# Shell/lit.site.cfg.py, and Unit/lit.site.cfg.py.in.
+template("write_lit_cfg") {
+  write_cmake_config(target_name) {
+    input = invoker.input
+    output = invoker.output
+    values = [
+      "LIT_SITE_CFG_IN_HEADER=## Autogenerated from $input, do not edit",
+      "LLDB_BINARY_DIR=" +
+          rebase_path(get_label_info("//lldb", "target_out_dir")),
+      "LLDB_SOURCE_DIR=" + rebase_path("//lldb"),
+      "LLVM_BINARY_DIR=" +
+          rebase_path(get_label_info("//llvm", "target_out_dir")),
+      "LLVM_LIBS_DIR=",  # needed only for shared builds
+      "LLVM_LIT_TOOLS_DIR=",  # Intentionally empty, matches cmake build.
+      "LLVM_SOURCE_DIR=" + rebase_path("//llvm"),
+      "LLVM_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"),
+      "Python3_EXECUTABLE=$python_path",
+      "TARGET_TRIPLE=$llvm_target_triple",
+    ]
+    values += invoker.extra_values
+  }
+}
+
+write_cmake_config("lit-lldb-init") {
+  input = "//lldb/test/Shell/lit-lldb-init.in"
+
+  # XXX nicer way to get this path
+  output = "$root_out_dir/obj/lldb/test/Shell/lit-lldb-init"
+  values = [ "LLDB_TEST_MODULE_CACHE_LLDB=" +
+             rebase_path(
+                 "$target_gen_dir/lldb-test-build.noindex/module-cache-lldb") ]
+}
+
+write_lit_cfg("lit_site_cfg") {
+  # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
+  input = "//lldb/test/lit.site.cfg.py.in"
+  output = lldb_lit_site_cfg_file
+  extra_values = [ "LLVM_BUILD_MODE=." ]
+}
+
+write_lit_cfg("lit_api_site_cfg") {
+  # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
+  input = "//lldb/test/API/lit.site.cfg.py.in"
+  output = lldb_lit_api_site_cfg_file
+  extra_values = [
+    "LLDB_BUILD_INTEL_PT=0",
+    "LLDB_DOTEST_ARGS=",
+    "LLDB_ENABLE_PYTHON=0",
+    "LLDB_LIBS_DIR=",  # FIXME: for shared builds only (?)
+    "LLDB_TEST_ARCH=$current_cpu",
+    "LLDB_TEST_COMPILER=" + rebase_path("$root_build_dir/bin/clang"),
+    "LLDB_TEST_BUILD_DIRECTORY=" + rebase_path("$target_gen_dir/test_build"),
+    "LLDB_TEST_DSYMUTIL=" + rebase_path("$root_build_dir/bin/dsymutil"),
+    "LLDB_TEST_EXECUTABLE=" + rebase_path("$root_build_dir/bin/lldb"),
+    "LLDB_TEST_MODULE_CACHE_CLANG=" +
+        rebase_path(
+            "$target_gen_dir/lldb-test-build.noindex/module-cache-clang"),
+    "LLDB_TEST_MODULE_CACHE_LLDB=" +
+        rebase_path(
+            "$target_gen_dir/lldb-test-build.noindex/module-cache-lldb"),
+    "LLVM_BUILD_MODE=.",
+    "LLVM_ENABLE_SHARED_LIBS=0",
+    "LLVM_HOST_TRIPLE=$llvm_current_triple",
+    "LLVM_USE_SANITIZER=",
+
+    "LLDB_FRAMEWORK_DIR=XXX_framework_dir",
+    "CMAKE_CXX_COMPILER=c++",  # XXX use bin/clang++ instead?
+    "HOST_OS=$host_os",  # XXX
+  ]
+
+  dir = get_path_info(output, "dir")
+  if (host_os == "win") {
+    # See comment for Windows solink in llvm/utils/gn/build/toolchain/BUILD.gn
+    extra_values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/bin", dir) ]
+  } else {
+    extra_values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/lib", dir) ]
+  }
+}
+
+write_lit_cfg("lit_shell_site_cfg") {
+  # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
+  input = "//lldb/test/Shell/lit.site.cfg.py.in"
+  output = lldb_lit_shell_site_cfg_file
+  extra_values = [
+    "LLDB_ENABLE_LUA=0",  # FIXME: gn arg, use in Config.h
+    "LLDB_ENABLE_LZMA=0",  # FIXME: gn arg, use in Config.h
+    "LLDB_ENABLE_PYTHON=0",  # FIXME: gn arg, use in Config.h
+    "LLDB_IS_64_BITS=1",
+    "LLDB_LIBS_DIR=",  # FIXME: for shared builds only (?)
+    "LLDB_LIT_TOOLS_DIR=",  # Intentionally empty, matches cmake build.
+    "LLDB_TEST_BUILD_DIRECTORY=" + rebase_path("$target_gen_dir/test_build"),
+    "LLDB_TEST_MODULE_CACHE_CLANG=" +
+        rebase_path(
+            "$target_gen_dir/lldb-test-build.noindex/module-cache-clang"),
+    "LLDB_TEST_MODULE_CACHE_LLDB=" +
+        rebase_path(
+            "$target_gen_dir/lldb-test-build.noindex/module-cache-lldb"),
+    "LLDB_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"),
+    "LLDB_USE_SYSTEM_DEBUGSERVER=1",  # XXX port //lldb/tools/debugserver (?)
+    "LLVM_HOST_TRIPLE=$llvm_current_triple",
+  ]
+
+  if (llvm_enable_zlib) {
+    extra_values += [ "LLVM_ENABLE_ZLIB=1" ]
+  } else {
+    extra_values += [ "LLVM_ENABLE_ZLIB=0" ]  # Must be 0.
+  }
+
+  dir = get_path_info(output, "dir")
+  if (host_os == "win") {
+    # See comment for Windows solink in llvm/utils/gn/build/toolchain/BUILD.gn
+    extra_values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/bin", dir) ]
+  } else {
+    extra_values += [ "SHLIBDIR=" + rebase_path("$root_out_dir/lib", dir) ]
+  }
+}
+
+write_lit_cfg("lit_unit_site_cfg") {
+  # Fully-qualified instead of relative for LIT_SITE_CFG_IN_HEADER.
+  input = "//lldb/test/Unit/lit.site.cfg.py.in"
+  output = lldb_lit_unit_site_cfg_file
+  extra_values = [ "LLVM_BUILD_MODE=." ]
+}
+
+# This target should contain all dependencies of check-lldb.
+# //:default depends on it, so that ninja's default target builds all
+# prerequisites for check-lldb but doesn't run check-lldb itself.
+group("test") {
+  deps = [
+    ":lit-lldb-init",
+    ":lit_api_site_cfg",
+    ":lit_shell_site_cfg",
+    ":lit_site_cfg",
+    ":lit_unit_site_cfg",
+    "//clang/tools/driver:symlinks",
+    "//lld/tools/lld:symlinks",
+    "//lldb/tools/driver:lldb",
+
+    # XXX lldb-instr, darwin-debug, etc
+    "//lldb/tools/lldb-server",
+    "//lldb/tools/lldb-test",
+    "//lldb/tools/lldb-vscode",
+    "//lldb/utils/lit-cpuid",
+
+    #"//lldb/unittests",
+    "//llvm/tools/dsymutil",
+    "//llvm/tools/llc",
+    "//llvm/tools/lli",
+    "//llvm/tools/llvm-config",
+    "//llvm/tools/llvm-dwarfdump",
+    "//llvm/tools/llvm-dwp",
+    "//llvm/tools/llvm-mc",
+    "//llvm/tools/llvm-nm:symlinks",
+    "//llvm/tools/llvm-objcopy:symlinks",
+    "//llvm/tools/llvm-pdbutil",
+    "//llvm/tools/llvm-readobj:symlinks",
+    "//llvm/tools/split-file",
+    "//llvm/tools/yaml2obj",
+    "//llvm/utils/FileCheck",
+    "//llvm/utils/count",
+    "//llvm/utils/llvm-lit",
+    "//llvm/utils/not",
+  ]
+  testonly = true
+}
+
+# This is the action that runs all of lldb's tests, check-lldb.
+action("check-lldb") {
+  script = "$root_out_dir/bin/llvm-lit"
+  if (host_os == "win") {
+    script += ".py"
+  }
+  args = [
+    "-sv",
+    rebase_path(".", root_out_dir),
+  ]
+  outputs = [ "$target_gen_dir/run-lit" ]  # Non-existing, so that ninja runs it
+                                           # each time.
+
+  # Since check-lldb is always dirty, //:default doesn't depend on it so that
+  # it's not part of the default ninja target.  Hence, check-lld shouldn't
+  # have any deps except :test, so that the default target is sure to build
+  # all the deps.
+  deps = [ ":test" ]
+  testonly = true
+
+  pool = "//:console"
+}

diff  --git a/llvm/utils/gn/secondary/lldb/test/lldb_lit_site_cfg_files.gni b/llvm/utils/gn/secondary/lldb/test/lldb_lit_site_cfg_files.gni
new file mode 100644
index 0000000000000..1c25fdaaaae25
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/test/lldb_lit_site_cfg_files.gni
@@ -0,0 +1,4 @@
+lldb_lit_site_cfg_file = "$root_gen_dir/lldb/test/lit.site.cfg.py"
+lldb_lit_api_site_cfg_file = "$root_gen_dir/lldb/test/API/lit.site.cfg.py"
+lldb_lit_shell_site_cfg_file = "$root_gen_dir/lldb/test/Shell/lit.site.cfg.py"
+lldb_lit_unit_site_cfg_file = "$root_gen_dir/lldb/test/Unit/lit.site.cfg.py"

diff  --git a/llvm/utils/gn/secondary/lldb/tools/argdumper/BUILD.gn b/llvm/utils/gn/secondary/lldb/tools/argdumper/BUILD.gn
new file mode 100644
index 0000000000000..52d2f4d83236a
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/tools/argdumper/BUILD.gn
@@ -0,0 +1,7 @@
+executable("lldb-argdumper") {
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [ "//llvm/lib/Support" ]
+  sources = [ "argdumper.cpp" ]
+
+  # XXX ADD_TO_FRAMEWORK
+}

diff  --git a/llvm/utils/gn/secondary/lldb/tools/driver/BUILD.gn b/llvm/utils/gn/secondary/lldb/tools/driver/BUILD.gn
new file mode 100644
index 0000000000000..1b82637bfc04e
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/tools/driver/BUILD.gn
@@ -0,0 +1,42 @@
+import("//llvm/utils/TableGen/tablegen.gni")
+import("//llvm/utils/gn/build/write_cmake_config.gni")
+import("//llvm/version.gni")
+
+tablegen("Options") {
+  visibility = [ ":lldb" ]
+  args = [ "-gen-opt-parser-defs" ]
+}
+
+if (host_os == "mac") {
+  write_cmake_config("write_info_plist") {
+    input = "lldb-Info.plist.in"
+    output = "$target_gen_dir/lldb-Info.plist"
+    values = [ "LLDB_VERSION=$llvm_version" ]
+  }
+}
+
+executable("lldb") {
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    ":Options",
+    "//lldb/include/lldb/Host:Config",
+    "//lldb/source/API:liblldb",
+    "//llvm/lib/Option",
+    "//llvm/lib/Support",
+    "//llvm/utils/gn/build/libs/xar",
+  ]
+  if (host_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) ]
+  }
+
+  sources = [
+    "Driver.cpp",
+    "Platform.cpp",
+  ]
+
+  # XXX if win -DIMPORT_LIBLLDB
+  # XXX LLDB_BUILD_FRAMEWORK rpath stuff
+}

diff  --git a/llvm/utils/gn/secondary/lldb/tools/lldb-server/BUILD.gn b/llvm/utils/gn/secondary/lldb/tools/lldb-server/BUILD.gn
new file mode 100644
index 0000000000000..eca737b0bc22b
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/tools/lldb-server/BUILD.gn
@@ -0,0 +1,60 @@
+import("//llvm/utils/TableGen/tablegen.gni")
+
+tablegen("LLGSOptions") {
+  visibility = [ ":lldb-server" ]
+  args = [ "-gen-opt-parser-defs" ]
+}
+
+executable("lldb-server") {
+  configs += [
+    #"//llvm/utils/gn/build:clang_code",
+    "//llvm/utils/gn/build:lldb_code",
+  ]
+  deps = [
+    ":LLGSOptions",
+
+    #"//lldb/include/lldb/Host:Config",
+    "//lldb/source:lldbBase",
+    "//lldb/source/Host",
+    "//lldb/source/Initialization",
+
+    #"//lldb/source/Plugins/Instruction/ARM", # XXX
+    #"//lldb/source/Plugins/Instruction/MIPS", # XXX
+    #"//lldb/source/Plugins/Instruction/MIPS64", # XXX
+    "//llvm/lib/Option",
+    "//llvm/lib/Support",
+
+    # Dep of //lldb/source/Core, but omitted there due to a
+    # dependency cyle. Need to add dep here.
+    "//lldb/source/Plugins/Language/CPlusPlus",
+  ]
+
+  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" ]
+  } else if (current_os == "win") {
+    deps += [ "//lldb/source/Plugins/ObjectFile/PECOFF" ]
+  } else {
+    deps += [ "//lldb/source/Plugins/ObjectFile/ELF" ]
+  }
+
+  # FIXME: codesign stuff on macos; default to "lldb_codesign"
+
+  # Reaches into Plugins/ObjectFile/Mach-O.
+  include_dirs = [ "//lldb/source" ]
+  sources = [
+    "Acceptor.cpp",
+    "LLDBServerUtilities.cpp",
+    "SystemInitializerLLGS.cpp",
+    "lldb-gdbserver.cpp",
+    "lldb-platform.cpp",
+    "lldb-server.cpp",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/tools/lldb-test/BUILD.gn b/llvm/utils/gn/secondary/lldb/tools/lldb-test/BUILD.gn
new file mode 100644
index 0000000000000..ea2ed501ec7a6
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/tools/lldb-test/BUILD.gn
@@ -0,0 +1,29 @@
+executable("lldb-test") {
+  configs += [
+    "//llvm/utils/gn/build:clang_code",
+    "//llvm/utils/gn/build:lldb_code",
+  ]
+  deps = [
+    "//lldb/source:lldbBase",
+    "//lldb/source/Breakpoint",
+    "//lldb/source/Core",
+    "//lldb/source/DataFormatters",
+    "//lldb/source/Expression",
+    "//lldb/source/Host",
+    "//lldb/source/Initialization",
+    "//lldb/source/Interpreter",
+    "//lldb/source/Plugins:LldbAllPlugins",
+    "//lldb/source/Symbol",
+    "//lldb/source/Target",
+    "//lldb/source/Utility",
+    "//llvm/lib/Support",
+  ]
+
+  # XXX commment
+  include_dirs = [ "//lldb/source" ]
+  sources = [
+    "FormatUtil.cpp",
+    "SystemInitializerTest.cpp",
+    "lldb-test.cpp",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/tools/lldb-vscode/BUILD.gn b/llvm/utils/gn/secondary/lldb/tools/lldb-vscode/BUILD.gn
new file mode 100644
index 0000000000000..a4211f831e2c3
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/tools/lldb-vscode/BUILD.gn
@@ -0,0 +1,52 @@
+import("//llvm/utils/TableGen/tablegen.gni")
+import("//llvm/utils/gn/build/write_cmake_config.gni")
+import("//llvm/version.gni")
+
+tablegen("Options") {
+  visibility = [ ":lldb-vscode" ]
+  args = [ "-gen-opt-parser-defs" ]
+}
+
+if (host_os == "mac") {
+  write_cmake_config("write_info_plist") {
+    input = "lldb-vscode-Info.plist.in"
+    output = "$target_gen_dir/lldb-vscode-Info.plist"
+    values = [ "LLDB_VERSION=$llvm_version" ]
+  }
+}
+
+executable("lldb-vscode") {
+  configs += [ "//llvm/utils/gn/build:lldb_code" ]
+  deps = [
+    ":Options",
+    "//lldb/source/API:liblldb",
+    "//llvm/lib/Option",
+    "//llvm/lib/Support",
+  ]
+  if (host_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) ]
+  }
+
+  # FIXME: link in //lldb/source/Host on Win (and netbsd)
+  # FIXME: link in pthread
+  # FIXME: rpath/install_name stuff on macOS for framework on macOS
+
+  sources = [
+    "BreakpointBase.cpp",
+    "ExceptionBreakpoint.cpp",
+    "FifoFiles.cpp",
+    "FunctionBreakpoint.cpp",
+    "IOStream.cpp",
+    "JSONUtils.cpp",
+    "LLDBUtils.cpp",
+    "OutputRedirector.cpp",
+    "ProgressEvent.cpp",
+    "RunInTerminal.cpp",
+    "SourceBreakpoint.cpp",
+    "VSCode.cpp",
+    "lldb-vscode.cpp",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/utils/TableGen/BUILD.gn b/llvm/utils/gn/secondary/lldb/utils/TableGen/BUILD.gn
new file mode 100644
index 0000000000000..37305d1de66ca
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/utils/TableGen/BUILD.gn
@@ -0,0 +1,12 @@
+executable("lldb-tblgen") {
+  deps = [
+    "//llvm/lib/Support",
+    "//llvm/lib/TableGen",
+  ]
+  sources = [
+    "LLDBOptionDefEmitter.cpp",
+    "LLDBPropertyDefEmitter.cpp",
+    "LLDBTableGen.cpp",
+    "LLDBTableGenUtils.cpp",
+  ]
+}

diff  --git a/llvm/utils/gn/secondary/lldb/utils/TableGen/lldb_tablegen.gni b/llvm/utils/gn/secondary/lldb/utils/TableGen/lldb_tablegen.gni
new file mode 100644
index 0000000000000..b59faf44e180f
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/utils/TableGen/lldb_tablegen.gni
@@ -0,0 +1,43 @@
+# This file introduces a template for running lldb-tblgen.
+#
+# Parameters:
+#
+#   args (required)
+#       [list of strings] Flags to pass to lldb-tblgen.
+#
+#   output_name (optional)
+#       Basename of the generated output file.
+#       Defaults to target name with ".inc" appended.
+#
+#   td_file (optional)
+#       The .td file to pass to llvm-tblgen.
+#       Defaults to target name with ".td" appended.
+#
+#   visibility (optional)
+#       GN's regular visibility attribute, see `gn help visibility`.
+#
+# Example of usage:
+#
+#   lldb_tablegen("CorePropertiesEnum") {
+#     args = [ "-gen-lldb-property-enum-defs" ]
+#     td_file = "CoreProperties.td"
+#   }
+
+import("//llvm/utils/TableGen/tablegen.gni")
+
+template("lldb_tablegen") {
+  tablegen(target_name) {
+    forward_variables_from(invoker,
+                           [
+                             "output_name",
+                             "td_file",
+                             "visibility",
+                           ])
+
+    args = [
+             #"-I",
+             #rebase_path("//lldb/include", root_build_dir),
+           ] + invoker.args
+    tblgen_target = "//lldb/utils/TableGen:lldb-tblgen"
+  }
+}

diff  --git a/llvm/utils/gn/secondary/lldb/utils/lit-cpuid/BUILD.gn b/llvm/utils/gn/secondary/lldb/utils/lit-cpuid/BUILD.gn
new file mode 100644
index 0000000000000..519c6e1f6de42
--- /dev/null
+++ b/llvm/utils/gn/secondary/lldb/utils/lit-cpuid/BUILD.gn
@@ -0,0 +1,4 @@
+executable("lit-cpuid") {
+  deps = [ "//llvm/lib/Support" ]
+  sources = [ "lit-cpuid.cpp" ]
+}

diff  --git a/llvm/utils/gn/secondary/llvm/utils/llvm-lit/BUILD.gn b/llvm/utils/gn/secondary/llvm/utils/llvm-lit/BUILD.gn
index 16669c4219c93..aa0c5f84c2d9a 100644
--- a/llvm/utils/gn/secondary/llvm/utils/llvm-lit/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/utils/llvm-lit/BUILD.gn
@@ -2,6 +2,7 @@ import("//clang-tools-extra/clangd/test/clangd_lit_site_cfg_files.gni")
 import("//clang-tools-extra/test/clang_tools_extra_lit_site_cfg_files.gni")
 import("//clang/test/clang_lit_site_cfg_files.gni")
 import("//lld/test/lld_lit_site_cfg_files.gni")
+import("//lldb/test/lldb_lit_site_cfg_files.gni")
 import("//llvm/test/llvm_lit_site_cfg_files.gni")
 import("//llvm/utils/gn/build/write_cmake_config.gni")
 import("//llvm/utils/llvm-lit/lit_path_function.gni")
@@ -25,6 +26,10 @@ write_cmake_config("llvm-lit") {
     "//clang/test:lit_unit_site_cfg",
     "//lld/test:lit_site_cfg",
     "//lld/test:lit_unit_site_cfg",
+    "//lldb/test:lit_api_site_cfg",
+    "//lldb/test:lit_shell_site_cfg",
+    "//lldb/test:lit_site_cfg",
+    "//lldb/test:lit_unit_site_cfg",
     "//llvm/test:lit_site_cfg",
     "//llvm/test:lit_unit_site_cfg",
   ]
@@ -62,6 +67,22 @@ write_cmake_config("llvm-lit") {
       "//lld/test/Unit/lit.cfg.py",
       lld_lit_unit_site_cfg_file,
     ],
+    [
+      "//lldb/test/lit.cfg.py",
+      lldb_lit_site_cfg_file,
+    ],
+    [
+      "//lldb/test/API/lit.cfg.py",
+      lldb_lit_api_site_cfg_file,
+    ],
+    [
+      "//lldb/test/Shell/lit.cfg.py",
+      lldb_lit_shell_site_cfg_file,
+    ],
+    [
+      "//lldb/test/Unit/lit.cfg.py",
+      lldb_lit_unit_site_cfg_file,
+    ],
     [
       "//llvm/test/lit.cfg.py",
       llvm_lit_site_cfg_file,


        


More information about the llvm-commits mailing list