507 Commits

Author SHA1 Message Date
Shubham Sandeep Rastogi
7f0e70fd2d [CMake] Update CMAKE_OSX_DEPLOYMENT_TARGET to 10.13.
The greendragon standalone bot is complaining about the deployment
target needing to be 10.13 or above. This change makes it 10.13
2025-08-21 15:09:31 -07:00
Jonas Devlieghere
52c9489d1d
[lldb] Use the Python limited API with SWIG 4.2 or later (#153119) (#153472)
Use the Python limited API when building with SWIG 4.2 or later.
2025-08-14 15:28:02 -05:00
Jonas Devlieghere
c681149ea4
Revert "[lldb] Use the Python limited API with SWIG 4.2 or later" (#153327)
Reverts llvm/llvm-project#153119 because with
`LLDB_USE_LIBEDIT_READLINE_COMPAT_MODULE`, we're using
`PyImport_Inittab` which isn't part of the stable API.
2025-08-13 01:13:37 +00:00
Jonas Devlieghere
c14ca4520f
[lldb] Use the Python limited API with SWIG 4.2 or later (#153119)
Use the Python limited API when building with SWIG 4.2 or later.
2025-08-12 19:51:43 -05:00
Jonas Devlieghere
fa39b67de0
[lldb] Add a CMake option to build agains the Python limited API (#152034)
This adds a CMake option (which defaults to OFF) to force building
against the Python limited API. This makes iterating on #151617 easier
and eventually will prevent us from regressing this configuration.
2025-08-05 08:16:36 -07:00
Chelsea Cassanova
67b519577e
[lldb][rpc] Disable building lldb-rpc-gen tool (#150699)
Disabling the lldb-rpc-gen tool while issues with certain builds are
solved: https://github.com/llvm/llvm-project/pull/148996
2025-07-25 15:25:05 -07:00
Chelsea Cassanova
68c8c8ceeb
Reland "[lldb][RPC] Upstream lldb-rpc-gen tool" (#146969)" Attempt 2 (#148996)
Second attempt at relanding the lldb-rpc-gen tool. This should fix 2
issues:

- An assert that was hitting when building on Linux. The assert would
hit in the server source emitter, specifically when attemping to
determine the storage size for a return type is that is a pointer, but
isn't a const char *, const char ** or void pointer.

The assert would hit when attempting to generate
SBAttachInfo::GetProcessPluginName, which returns a const char *
(meaning it shouldn't have been in the code block for the assert at
all). The reason that it was hitting the assert when generating this
function is that lldb_rpc_gen::TypeIsConstCharPtr was returning false
for this function even though it did return a const char *. This was
happening because when checking the return type for a const char *,
TypeIsConstCharPtr would only check that the underlying type was a
signed char. This failed on Linux (but was fine on Darwin), as the
underlying type also needs to be checked for being an unsigned char.

- Cross compiling support

The build for lldb-rpc-gen had no support for cross compiling and as
such, the sources generated for lldb-rpc-gen would get compiled too
early in phase 2 when cross compiling, before the Clang toolchain was
built and this led to an error when trying to include stdlib files. This
reland splits this build into 2 by building the tool first and then
compiling the sources in the second stage of the cross-compiled build.

Original PR Description:
This commit upstreams the lldb-rpc-gen tool, a ClangTool that generates
the LLDB RPC client and server interfaces. This tool, as well as LLDB
RPC itself is built by default. If it needs to be disabled, put
-DLLDB_BUILD_LLDBRPC=OFF in your CMake invocation.

https://discourse.llvm.org/t/rfc-upstreaming-lldb-rpc/85804

Original PR Link:
github.com/llvm/llvm-project/pull/138031
2025-07-23 18:10:16 -07:00
Chelsea Cassanova
d64802d6d9
[lldb][framework] Glob headers from source for framework (#148736)
When gathering the headers to fix up and place in LLDB.framework, we
were previously globbing the header files from a location in the build
directory. This commit changes this to glob from the source directory
instead, as we were globbing from the build directory without ensuring
that the necessary files were actually in that location before globbing.
2025-07-18 15:26:09 -05:00
Chelsea Cassanova
76a841a5e6
Revert "Reland "[lldb][RPC] Upstream lldb-rpc-gen tool" (#146969)" (#147779)
Reverts llvm/llvm-project#147417. Failing an assert:
`lldb-rpc-gen:
../llvm-project/lldb/tools/lldb-rpc/lldb-rpc-gen/server/RPCServerSourceEmitter.cpp:361:
void lldb_rpc_gen::RPCServerSourceEmitter::EmitMethodCallAndEncode(const
Method &): Assertion `Pos != MethodsWithPointerReturnTypes.end() &&
"Unable to determine the size of the return buffer"' failed.`
2025-07-09 09:39:30 -07:00
Chelsea Cassanova
afc82ce3aa
Reland "[lldb][RPC] Upstream lldb-rpc-gen tool" (#146969) (#147417)
Relands the commit to upstream the lldb-rpc-gen tool in order to fix a
build failure on the linux remote bots. The reland adds the Clang
resource dir unconditionally to the invocation for the tool instead of
only adding it in the event that we're using a standalone build.

Original PR description:

This commit upstreams the lldb-rpc-gen tool, a ClangTool that generates
the LLDB RPC client and server interfaces. This tool, as well as LLDB
RPC itself is built by default. If it needs to be disabled, put
-DLLDB_BUILD_LLDBRPC=OFF in your CMake invocation.

https://discourse.llvm.org/t/rfc-upstreaming-lldb-rpc/85804

Original PR Link:

https://github.com/llvm/llvm-project/pull/138031
2025-07-09 09:19:42 -07:00
Chelsea Cassanova
7e04bfbf18
Revert "[lldb][RPC] Upstream lldb-rpc-gen tool" (#146969)
Reverts llvm/llvm-project#138031. This is failing during the build phase
on the Ubuntu buildbot:
```
Error while processing /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/include/lldb/API/SBWatchpoint.h.
[78/78] Processing file /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/include/lldb/API/SBWatchpointOptions.h.
warning: unknown warning option '-Wno-maybe-uninitialized'; did you mean '-Wno-uninitialized'? [-Wunknown-warning-option]
warning: unknown warning option '-Wno-class-memaccess'; did you mean '-Wno-class-varargs'? [-Wunknown-warning-option]
warning: unknown warning option '-Wno-stringop-truncation'; did you mean '-Wno-format-truncation'? [-Wunknown-warning-option]
warning: unknown warning option '-Wno-maybe-uninitialized'; did you mean '-Wno-uninitialized'? [-Wunknown-warning-option]
warning: unknown warning option '-Wno-class-memaccess'; did you mean '-Wno-class-varargs'? [-Wunknown-warning-option]
warning: unknown warning option '-Wno-stringop-truncation'; did you mean '-Wno-format-truncation'? [-Wunknown-warning-option]
In file included from /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/include/lldb/API/SBWatchpointOptions.h:12:
In file included from /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/include/lldb/API/SBDefines.h:12:
In file included from /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/include/lldb/lldb-defines.h:12:
In file included from /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/include/lldb/lldb-types.h:12:
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/include/lldb/lldb-enumerations.h:12:10: fatal error: 'cstdint' file not found
   12 | #include <cstdint>
      |          ^~~~~~~~~
```
2025-07-03 15:53:40 -07:00
Chelsea Cassanova
9bfb347ea0
[lldb][RPC] Upstream lldb-rpc-gen tool (#138031)
This commit upstreams the `lldb-rpc-gen` tool, a ClangTool that
generates the LLDB RPC client and server interfaces. This tool, as well
as LLDB RPC itself is built by default. If it needs to be disabled, put
-DLLDB_BUILD_LLDBRPC=OFF in your CMake invocation.

https://discourse.llvm.org/t/rfc-upstreaming-lldb-rpc/85804
2025-07-03 15:31:17 -07:00
Chelsea Cassanova
45083dc4d2
[lldb][framework] Correctly place framework files in framework with script (#146425)
There's 2 bugs that this commit fixes:
1. Calculate the correct file path for the output file by appending the
basename of the input header instead of appending the entire input
header's path to the framework path.
2. In the script, create the framework's header directory if it does not
exist.
2025-07-03 15:09:15 -07:00
Pavel Labath
46e1e9f104
Reapply "[lldb/cmake] Plugin layering enforcement mechanism (#144543)" (#145305)
The only difference from the original PR are the added BRIEF and
FULL_DOCS arguments to define_property, which are required for
cmake<3.23.
2025-06-24 11:10:35 +02:00
Pavel Labath
18f667d804 Revert "[lldb/cmake] Plugin layering enforcement mechanism (#144543)"
Causes failures on several bots.

This reverts commits 714b2fdf3a385e5b9a95c435f56b1696ec3ec9e8 and
e7c1da7c8ef31c258619c1668062985e7ae83b70.
2025-06-23 12:07:10 +02:00
Pavel Labath
714b2fdf3a [lldb] Add BRIEF_DOCS for cmake properties defined in #144543
It seems some cmake versions require it.
2025-06-23 11:39:20 +02:00
Pavel Labath
e7c1da7c8e
[lldb/cmake] Plugin layering enforcement mechanism (#144543)
Some inter-plugin dependencies are okay, others are not. Yet others not,
but we're sort of stuck with them. The idea is to be able to prevent
backsliding while making sure that acceptable dependencies are..
accepted. For context, see
https://github.com/llvm/llvm-project/pull/139170 and the attached
changes to the documentation.
2025-06-23 11:31:26 +02:00
Jonas Devlieghere
9524bfb270
[lldb] Add Model Context Protocol (MCP) support to LLDB (#143628)
This PR adds an MCP (Model Context Protocol ) server to LLDB. For
motivation and background, please refer to the corresponding RFC:
https://discourse.llvm.org/t/rfc-adding-mcp-support-to-lldb/86798

I implemented this as a new kind of plugin. The idea is that we could
support multiple protocol servers (e.g. if we want to support DAP from
within LLDB). This also introduces a corresponding top-level command
(`protocol-server`) with two subcommands to `start` and `stop` the
server.

```
(lldb) protocol-server start MCP tcp://localhost:1234
MCP server started with connection listeners: connection://[::1]:1234, connection://[127.0.0.1]:1234
```

The MCP sever supports one tool (`lldb_command`) which executes a
command, but can easily be extended with more commands.
2025-06-20 10:48:04 -05:00
Charles Zablit
556e69b7f4
[lldb] make lit use the same Python executable for building and testing (#143756)
When testing LLDB, we want to make sure to use the same Python as the
one we used to build it.

This patch uses the CMake variable `Python3_ROOT_DIR` to add the correct
Python to the `PATH` in LLDB lit tests, in order to ensure of this.

Please see https://github.com/swiftlang/swift/pull/82063 for the
original issue.

This is a continuation of https://github.com/swiftlang/swift/pull/82063.
2025-06-17 11:52:03 -05:00
Chelsea Cassanova
8a8ea8fec0
Reland "[lldb][headers] Create Python script to fix up framework head… (#143945)
…ers" (#143941)

Reland the script that converts lldb headers to RPC headers. The RPC
test was failing due to the incorrect input filepath being used.

Original commit message:
This commit replaces the shell script that fixes up includes for the
LLDB framework with a Python script. This script will also be used when
fixing up includes for the LLDBRPC.framework.
2025-06-12 13:55:44 -07:00
Chelsea Cassanova
06dad352db
Revert "[lldb][headers] Create Python script to fix up framework headers" (#143941)
Reverts llvm/llvm-project#142051
2025-06-12 10:39:53 -07:00
Chelsea Cassanova
1a4cf1d3ed
[lldb][headers] Create Python script to fix up framework headers (#142051)
This commit replaces the shell script that fixes up includes for the
LLDB framework with a Python script. This script will also be used when
fixing up includes for the LLDBRPC.framework.
2025-06-12 10:07:45 -07:00
Pavel Labath
622df892b8
[lldb/cmake] Remove EXTRA_CXXFLAGS arg (#143731)
We have one library using this and three libraries directly calling
`target_compile_options`. Might as well standardize on the latter.
2025-06-12 15:27:27 +02:00
Chelsea Cassanova
eb76d8332e
Reland "[lldb][headers] Create script to fix up versioning" (#142864)" (#142871)
This relands the original commit for the versioning script in LLDB. This
commit uses '>' for output from `unifdef` for platforms that have that
executable but do not have the `-o` option. It also fixes the Xcode
build by adding a dependency between the liblldb-header-staging target
in the source/API/CMakeLists.txt the `liblldb-resource-headers` target
in LLDBFramework.cmake.

Original patch: https://github.com/llvm/llvm-project/pull/141116
2025-06-10 09:47:11 -07:00
Pavel Labath
7e471c1fd0
[lldb/cmake] Use ADDITIONAL_HEADER(_DIR)?S (#142587)
Replace (questionable) header globs with an explicit argument supported
by llvm_add_library.
2025-06-10 11:58:39 +02:00
Pavel Labath
2c4f67794b
[lldb/cmake] Implicitly pass arguments to llvm_add_library (#142583)
If we're not touching them, we don't need to do anything special to pass
them along -- with one important caveat: due to how cmake arguments
work, the implicitly passed arguments need to be specified before
arguments that we handle.

This isn't particularly nice, but the alternative is enumerating all
arguments that can be used by llvm_add_library and the macros it calls
(it also relies on implicit passing of some arguments to
llvm_process_sources).
2025-06-04 11:33:37 +02:00
Fabrice de Gans
a080c741bc
[lldb] Add build option to specify the libxml 2 version (#142183)
The Swift Windows toolchain uses its own static build of libxml 2, which
is more recent than 2.8, resulting in the provided libxml 2 to be
rejected. This change allows to specify a custom version for libxml 2,
while defaulting to 2.8.
2025-05-30 16:21:13 -07:00
Pavel Labath
e3e5bd1cb1
[lldb/cmake] Don't call llvm_process_sources (#141217)
It's already called in llvm_add_library.
2025-05-27 14:32:16 +02:00
Pavel Labath
a4380fe5f9
[lldb/cmake] Remove special handling of OBJECT libraries (#141066)
Nothing in lldb sets this. And even if they did, llvm_add_library should
know how to handle that.
2025-05-23 10:22:59 +02:00
Pavel Labath
f1cf168a6f
[lldb/cmake] Remove a no-op statement (#141063)
Like the comment says, this really is a no-op and has no effect on the
generated build commands.
2025-05-23 09:23:53 +02:00
jeremyd2019
ba4bd3f46e
[CMake] respect LLVMConfig.cmake's LLVM_DEFINITIONS in standalone builds (#138587)
In #138329, _GNU_SOURCE was added for Cygwin, but when building Clang
standalone against an installed LLVM this definition was not picked up,
resulting in undefined strnlen. Follow the documentation in
https://llvm.org/docs/CMake.html#embedding-llvm-in-your-project and add
the LLVM_DEFINITIONS in standalone projects' cmakes.
2025-05-22 08:14:13 +03:00
Chelsea Cassanova
ff8fc5bc45
[lldb][cmake] Add clang resource dir to LLDB shell tests config (#136761)
We want to be able to access the Clang resources directory in LLDB shell
tests, this commit adds the ability to do this by populating the
`CLANG_RESOURCE_DIR` variable in LLDBConfig.cmake.
2025-04-30 10:10:05 -07:00
Dhruv Srivastava
ec95ce358c
[lldb][AIX] Added base files for NativeProcess Support for AIX (#118160)
This PR is in reference to porting LLDB on AIX.

Link to discussions on llvm discourse and github:

1. https://discourse.llvm.org/t/port-lldb-to-ibm-aix/80640
2. https://github.com/llvm/llvm-project/issues/101657
The complete changes for porting are present in this draft PR:
https://github.com/llvm/llvm-project/pull/102601

Added base files for NativeProcess Support for AIX. 
Will be adding further support in consequent incremental PR.
2025-03-14 16:52:41 +05:30
Jordan R AW
bb6a273d9a
[lldb] Fix manual CURSES_LIBRARIES tinfo finding (#128245) 2025-02-22 11:13:46 -06:00
Jordan R AW
8fff0c181f
[lldb] Add terminfo dependency for ncurses support (#126810)
For some operating systems (e.g. chromiumos), terminfo is a separate
package and library from ncurses. Both are still requirements for curses
support in lldb, individually.
    
This is a rework of this original spack commit:

9ea2612650

Instead though, this PR uses CMake to detect whether the symbol is
present and defined in the curses library, and only falls back to a separate
tinfo if not found.
    
Without this fix, LLDB cannot be built on these systems.
    
Fixes #101368
2025-02-14 21:37:39 -08:00
Brad Smith
ff17a4136d
[lldb] Remove support and workarounds for Android 4 and older (#124047) 2025-01-23 12:54:35 -05:00
Brad Smith
1b476ecdcf
[lldb] A few more pieces towards OpenBSD support (#121051) 2024-12-26 08:04:44 -05:00
Saleem Abdulrasool
24593f1814
[lldb] build: cleanup extraneous include paths (#117615)
Clean up some unnecessary include paths. The use of `LibXml2::LibXml2`
with `target_link_libraries` on `libLLDBHost` ensures that the header
search path is properly propagated.
2024-11-27 08:39:15 -08:00
David Spickett
3ce0dbb718
[lldb] Recommend Python 3.8 as the minimum Python version for LLDB (#114807)
See
https://discourse.llvm.org/t/rfc-lets-document-and-enforce-a-minimum-python-version-for-lldb/82731
for discussions.

This matches LLVM's requirement to run tests. For LLDB 20 there will be
a CMake warning telling builders that from LLDB 21 this will be a hard
requirement. From LLDB 21, it will be an error to try to build with
anything <= 3.8.

So there are no code changes in this commit. Once the llvm 20 branch is
created we can remove some < 3.8 support code.

As always, if you disable Python support you will not get any new
warnings or errors from this change.
2024-11-12 10:49:16 +00:00
Jonas Devlieghere
e19d740169
[lldb] Support both Lua 5.3 and Lua 5.4 (#115500)
Lua 5.3 and Lua 5.4 are similar enough that we can easily support both
in LLDB. This patch adds support for building LLDB with both and updates
the documentation accordingly.
2024-11-11 08:11:03 -08:00
Jonas Devlieghere
4897fc44a9
[lldb] Narrow scope of -Wno-deprecated-declarations (NFC) (#112276)
Currently all of LLDB is being compiled with
-Wno-deprecated-declarations. That's not desirable, especially as part
of the LLVM monorepo, as we miss deprecation warnings from LLVM and
clang.

According to the git history, this was first introduced to suppress
warnings related to auto_ptr. Since then, other things have been
deprecated and gone unnoticed. This patch limits the flag to Host.mm
which uses a handful of LSApplication headers that have no replacement.

rdar://112040718
2024-10-17 08:22:56 -07:00
Jon Roelofs
a982cabea3
[cmake][llvm] Limit the number of Xcode schemes created by default (#101243)
CMake -GXcode would otherwise offer to create one scheme for each
target, which ends up being a lot. For now, limit the default to the
`check-*` LIT targets, plus `ALL_BUILD` and `install`.

For targets that aren't in the default list, we now have a configuration
variable to promote an extra list of targets into schemes, for example
`-DLLVM_XCODE_EXTRA_TARGET_SCHEMES="TargetParserTests;SupportTests"` to
add schemes for `TargetParserTests` and `SupportTests` respectively.
2024-07-30 17:17:04 -07:00
Vlad Serebrennikov
cd676e5b27 [lldb] Guard some GCC-style flags from MSVC
A follow up to #92953. Suggested in https://github.com/llvm/llvm-project/pull/92953#issuecomment-2143274065
2024-06-01 12:48:12 +03:00
Michael Kruse
c3efb57655
[lldb] Revise IDE folder structure (#89748)
Update the folder titles for targets in the monorepository that have not
seen taken care of for some time. These are the folders that targets are
organized in Visual Studio and XCode
(`set_property(TARGET <target> PROPERTY FOLDER "<title>")`)
when using the respective CMake's IDE generator.

 * Ensure that every target is in a folder
 * Use a folder hierarchy with each LLVM subproject as a top-level folder
 * Use consistent folder names between subprojects
 * When using target-creating functions from AddLLVM.cmake, automatically
deduce the folder. This reduces the number of
`set_property`/`set_target_property`, but are still necessary when
`add_custom_target`, `add_executable`, `add_library`, etc. are used. A
LLVM_SUBPROJECT_TITLE definition is used for that in each subproject's
root CMakeLists.txt.
2024-05-25 17:29:18 +02:00
Vlad Serebrennikov
4feae05c6a
Remove some try_compile CMake checks for compiler flags (#92953)
This patch remove 36 checks for compiler flags that are done via
invoking the compiler across LLVM, Clang, and LLDB. It's was made
possible by raising the bar for supported compilers that has been
happening over the years since the checks were added.

This is going to improve CMake configuration times. This topic was
highlighted in
https://discourse.llvm.org/t/cmake-compiler-flag-checks-are-really-slow-ideas-to-speed-them-up/78882.
2024-05-23 17:05:41 +04:00
Adrian Prantl
fcfc15b705
Add a dependency from lldb-sbapi-dwarf-enums as a dependency of libll… (#91511)
…db-resource-headers

The Xcode build otherwise fails with
```
CMake Error in source/API/CMakeLists.txt:
  The custom command generating

    /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-standalone/lldb-xcode-build/include/lldb/API/SBLanguages.h

  is attached to multiple targets:

    lldb-sbapi-dwarf-enums
    liblldb-resource-headers

  but none of these is a common dependency of the other(s).  This is not
  allowed by the Xcode "new build system".

CMake Generate step failed.  Build files cannot be regenerated correctly.
```
2024-05-08 10:38:09 -07:00
Adrian Prantl
b88d21127f
Install generated API headers into LLDB.framework (#90666) 2024-05-01 12:47:43 -07:00
Jordan Rupprecht
0e5c28d193
[lldb][test] Remove LLDB_TEST_USE_VENDOR_PACKAGES (#89260)
The `LLDB_TEST_USE_VENDOR_PACKAGES` has defaulted to `Off` for a while.
Either installing `pexpect` or skipping those tests with
`-DLLDB_TEST_USER_ARGS=--skip-category=pexpect` seems to be enough that
we can fully remove this option.

This patch removes the `LLDB_TEST_USE_VENDOR_PACKAGES` cmake
configuration as well as the associated code to add
`third_party/Python/module` to the python path. I'll do the actual
deletion of `third_party/Python/module` in a followup PR in the
(unlikely, I hope) event this commit needs to be reverted.
2024-04-18 13:17:39 -05:00
Jonas Devlieghere
a855eea7fe
[lldb] Fix the standalone Xcode build after #88317
In #88317, the clang resource headers was converted to an interface
library. Update LLDB and fix the Xcode standalone build. Thanks Evan for
the help!
2024-04-15 14:08:56 -07:00
Adam Fowler
2c2377d3a9
Add lldb-dap to Swift distributions (#88482)
This includes the lldb-dap executable in the MacOS and Linux
distributions of Swift. Currently there is a commit in the Apple repo to
do this for just MacOS https://github.com/apple/llvm-project/pull/8176.
This PR extends this to both Linux and MacOS and brings the change
upstream.

@JDevlieghere @adrian-prantl
2024-04-12 07:39:22 -07:00