Skip to content

Commit 75ddbac

Browse files
committed
[lldb][rpc] Fix build failures when building lldb-rpc-gen
On some cross compile builds, the tool is not correctly set and the command that runs the tool has an empty path for the tool, causing the build to fail. We can setup the tool as a build host tool using setup_host_tool.
1 parent a86ad73 commit 75ddbac

File tree

3 files changed

+12
-21
lines changed

3 files changed

+12
-21
lines changed

lldb/cmake/modules/LLDBConfig.cmake

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -323,30 +323,23 @@ else()
323323
set(LLDB_CAN_USE_DEBUGSERVER OFF)
324324
endif()
325325

326-
# In a cross-compile build, we need to skip building the generated
327-
# lldb-rpc sources in the first phase of host build so that they can
328-
# get built using the just-built Clang toolchain in the second phase.
329326
if (NOT DEFINED LLDB_CAN_USE_LLDB_RPC_SERVER)
330-
set(LLDB_CAN_USE_LLDB_RPC_SERVER OFF)
331-
else()
332-
if ((CMAKE_CROSSCOMPILING OR LLVM_HOST_TRIPLE MATCHES "${LLVM_DEFAULT_TARGET_TRIPLE}") AND
327+
# In a cross-compile build, we don't want to try to build a lldb-rpc-gen, as
328+
# as that essentially forces rebuilding a whole separate native copy of clang.
329+
# Allow the caller to set this variable manually to opt in/out of it.
330+
if (NOT CMAKE_CROSSCOMPILING AND
333331
CMAKE_SYSTEM_NAME MATCHES "AIX|Android|Darwin|FreeBSD|Linux|NetBSD|OpenBSD|Windows")
334332
set(LLDB_CAN_USE_LLDB_RPC_SERVER ON)
335333
else()
336334
set(LLDB_CAN_USE_LLDB_RPC_SERVER OFF)
337335
endif()
338336
endif()
339337

340-
341-
if (NOT DEFINED LLDB_BUILD_LLDBRPC)
342-
set(LLDB_BUILD_LLDBRPC OFF)
338+
if (CMAKE_CROSSCOMPILING)
339+
set(LLDB_BUILD_LLDBRPC OFF CACHE BOOL "")
340+
get_host_tool_path(lldb-rpc-gen LLDB_RPC_GEN_EXE lldb_rpc_gen_exe lldb_rpc_gen_target)
343341
else()
344-
if (CMAKE_CROSSCOMPILING)
345-
set(LLDB_BUILD_LLDBRPC OFF CACHE BOOL "")
346-
get_host_tool_path(lldb-rpc-gen LLDB_RPC_GEN_EXE lldb_rpc_gen_exe lldb_rpc_gen_target)
347-
else()
348-
set(LLDB_BUILD_LLDBRPC ON CACHE BOOL "")
349-
endif()
342+
set(LLDB_BUILD_LLDBRPC ON CACHE BOOL "")
350343
endif()
351344

352345
include(LLDBGenerateConfig)

lldb/tools/lldb-rpc-gen/CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,5 @@ add_lldb_tool(lldb-rpc-gen
1717
LINK_COMPONENTS
1818
Support
1919
)
20-
21-
if (NOT DEFINED LLDB_RPC_GEN_EXE)
22-
set(LLDB_RPC_GEN_EXE $<TARGET_FILE:lldb-rpc-gen> CACHE STRING "Executable that generates lldb-rpc-server")
23-
endif()
20+
add_dependencies(lldb-rpc-gen clang-resource-headers)
21+
setup_host_tool(lldb-rpc-gen LLDB_RPC_GEN_EXE lldb_rpc_gen_exe lldb_rpc_gen_target)

lldb/tools/lldb-rpc/LLDBRPCGeneration.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ add_custom_command(OUTPUT ${lldb_rpc_gen_byproducts}
6060
COMMAND ${CMAKE_COMMAND} -E make_directory
6161
${lldb_rpc_server_generated_source_dir}
6262

63-
COMMAND ${LLDB_RPC_GEN_EXE}
63+
COMMAND ${lldb_rpc_gen_exe}
6464
-p ${CMAKE_BINARY_DIR}
6565
--output-dir=${lldb_rpc_generated_dir}
6666
${sysroot_arg}
6767
--extra-arg="-USWIG"
6868
${api_headers}
6969

70-
DEPENDS ${LLDB_RPC_GEN_EXE} ${api_headers}
70+
DEPENDS ${lldb_rpc_gen_exe} ${api_headers}
7171
COMMENT "Generating sources for lldb-rpc-server..."
7272
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
7373
)

0 commit comments

Comments
 (0)