Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions lldb/cmake/modules/LLDBConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -380,4 +380,30 @@ else()
set(LLDB_CAN_USE_DEBUGSERVER OFF)
endif()

# In a cross-compile build, we need to skip building the generated
# lldb-rpc sources in the first phase of host build so that they can
# get built using the just-built Clang toolchain in the second phase.
if (NOT DEFINED LLDB_CAN_USE_LLDB_RPC_SERVER)
set(LLDB_CAN_USE_LLDB_RPC_SERVER OFF)
else()
if ((CMAKE_CROSSCOMPILING OR LLVM_HOST_TRIPLE MATCHES "${LLVM_DEFAULT_TARGET_TRIPLE}") AND
CMAKE_SYSTEM_NAME MATCHES "AIX|Android|Darwin|FreeBSD|Linux|NetBSD|OpenBSD|Windows")
set(LLDB_CAN_USE_LLDB_RPC_SERVER ON)
else()
set(LLDB_CAN_USE_LLDB_RPC_SERVER OFF)
endif()
endif()


if (NOT DEFINED LLDB_BUILD_LLDBRPC)
set(LLDB_BUILD_LLDBRPC OFF)
else()
if (CMAKE_CROSSCOMPILING)
set(LLDB_BUILD_LLDBRPC OFF CACHE BOOL "")
get_host_tool_path(lldb-rpc-gen LLDB_RPC_GEN_EXE lldb_rpc_gen_exe lldb_rpc_gen_target)
else()
set(LLDB_BUILD_LLDBRPC ON CACHE BOOL "")
endif()
endif()

include(LLDBGenerateConfig)
5 changes: 4 additions & 1 deletion lldb/docs/resources/build.rst
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,13 @@ checked out above, but now we will have multiple build-trees:

Run CMake with ``-B`` pointing to a new directory for the provided
build-tree\ :sup:`1` and the positional argument pointing to the ``llvm``
directory in the source-tree. Note that we leave out LLDB here and only include
directory in the source-tree.\ :sup:`2` Note that we leave out LLDB here and only include
Clang. Then we build the ``ALL`` target with ninja:

::

$ cmake -B /path/to/llvm-build -G Ninja \
-DCMAKE_BUILD_TYPE=[<build type>] \
-DLLVM_ENABLE_PROJECTS=clang \
[<more cmake options>] /path/to/llvm-project/llvm
$ ninja
Expand All @@ -236,6 +237,8 @@ remove it from the Ninja command.
#. The ``-B`` argument was undocumented for a while and is only officially
supported since `CMake version 3.14
<https://cmake.org/cmake/help/v3.14/release/3.14.html#command-line>`_
#. If you want to have a standalone LLDB build with tests enabled, you also
need to pass in ``-DLLVM_ENABLE_RUNTIME='libcxx;libcxxabi;libunwind'`` to your CMake invocation when configuring your LLVM standalone build.

.. _CommonCMakeOptions:

Expand Down
2 changes: 1 addition & 1 deletion lldb/scripts/framework-header-fix.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def main():
# but passing them in with dashes for this script causes argparse to think that they're
# arguments in and of themself, so they need to passed in without dashes.
if args.unifdef_guards:
unifdef_guards = ["-" + guard for guard in args.unifdef_guards]
unifdef_guards = ["-U" + guard for guard in args.unifdef_guards]

# Create the framework's header dir if it doesn't already exist
if not os.path.exists(os.path.dirname(output_file_path)):
Expand Down
11 changes: 0 additions & 11 deletions lldb/scripts/framework-header-fix.sh

This file was deleted.

2 changes: 1 addition & 1 deletion lldb/source/API/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ list(REMOVE_ITEM root_public_headers ${root_private_headers})

find_program(unifdef_EXECUTABLE unifdef)

add_custom_target(liblldb-header-staging DEPENDS ${lldb_staged_headers} ${lldb_header_staging_dir}/lldb-defines.h)
add_custom_target(liblldb-header-staging)

if (LLDB_BUILD_FRAMEWORK)
add_custom_target(lldb-framework-fixup-all-headers)
Expand Down
7 changes: 6 additions & 1 deletion lldb/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ if(TARGET lldb-framework)
add_lldb_test_dependency(lldb-framework)
endif()

if (LLDB_CAN_USE_LLDB_RPC_SERVER)
add_lldb_test_dependency(lldb-rpc-generate-sources)
endif()

# Add dependencies that are not exported targets when building standalone.
if(NOT LLDB_BUILT_STANDALONE)
add_lldb_test_dependency(
Expand Down Expand Up @@ -260,7 +264,8 @@ llvm_canonicalize_cmake_booleans(
LLDB_TEST_SHELL_DISABLE_REMOTE
LLDB_TOOL_LLDB_SERVER_BUILD
LLDB_USE_SYSTEM_DEBUGSERVER
LLDB_IS_64_BITS)
LLDB_IS_64_BITS
LLDB_BUILD_LLDBRPC)

