gn build: Add support for building LLDB on Linux.

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

Differential Revision: https://reviews.llvm.org/D109463
This commit is contained in:
Peter Collingbourne 2021-09-02 13:39:32 -07:00
parent c95a7246a3
commit 9449f441fc
10 changed files with 94 additions and 10 deletions

View File

@ -20,7 +20,7 @@ group("default") {
"//libcxxabi",
]
}
if (current_os == "mac") {
if (current_os == "linux" || current_os == "mac") {
deps += [ "//lldb/test" ]
}
if (current_os == "linux" || current_os == "android") {

View File

@ -12,7 +12,6 @@ write_cmake_config("Config") {
# FIXME: Actual values for everything.
"LLDB_EDITLINE_USE_WCHAR=",
"LLDB_HAVE_EL_RFUNC_T=",
"HAVE_PPOLL=",
"HAVE_PTSNAME_R=",
"HAVE_PROCESS_VM_READV=",
"HAVE_NR_PROCESS_VM_READV=",
@ -44,15 +43,25 @@ write_cmake_config("Config") {
if (current_os == "win") {
values += [
"HAVE_SYS_EVENT_H=",
"LLDB_ENABLE_POSIX=",
"LLDB_ENABLE_TERMIOS=",
]
} else {
values += [
"HAVE_SYS_EVENT_H=1",
"LLDB_ENABLE_POSIX=1",
"LLDB_ENABLE_TERMIOS=1",
]
}
if (current_os == "win" || current_os == "linux" || current_os == "android") {
values += [ "HAVE_SYS_EVENT_H=" ]
} else {
values += [ "HAVE_SYS_EVENT_H=1" ]
}
if (current_os == "linux" || current_os == "android") {
values += [ "HAVE_PPOLL=1" ]
} else {
values += [ "HAVE_PPOLL=" ]
}
}

View File

@ -7,10 +7,12 @@ static_library("Initialization") {
"//lldb/source/Plugins/Process/gdb-remote",
# XXX:
# lldbPluginProcessPOSIX on linux/android
# lldbPluginProcessWindowsCommon on win
"//llvm/lib/Support",
]
if (current_os == "linux" || current_os == "android") {
deps += [ "//lldb/source/Plugins/Process/POSIX" ]
}
# SystemInitializerCommon.cpp includes headers from Plugins/Process/....
include_dirs = [ ".." ]

View File

@ -108,6 +108,10 @@ lldb_plugins += [
"//lldb/source/Plugins/ObjectFile/wasm",
"ObjectFileWasm",
],
[
"//lldb/source/Plugins/Platform/Linux",
"PlatformLinux",
],
[
"//lldb/source/Plugins/Platform/MacOSX",
"PlatformMacOSX",

View File

@ -10,4 +10,6 @@ static_library("JIT") {
"//llvm/lib/Support",
]
sources = [ "ObjectFileJIT.cpp" ]
# For Utility/UuidCompatibility.h.
include_dirs = [ "//lldb/source" ]
}

View File

@ -0,0 +1,18 @@
static_library("Linux") {
output_name = "lldbPluginPlatformLinux"
configs += [
"//llvm/utils/gn/build:clang_code",
"//llvm/utils/gn/build:lldb_code",
]
deps = [
"//lldb/source/Breakpoint",
"//lldb/source/Core",
"//lldb/source/Host",
"//lldb/source/Interpreter",
"//lldb/source/Target",
"//lldb/source/Plugins/Platform/POSIX",
]
# Reaches into Plugins/Platform/POSIX.
include_dirs = [ "//lldb/source" ]
sources = [ "PlatformLinux.cpp" ]
}

View File

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

View File

@ -0,0 +1,17 @@
static_library("POSIX") {
output_name = "lldbPluginProcessPOSIX"
configs += [ "//llvm/utils/gn/build:lldb_code" ]
deps = [
"//lldb/source/Utility",
"//lldb/source/Plugins/Process/Utility",
"//llvm/lib/Support",
]
# Reaches into Plugins/Platform/Process/Utility.
include_dirs = [ "//lldb/source" ]
sources = [
"CrashReason.cpp",
"NativeProcessELF.cpp",
"ProcessMessage.cpp",
"ProcessPOSIXLog.cpp",
]
}

View File

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

View File

@ -29,13 +29,13 @@ executable("lldb-server") {
"//lldb/source/Plugins/Language/CPlusPlus",
]
#if (current_os == "android" || current_os == "linux") {
#deps += [ "//lldb/source/Plugins/Process/Linux" ]
if (current_os == "android" || current_os == "linux") {
deps += [ "//lldb/source/Plugins/Process/Linux" ]
#} else if (current_os == "freebsd") {
#deps += [ "//lldb/source/Plugins/Process/FreeBSD" ]
#} else if (current_os == "netbsd") {
#deps += [ "//lldb/source/Plugins/Process/NetBSD" ]
#}
}
if (current_os == "mac") {
deps += [ "//lldb/source/Plugins/ObjectFile/Mach-O" ]