Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ab98fa0

Browse files
authored
Merge pull request #11378 from swiftlang/cherrypick-missing-rpc-commits
Cherrypick missing LLDB RPC commits
2 parents c440bec + c7fcb14 commit ab98fa0

26 files changed

+934
-32
lines changed

lldb/cmake/modules/LLDBConfig.cmake

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,4 +380,30 @@ else()
380380
set(LLDB_CAN_USE_DEBUGSERVER OFF)
381381
endif()
382382

383+
# In a cross-compile build, we need to skip building the generated
384+
# lldb-rpc sources in the first phase of host build so that they can
385+
# get built using the just-built Clang toolchain in the second phase.
386+
if (NOT DEFINED LLDB_CAN_USE_LLDB_RPC_SERVER)
387+
set(LLDB_CAN_USE_LLDB_RPC_SERVER OFF)
388+
else()
389+
if ((CMAKE_CROSSCOMPILING OR LLVM_HOST_TRIPLE MATCHES "${LLVM_DEFAULT_TARGET_TRIPLE}") AND
390+
CMAKE_SYSTEM_NAME MATCHES "AIX|Android|Darwin|FreeBSD|Linux|NetBSD|OpenBSD|Windows")
391+
set(LLDB_CAN_USE_LLDB_RPC_SERVER ON)
392+
else()
393+
set(LLDB_CAN_USE_LLDB_RPC_SERVER OFF)
394+
endif()
395+
endif()
396+
397+
398+
if (NOT DEFINED LLDB_BUILD_LLDBRPC)
399+
set(LLDB_BUILD_LLDBRPC OFF)
400+
else()
401+
if (CMAKE_CROSSCOMPILING)
402+
set(LLDB_BUILD_LLDBRPC OFF CACHE BOOL "")
403+
get_host_tool_path(lldb-rpc-gen LLDB_RPC_GEN_EXE lldb_rpc_gen_exe lldb_rpc_gen_target)
404+
else()
405+
set(LLDB_BUILD_LLDBRPC ON CACHE BOOL "")
406+
endif()
407+
endif()
408+
383409
include(LLDBGenerateConfig)

lldb/docs/resources/build.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,13 @@ checked out above, but now we will have multiple build-trees:
204204

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

210210
::
211211

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

240243
.. _CommonCMakeOptions:
241244

lldb/scripts/framework-header-fix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def main():
112112
# but passing them in with dashes for this script causes argparse to think that they're
113113
# arguments in and of themself, so they need to passed in without dashes.
114114
if args.unifdef_guards:
115-
unifdef_guards = ["-" + guard for guard in args.unifdef_guards]
115+
unifdef_guards = ["-U" + guard for guard in args.unifdef_guards]
116116

117117
# Create the framework's header dir if it doesn't already exist
118118
if not os.path.exists(os.path.dirname(output_file_path)):

lldb/scripts/framework-header-fix.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

lldb/source/API/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ list(REMOVE_ITEM root_public_headers ${root_private_headers})
336336

337337
find_program(unifdef_EXECUTABLE unifdef)
338338

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

341341
if (LLDB_BUILD_FRAMEWORK)
342342
add_custom_target(lldb-framework-fixup-all-headers)

lldb/test/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ if(TARGET lldb-framework)
134134
add_lldb_test_dependency(lldb-framework)
135135
endif()
136136

137+
if (LLDB_CAN_USE_LLDB_RPC_SERVER)
138+
add_lldb_test_dependency(lldb-rpc-generate-sources)
139+
endif()
140+
137141
# Add dependencies that are not exported targets when building standalone.
138142
if(NOT LLDB_BUILT_STANDALONE)
139143
add_lldb_test_dependency(
@@ -260,7 +264,8 @@ llvm_canonicalize_cmake_booleans(
260264
LLDB_TEST_SHELL_DISABLE_REMOTE
261265
LLDB_TOOL_LLDB_SERVER_BUILD
262266
LLDB_USE_SYSTEM_DEBUGSERVER
263-
LLDB_IS_64_BITS)
267+
LLDB_IS_64_BITS
268+
LLDB_BUILD_LLDBRPC)
264269

265270
# BEGIN SWIFT
266271
llvm_canonicalize_cmake_booleans(

lldb/test/Shell/RPC/Generator/Inputs/SBDummy.h

Whitespace-only changes.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
RUN: %lldb-rpc-gen --output-dir=%t %S/../Inputs/SBDummy.h
2+
3+
RUN: ls %t | FileCheck %s
4+
5+
# We're just making sure that the tool emits the class names,
6+
# methods and skipped methods file in the output directory.
7+
CHECK: SBAPI.def
8+
CHECK: SBClasses.def
9+
CHECK: SkippedMethods.txt
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# All tests for the tool need lldb-rpc-gen to be built.
2+
if not config.lldb_has_lldbrpc:
3+
config.unsupported = True

lldb/test/Shell/Scripts/TestFrameworkFixScript.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Create a temp dir for output and run the framework fix script on the truncated version of SBAddress.h in the inputs dir.
22
RUN: mkdir -p %t/Outputs
3-
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
3+
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
44

55
# Check the output
66
RUN: cat %t/Outputs/SBAddress.h | FileCheck %s

0 commit comments

Comments
 (0)