# BEGIN SWIFT
llvm_canonicalize_cmake_booleans(
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
RUN: %lldb-rpc-gen --output-dir=%t %S/../Inputs/SBDummy.h

RUN: ls %t | FileCheck %s

# We're just making sure that the tool emits the class names,
# methods and skipped methods file in the output directory.
CHECK: SBAPI.def
CHECK: SBClasses.def
CHECK: SkippedMethods.txt
3 changes: 3 additions & 0 deletions lldb/test/Shell/RPC/Generator/lit.local.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# All tests for the tool need lldb-rpc-gen to be built.
if not config.lldb_has_lldbrpc:
config.unsupported = True
2 changes: 1 addition & 1 deletion lldb/test/Shell/Scripts/TestFrameworkFixScript.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Create a temp dir for output and run the framework fix script on the truncated version of SBAddress.h in the inputs dir.
RUN: mkdir -p %t/Outputs
RUN: %python %p/../../../scripts/framework-header-fix.py -f lldb_main -i %p/Inputs/Main/SBAddress.h -o %t/Outputs/SBAddress.h -p /usr/bin/unifdef --unifdef_guards USWIG
RUN: %python %p/../../../scripts/framework-header-fix.py -f lldb_main -i %p/Inputs/Main/SBAddress.h -o %t/Outputs/SBAddress.h -p /usr/bin/unifdef --unifdef_guards SWIG

# Check the output
RUN: cat %t/Outputs/SBAddress.h | FileCheck %s
Expand Down
2 changes: 1 addition & 1 deletion lldb/test/Shell/Scripts/TestFrameworkFixUnifdef.test
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# REQUIRES: system-darwin
# Create a temp dir for output and run the framework fix script on the truncated version of SBAddress.h in the inputs dir.
RUN: mkdir -p %t/Outputs
RUN: %python %p/../../../scripts/framework-header-fix.py -f lldb_main -i %p/Inputs/Main/SBAddress.h -o %t/Outputs/SBAddress.h -p /usr/bin/unifdef --unifdef_guards USWIG
RUN: %python %p/../../../scripts/framework-header-fix.py -f lldb_main -i %p/Inputs/Main/SBAddress.h -o %t/Outputs/SBAddress.h -p /usr/bin/unifdef --unifdef_guards SWIG

# Check the output
RUN: cat %t/Outputs/SBAddress.h | FileCheck %s
Expand Down
2 changes: 1 addition & 1 deletion lldb/test/Shell/Scripts/TestRPCFrameworkFixScript.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Create a temp dir for output and run the framework fix script on the truncated version of SBAddress.h in the inputs dir.
RUN: mkdir -p %t/Outputs
RUN: %python %p/../../../scripts/framework-header-fix.py -f lldb_rpc -i %p/Inputs/RPC/RPCSBAddress.h -o %t/Outputs/RPCSBAddress.h -p /usr/bin/unifdef --unifdef_guards USWIG
RUN: %python %p/../../../scripts/framework-header-fix.py -f lldb_rpc -i %p/Inputs/RPC/RPCSBAddress.h -o %t/Outputs/RPCSBAddress.h -p /usr/bin/unifdef --unifdef_guards SWIG

# Check the output
RUN: cat %t/Outputs/RPCSBAddress.h | FileCheck %s
Expand Down
10 changes: 10 additions & 0 deletions lldb/test/Shell/helper/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,16 @@ def use_lldb_substitutions(config):
extra_args=["platform"],
unresolved="ignore",
),
ToolSubst(
"%lldb-rpc-gen",
command=FindTool("lldb-rpc-gen"),
# We need the LLDB build directory root to pass into the tool, not the test build root.
extra_args=[
"-p " + config.lldb_build_directory + "/..",
'--extra-arg="-resource-dir=' + config.clang_resource_dir + '"',
],
unresolved="ignore",
),
"lldb-test",
"lldb-dap",
ToolSubst(
Expand Down
1 change: 1 addition & 0 deletions lldb/test/Shell/lit.site.cfg.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ config.lldb_build_directory = "@LLDB_TEST_BUILD_DIRECTORY@"
config.have_lldb_server = @LLDB_TOOL_LLDB_SERVER_BUILD@
config.lldb_system_debugserver = @LLDB_USE_SYSTEM_DEBUGSERVER@
config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
config.lldb_has_lldbrpc = @LLDB_BUILD_LLDBRPC@
# The shell tests use their own module caches.
config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@", "lldb-shell")
config.clang_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_CLANG@", "lldb-shell")
Expand Down
6 changes: 6 additions & 0 deletions lldb/tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ add_subdirectory(lldb-fuzzer EXCLUDE_FROM_ALL)

add_lldb_tool_subdirectory(lldb-instr)
add_lldb_tool_subdirectory(lldb-dap)
if (LLDB_BUILD_LLDBRPC)
add_lldb_tool_subdirectory(lldb-rpc-gen)
endif()
if (LLDB_CAN_USE_LLDB_RPC_SERVER)
add_subdirectory(lldb-rpc)
endif()

if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_lldb_tool_subdirectory(darwin-debug)
Expand Down
23 changes: 23 additions & 0 deletions lldb/tools/lldb-rpc-gen/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
add_lldb_tool(lldb-rpc-gen
RPCCommon.cpp
server/RPCServerHeaderEmitter.cpp
server/RPCServerSourceEmitter.cpp
lldb-rpc-gen.cpp

CLANG_LIBS
clangAST
clangBasic
clangCodeGen
clangFrontend
clangLex
clangRewrite
clangSerialization
clangTooling

LINK_COMPONENTS
Support
)

if (NOT DEFINED LLDB_RPC_GEN_EXE)
set(LLDB_RPC_GEN_EXE $<TARGET_FILE:lldb-rpc-gen> CACHE STRING "Executable that generates lldb-rpc-server")
endif()
Loading