[Lldb-commits] [lldb] [lldb][rpc] Fix build failures when building lldb-rpc-gen (PR #151603)
Martin Storsjö via lldb-commits
lldb-commits at lists.llvm.org
Fri Aug 1 01:21:19 PDT 2025
================
@@ -18,6 +18,11 @@ add_lldb_tool(lldb-rpc-gen
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")
+if (CMAKE_CROSSCOMPILING)
+ setup_host_tool(lldb-rpc-gen LLDB_RPC_GEN_EXE lldb_rpc_gen_exe lldb_rpc_gen_target)
----------------
mstorsjo wrote:
This doesn't seem right to me. And in actual tests with cross builds, this still hits the same `/bin/sh: 1: -p: not found` error.
We shouldn't need any sort of `if (CMAKE_CROSSCOMPILING)` here at all - we should unconditionally use `setup_host_tool`. That cmake function then internally checks whether it can expect to use the just-built tool, or if it needs to do a nested build to produce a native `lldb-rpc-gen` that can be used instead. Again, have a look at the corresponding clang-tidy case - it doesn't have any such conditionals.
Then after that, you do need to modify the following code that actually _uses_ `lldb-rpc-gen` too. It needs to call the tool `${lldb_rpc_gen_exe}` instead of `$<TARGET_FILE:lldb-rpc-gen>`. This variable then contains the path of the right `lldb-rpc-gen` executable that should be used. And whenever you're using it, you need to add a dependency on `${lldb_rpc_gen_target}`, which is the cmake/ninja target which produces `${lldb_rpc_gen_exe}`, possibly through a nested cmake build.
See https://github.com/llvm/llvm-project/blob/llvmorg-22-init/clang-tools-extra/clang-tidy/misc/CMakeLists.txt#L12-L15 how this is done in the case of clang-tidy. I understand that lldb-rpc-gen is donig something more complicated here, but this needs to be hooked up in one way or another.
https://github.com/llvm/llvm-project/pull/151603
More information about the lldb-commits
mailing list