7 Please refer to the `LLVM Getting Started Guide
8 <https://llvm.org/docs/GettingStarted.html#getting-started-with-llvm>`_ for
9 general instructions on how to check out the LLVM monorepo, which contains the
12 Git browser: https://github.com/llvm/llvm-project/tree/main/lldb
17 LLDB relies on many of the technologies developed by the larger LLVM project.
18 In particular, it requires both Clang and LLVM itself in order to build. Due to
19 this tight integration the Getting Started guides for both of these projects
20 come as prerequisite reading:
22 * `LLVM <https://llvm.org/docs/GettingStarted.html>`_
23 * `Clang <http://clang.llvm.org/get_started.html>`_
25 The following requirements are shared on all platforms.
27 * `CMake <https://cmake.org>`_
28 * `Ninja <https://ninja-build.org>`_ (strongly recommended)
30 If you want to run the test suite, you'll need to build LLDB with Python
33 * `Python <http://www.python.org/>`_
34 * `SWIG <http://swig.org/>`_ 4 or later.
36 .. _Optional Dependencies:
41 Although the following dependencies are optional, they have a big impact on
42 LLDB's functionality. It is strongly encouraged to build LLDB with these
45 By default they are auto-detected: if CMake can find the dependency it will be
46 used. It is possible to override this behavior by setting the corresponding
47 CMake flag to ``On`` or ``Off`` to force the dependency to be enabled or
48 disabled. When a dependency is set to ``On`` and can't be found it will cause a
49 CMake configuration error.
51 +-------------------+------------------------------------------------------+--------------------------+
52 | Feature | Description | CMake Flag |
53 +===================+======================================================+==========================+
54 | Editline | Generic line editing, history, Emacs and Vi bindings | ``LLDB_ENABLE_LIBEDIT`` |
55 +-------------------+------------------------------------------------------+--------------------------+
56 | Curses | Text user interface | ``LLDB_ENABLE_CURSES`` |
57 +-------------------+------------------------------------------------------+--------------------------+
58 | LZMA | Lossless data compression | ``LLDB_ENABLE_LZMA`` |
59 +-------------------+------------------------------------------------------+--------------------------+
60 | Libxml2 | XML | ``LLDB_ENABLE_LIBXML2`` |
61 +-------------------+------------------------------------------------------+--------------------------+
62 | Python | Python scripting | ``LLDB_ENABLE_PYTHON`` |
63 +-------------------+------------------------------------------------------+--------------------------+
64 | Lua | Lua scripting | ``LLDB_ENABLE_LUA`` |
65 +-------------------+------------------------------------------------------+--------------------------+
67 Depending on your platform and package manager, one might run any of the
72 $ yum install libedit-devel libxml2-devel ncurses-devel python-devel swig
73 $ sudo apt-get install build-essential swig python3-dev libedit-dev libncurses5-dev
74 $ pkg install swig python
75 $ pkgin install swig python36 cmake ninja-build
76 $ brew install swig cmake ninja
78 Note that there's an `incompatibility
79 <https://github.com/swig/swig/issues/1321>`_ between Python version 3.7 and later
80 and swig versions older than 4.0.0 which makes builds of LLDB using debug
81 versions of python unusable. This primarily affects Windows, as debug builds of
82 LLDB must use debug python as well.
89 * The latest Windows SDK.
90 * The Active Template Library (ATL).
91 * `GnuWin32 <http://gnuwin32.sourceforge.net/>`_ for CoreUtils and Make.
92 * `Python 3 <https://www.python.org/downloads/windows/>`_. Make sure to (1) get
93 the x64 variant if that's what you're targetting and (2) install the debug
94 library if you want to build a debug lldb. The standalone installer is the
95 easiest way to get the debug library.
96 * `Python Tools for Visual Studio
97 <https://github.com/Microsoft/PTVS/>`_. If you plan to debug test failures
98 or even write new tests at all, PTVS is an indispensable debugging
99 extension to VS that enables full editing and debugging support for Python
100 (including mixed native/managed debugging).
101 * `SWIG for Windows <http://www.swig.org/download.html>`_
103 The steps outlined here describes how to set up your system and install the
104 required dependencies such that they can be found when needed during the build
105 process. They only need to be performed once.
107 #. Install Visual Studio with the "Desktop Development with C++" workload and
108 the "Python Development" workload.
109 #. Install GnuWin32, making sure ``<GnuWin32 install dir>\bin`` is added to
110 your PATH environment variable. Verify that utilities like ``dirname`` and
111 ``make`` are available from your terminal.
112 #. Install SWIG for Windows, making sure ``<SWIG install dir>`` is added to
113 your PATH environment variable. Verify that ``swig`` is available from your
115 #. Install Python 3 from the standalone installer and include the debug libraries
116 in the install, making sure the Python install path is added to your PATH
117 environment variable.
118 #. Register the Debug Interface Access DLLs with the Registry from a privileged
123 > regsvr32 "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\DIA SDK\bin\msdia140.dll"
124 > regsvr32 "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\DIA SDK\bin\amd64\msdia140.dll"
126 Any command prompt from which you build LLDB should have a valid Visual Studio
127 environment setup. This means you should open an appropriate `Developer Command
128 Prompt for VS <https://docs.microsoft.com/en-us/visualstudio/ide/reference/command-prompt-powershell?view=vs-2019>`_
129 corresponding to the version you wish to use or run ``vcvarsall.bat`` or
135 * To use the in-tree debug server on macOS, lldb needs to be code signed. For
136 more information see :ref:`CodeSigning` below.
137 * If you are building both Clang and LLDB together, be sure to also check out
138 libc++, which is a required for testing on macOS.
140 Building LLDB with CMake
141 ------------------------
143 The LLVM project is migrating to a single monolithic repository for LLVM and
144 its subprojects. This is the recommended way to build LLDB. Check out the
145 source-tree with git:
149 $ git clone https://github.com/llvm/llvm-project.git
151 CMake is a cross-platform build-generator tool. CMake does not build the
152 project, it generates the files needed by your build tool. The recommended
153 build tool for LLVM is Ninja, but other generators like Xcode or Visual Studio
154 may be used as well. Please also read `Building LLVM with CMake
155 <https://llvm.org/docs/CMake.html>`_.
157 Regular in-tree builds
158 **********************
160 Create a new directory for your build-tree. From there run CMake and point it
161 to the ``llvm`` directory in the source-tree:
165 $ cmake -G Ninja -DLLVM_ENABLE_PROJECTS="clang;lldb" [<cmake options>] path/to/llvm-project/llvm
167 We used the ``LLVM_ENABLE_PROJECTS`` option here to tell the build-system which
168 subprojects to build in addition to LLVM (for more options see
169 :ref:`CommonCMakeOptions` and :ref:`CMakeCaches`). Parts of the LLDB test suite
170 require ``lld``. Add it to the list in order to run all tests. Once CMake is done,
171 run ninja to perform the actual build.
175 $ ninja lldb lldb-server
177 If you only want lldb, or are on a platform where lldb-server is not supported,
178 you can pass just ``lldb``. Ninja will only build what is necessary to run the
188 This is another way to build LLDB. We can use the same source-tree as we
189 checked out above, but now we will have multiple build-trees:
191 * the main build-tree for LLDB in ``/path/to/lldb-build``
192 * one or more provided build-trees for LLVM and Clang; for simplicity we use a
193 single one in ``/path/to/llvm-build``
195 Run CMake with ``-B`` pointing to a new directory for the provided
196 build-tree\ :sup:`1` and the positional argument pointing to the ``llvm``
197 directory in the source-tree. Note that we leave out LLDB here and only include
198 Clang. Then we build the ``ALL`` target with ninja:
202 $ cmake -B /path/to/llvm-build -G Ninja \
203 -DLLVM_ENABLE_PROJECTS=clang \
204 [<more cmake options>] /path/to/llvm-project/llvm
207 Now run CMake a second time with ``-B`` pointing to a new directory for the
208 main build-tree and the positional argument pointing to the ``lldb`` directory
209 in the source-tree. In order to find the provided build-tree, the build system
210 looks for the path to its CMake modules in ``LLVM_DIR``. If you use a separate
211 build directory for Clang, remember to pass its module path via ``Clang_DIR``
212 (CMake variables are case-sensitive!):
216 $ cmake -B /path/to/lldb-build -G Ninja \
217 -DLLVM_DIR=/path/to/llvm-build/lib/cmake/llvm \
218 [<more cmake options>] /path/to/llvm-project/lldb
219 $ ninja lldb lldb-server
221 If you do not require or cannot build ``lldb-server`` on your platform, simply
222 remove it from the Ninja command.
226 #. The ``-B`` argument was undocumented for a while and is only officially
227 supported since `CMake version 3.14
228 <https://cmake.org/cmake/help/v3.14/release/3.14.html#command-line>`_
230 .. _CommonCMakeOptions:
235 Following is a description of some of the most important CMake variables which
236 you are likely to encounter. A variable FOO is set by adding ``-DFOO=value`` to
237 the CMake command line.
239 If you want to debug the lldb that you're building -- that is, build it with
240 debug info enabled -- pass two additional arguments to cmake before running
246 -DLLDB_EXPORT_ALL_SYMBOLS=1 \
247 -DCMAKE_BUILD_TYPE=Debug
248 <path to root of llvm source tree>
250 If you want to run the test suite, you will need a compiler to build the test
251 programs. If you have Clang checked out, that will be used by default.
252 Alternatively, you can specify a C and C++ compiler to be used by the test
258 -DLLDB_TEST_COMPILER=<path to C compiler> \
259 <path to root of llvm source tree>
261 It is strongly recommend to use a release build for the compiler to speed up
267 On Windows the LLDB test suite requires lld. Either add ``lld`` to
268 ``LLVM_ENABLE_PROJECTS`` or disable the test suite with
269 ``LLDB_INCLUDE_TESTS=OFF``.
271 Although the following CMake variables are by no means Windows specific, they
272 are commonly used on Windows.
274 * ``LLDB_TEST_DEBUG_TEST_CRASHES`` (Default=0): If set to 1, will cause Windows
275 to generate a crash dialog whenever lldb.exe or the python extension module
276 crashes while running the test suite. If set to 0, LLDB will silently crash.
277 Setting to 1 allows a developer to attach a JIT debugger at the time of a
278 crash, rather than having to reproduce a failure or use a crash dump.
279 * ``PYTHON_HOME`` (Required): Path to the folder where the Python distribution
280 is installed. For example, ``C:\Python35``.
281 * ``LLDB_RELOCATABLE_PYTHON`` (Default=0): When this is 0, LLDB will bind
282 statically to the location specified in the ``PYTHON_HOME`` CMake variable,
283 ignoring any value of ``PYTHONHOME`` set in the environment. This is most
284 useful for developers who simply want to run LLDB after they build it. If you
285 wish to move a build of LLDB to a different machine where Python will be in a
286 different location, setting ``LLDB_RELOCATABLE_PYTHON`` to 1 will cause
287 Python to use its default mechanism for finding the python installation at
288 runtime (looking for installed Pythons, or using the ``PYTHONHOME``
289 environment variable if it is specified).
296 -DLLDB_TEST_DEBUG_TEST_CRASHES=1^
297 -DPYTHON_HOME=C:\Python35^
298 -DLLDB_TEST_COMPILER=d:\src\llvmbuild\ninja_release\bin\clang.exe^
299 <path to root of llvm source tree>
302 Building with ninja is both faster and simpler than building with Visual Studio,
303 but chances are you still want to debug LLDB with an IDE. One solution is to run
304 cmake twice and generate the output into two different folders. One for
305 compiling (the ninja folder), and one for editing, browsing and debugging.
307 Follow the previous instructions in one directory, and generate a Visual Studio
308 project in another directory.
312 $ cmake -G "Visual Studio 16 2019" -A x64 -T host=x64 <cmake variables> <path to root of llvm source tree>
314 Then you can open the .sln file in Visual Studio, set lldb as the startup
315 project, and use F5 to run it. You need only edit the project settings to set
316 the executable and the working directory to point to binaries inside of the
323 On macOS the LLDB test suite requires libc++. Either add
324 ``LLVM_ENABLE_RUNTIMES="libcxx;libcxxabi"`` or disable the test suite with
325 ``LLDB_INCLUDE_TESTS=OFF``. Further useful options:
327 * ``LLDB_BUILD_FRAMEWORK:BOOL``: Builds the LLDB.framework.
328 * ``LLDB_CODESIGN_IDENTITY:STRING``: Set the identity to use for code-signing
329 all executables. If not explicitly specified, only ``debugserver`` will be
330 code-signed with identity ``lldb_codesign`` (see :ref:`CodeSigning`).
331 * ``LLDB_USE_SYSTEM_DEBUGSERVER:BOOL``: Use the system's debugserver, so lldb is
332 functional without setting up code-signing.
340 CMake caches allow to store common sets of configuration options in the form of
341 CMake scripts and can be useful to reproduce builds for particular use-cases
342 (see by analogy `usage in LLVM and Clang <https://llvm.org/docs/AdvancedBuilds.html>`_).
343 A cache is passed to CMake with the ``-C`` flag, following the absolute path to
344 the file on disk. Subsequent ``-D`` options are still allowed. Please find the
345 currently available caches in the `lldb/cmake/caches/
346 <https://github.com/llvm/llvm-project/tree/main/lldb/cmake/caches>`_
349 Common configurations on macOS
350 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
352 Build, test and install a distribution of LLDB from the `monorepo
353 <https://github.com/llvm/llvm-project>`_ (see also `Building a Distribution of
354 LLVM <https://llvm.org/docs/BuildingADistribution.html>`_):
358 $ git clone https://github.com/llvm/llvm-project
360 $ cmake -B /path/to/lldb-build -G Ninja \
361 -C /path/to/llvm-project/lldb/cmake/caches/Apple-lldb-macOS.cmake \
362 -DLLVM_ENABLE_PROJECTS="clang;lldb" \
363 -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \
366 $ DESTDIR=/path/to/lldb-install ninja -C /path/to/lldb-build check-lldb install-distribution
368 .. _CMakeGeneratedXcodeProject:
370 Build LLDB standalone for development with Xcode:
374 $ git clone https://github.com/llvm/llvm-project
376 $ cmake -B /path/to/llvm-build -G Ninja \
377 -C /path/to/llvm-project/lldb/cmake/caches/Apple-lldb-base.cmake \
378 -DLLVM_ENABLE_PROJECTS="clang" \
379 -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \
381 $ ninja -C /path/to/llvm-build
383 $ cmake -B /path/to/lldb-build \
384 -C /path/to/llvm-project/lldb/cmake/caches/Apple-lldb-Xcode.cmake \
385 -DLLVM_DIR=/path/to/llvm-build/lib/cmake/llvm \
387 $ open lldb.xcodeproj
388 $ cmake --build /path/to/lldb-build --target check-lldb
392 The ``-B`` argument was undocumented for a while and is only officially
393 supported since `CMake version 3.14
394 <https://cmake.org/cmake/help/v3.14/release/3.14.html#command-line>`_
397 Building the Documentation
398 --------------------------
400 If you wish to build the optional (reference) documentation, additional
401 dependencies are required:
403 * Sphinx (for the website and the Python API reference)
404 * Graphviz (for the 'dot' tool)
405 * doxygen (if you wish to build the C++ API reference)
406 * SWIG (for generating Python bindings)
408 To install the system prerequisites for building the documentation (on Debian/Ubuntu)
413 $ sudo apt-get install doxygen graphviz swig
415 To install Sphinx and its dependencies, use the ``requirements.txt`` available within LLVM
416 to ensure you get a working configuration:
420 $ pip3 install -r /path/to/llvm-project/llvm/docs/requirements.txt
422 To build the documentation, configure with ``LLVM_ENABLE_SPHINX=ON`` and build the desired target(s).
426 $ ninja docs-lldb-html
427 $ ninja docs-lldb-man
433 The advice presented here may not be complete or represent the best practices
434 of CMake at this time. Please refer to `CMake's documentation <https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html>`_
435 if you have any doubts or want more in depth information.
437 In order to debug remote targets running different architectures than your
438 host, you will need to compile LLDB (or at least the server component
439 ``lldb-server``) for the target. While the easiest solution is to compile it
440 locally on the target, this is often not feasible, and in these cases you will
441 need to cross-compile LLDB on your host.
443 Cross-compilation is often a daunting task and has a lot of quirks which depend
444 on the exact host and target architectures, so it is not possible to give a
445 universal guide which will work on all platforms. However, here we try to
446 provide an overview of the cross-compilation process along with the main things
447 you should look out for.
449 First, you will need a working toolchain which is capable of producing binaries
450 for the target architecture. Since you already have a checkout of clang and
451 lldb, you can compile a host version of clang in a separate folder and use
452 that. Alternatively you can use system clang or even cross-gcc if your
453 distribution provides such packages (e.g., ``g++-aarch64-linux-gnu`` on
456 Next, you will need a copy of the required target headers and libraries on your
457 host. The libraries can be usually obtained by copying from the target machine,
458 however the headers are often not found there, especially in case of embedded
459 platforms. In this case, you will need to obtain them from another source,
460 either a cross-package if one is available, or cross-compiling the respective
461 library from source. Fortunately the list of LLDB dependencies is not big and
462 if you are only interested in the server component, you can reduce this even
463 further by passing the appropriate cmake options, such as:
467 -DLLDB_ENABLE_PYTHON=0
468 -DLLDB_ENABLE_LIBEDIT=0
469 -DLLDB_ENABLE_CURSES=0
470 -DLLVM_ENABLE_TERMINFO=0
472 (see :ref:`Optional Dependencies` for more)
474 In this case you, will often not need anything other than the standard C and
477 If you find that CMake is finding a version of an optional dependency that
478 for whatever reason doesn't work, consider simply disabling it if you don't
479 know that you need it.
481 Once all of the dependencies are in place, you need to configure the build
482 system with the locations and arguments of all the necessary tools.
484 There are 2 ways to do this depending on your starting point and requirements.
486 1. If you are starting from scratch and only need the resulting cross compiled
487 binaries, you can have LLVM build the native tools for you.
489 2. If you need a host build too, or already have one, you can tell CMake where
490 that is and it will use those native tools instead.
492 If you are going to run ``lldb`` and ``lldb-server`` only on the target machine,
493 choose option 1. If you are going to run ``lldb`` on the host machine and
494 connect to ``lldb-server`` on the target, choose option 2.
496 Either way, the most important cmake options when cross-compiling are:
498 * ``CMAKE_SYSTEM_NAME`` and ``CMAKE_SYSTEM_PROCESSOR``: This tells CMake what
499 the build target is and from this it will infer that you are cross compiling.
500 * ``CMAKE_C_COMPILER``, ``CMAKE_CXX_COMPILER`` : C and C++ compilers for the
502 * ``CMAKE_C_FLAGS``, ``CMAKE_CXX_FLAGS`` : The flags for the C and C++ target
503 compilers. You may need to specify the exact target cpu and ABI besides the
504 include paths for the target headers.
505 * ``CMAKE_EXE_LINKER_FLAGS`` : The flags to be passed to the linker. Usually
506 this is a list of library search paths referencing the target libraries.
507 * ``LLVM_HOST_TRIPLE`` : The triple of the system that lldb (or lldb-server)
508 will run on. Not setting this (or setting it incorrectly) can cause a lot of
509 issues with remote debugging as a lot of the choices lldb makes depend on the
510 triple reported by the remote platform.
511 * ``LLVM_NATIVE_TOOL_DIR`` (only when using an existing host build): Is a
512 path to the llvm tools compiled for the host. Any tool that must be run on the
513 host during a cross build will be configured from this path, so you do not
514 need to set them all individually. If you are doing a host build only for the
515 purpose of a cross build, you will need it to include at least
516 ``llvm-tblgen``, ``clang-tblgen`` and ``lldb-tblgen``. Be aware that
517 the list may grow over time.
518 * ``CMAKE_LIBRARY_ARCHITECTURE`` : Affects the cmake search path when looking
519 for libraries. You may need to set this to your architecture triple if you do
520 not specify all your include and library paths explicitly.
522 To find the possible values of the ``CMAKE_*`` options, please refer to the
525 You can of course also specify the usual cmake options like
526 ``CMAKE_BUILD_TYPE``, etc.
528 For testing, you may want to set one of:
530 * ``LLDB_TEST_COMPILER`` : The compiler used to build programs used
531 in the test suite. If you are also building clang, this will be used
532 but if you want to test remotely from the host, you should choose the
533 cross compiler you are using for the cross build.
534 * ``LLDB_INCLUDE_TESTS=0`` : To disable the tests completely.
536 Example 1: Cross-compiling for linux arm64 on Ubuntu host
537 *********************************************************
539 Ubuntu already provides the packages necessary to cross-compile LLDB for arm64.
540 It is sufficient to install packages ``gcc-aarch64-linux-gnu``,
541 ``g++-aarch64-linux-gnu``, ``binutils-aarch64-linux-gnu``.
543 Configure as follows:
547 cmake <path-to-monorepo>/llvm-project/llvm -G Ninja \
548 -DCMAKE_BUILD_TYPE=Release \
549 -DLLVM_ENABLE_PROJECTS="clang;lld;lldb" \
550 -DCMAKE_SYSTEM_NAME=Linux \
551 -DCMAKE_SYSTEM_PROCESSOR=AArch64 \
552 -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
553 -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \
554 -DLLVM_HOST_TRIPLE=aarch64-unknown-linux-gnu \
555 -DLLDB_ENABLE_PYTHON=0 \
556 -DLLDB_ENABLE_LIBEDIT=0 \
557 -DLLDB_ENABLE_CURSES=0
559 During this build native tools will be built automatically when they are needed.
560 The contents of ``<build dir>/bin`` will be target binaries as you'd expect.
561 AArch64 binaries in this case.
563 Example 2: Cross-compiling for linux arm64 on Ubuntu host using an existing host build
564 **************************************************************************************
566 This build requires an existing host build that includes the required native
567 tools. Install the compiler as in example 1 then run CMake as follows:
571 cmake <path-to-monorepo>/llvm-project/llvm -G Ninja \
572 -DCMAKE_BUILD_TYPE=Release \
573 -DLLVM_ENABLE_PROJECTS="clang;lld;lldb" \
574 -DCMAKE_SYSTEM_NAME=Linux \
575 -DCMAKE_SYSTEM_PROCESSOR=AArch64 \
576 -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
577 -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \
578 -DLLVM_HOST_TRIPLE=aarch64-unknown-linux-gnu \
579 -DLLVM_NATIVE_TOOL_DIR=<path-to-host>/bin/ \
580 -DLLDB_ENABLE_PYTHON=0 \
581 -DLLDB_ENABLE_LIBEDIT=0 \
582 -DLLDB_ENABLE_CURSES=0
584 The only difference from example 1 is the addition of
585 ``DLLVM_NATIVE_TOOL_DIR`` pointing to your existing host build.
587 An alternative (and recommended) way to compile LLDB is with clang.
588 Unfortunately, clang is not able to find all the include paths necessary for a
589 successful cross-compile, so we need to help it with a couple of CFLAGS
590 options. In my case it was sufficient to add the following arguments to
591 ``CMAKE_C_FLAGS`` and ``CMAKE_CXX_FLAGS`` (in addition to changing
592 ``CMAKE_C(XX)_COMPILER`` to point to clang compilers):
596 -target aarch64-linux-gnu \
597 -I /usr/aarch64-linux-gnu/include/c++/4.8.2/aarch64-linux-gnu \
598 -I /usr/aarch64-linux-gnu/include
600 If you wanted to build a full version of LLDB and avoid passing
601 ``-DLLDB_ENABLE_PYTHON=0`` and other options, you would need to obtain the
602 target versions of the respective libraries. The easiest way to achieve this is
603 to use the qemu-debootstrap utility, which can prepare a system image using
604 qemu and chroot to simulate the target environment. Then you can install the
605 necessary packages in this environment (python-dev, libedit-dev, etc.) and
606 point your compiler to use them using the correct -I and -L arguments.
608 Example 3: Cross-compiling for Android on Linux
609 ***********************************************
611 In the case of Android, the toolchain and all required headers and libraries
612 are available in the Android NDK.
614 The NDK also contains a cmake toolchain file, which makes configuring the build
615 much simpler. The compiler, include and library paths will be configured by the
616 toolchain file and all you need to do is to select the architecture
617 (ANDROID_ABI) and platform level (``ANDROID_PLATFORM``, should be at least 21).
618 You will also need to set ``ANDROID_ALLOW_UNDEFINED_SYMBOLS=On``, as the
619 toolchain file defaults to "no undefined symbols in shared libraries", which is
620 not compatible with some llvm libraries. The first version of NDK which
621 supports this approach is r14.
623 For example, the following arguments are sufficient to configure an android
628 -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake \
629 -DANDROID_ABI=arm64-v8a \
630 -DANDROID_PLATFORM=android-21 \
631 -DANDROID_ALLOW_UNDEFINED_SYMBOLS=On \
632 -DLLVM_HOST_TRIPLE=aarch64-unknown-linux-android \
633 -DCROSS_TOOLCHAIN_FLAGS_NATIVE='-DCMAKE_C_COMPILER=cc;-DCMAKE_CXX_COMPILER=c++'
635 Note that currently only lldb-server is functional on android. The lldb client
636 is not supported and unlikely to work.
638 Verifying Python Support
639 ------------------------
641 LLDB has a Python scripting capability and supplies its own Python module named
642 lldb. If a script is run inside the command line lldb application, the Python
643 module is made available automatically. However, if a script is to be run by a
644 Python interpreter outside the command line application, the ``PYTHONPATH``
645 environment variable can be used to let the Python interpreter find the lldb
648 The correct path can be obtained by invoking the command line lldb tool with
653 $ export PYTHONPATH=`$llvm/build/Debug+Asserts/bin/lldb -P`
655 If you used a different build directory or made a release build, you may need
656 to adjust the above to suit your needs. To test that the lldb Python module is
657 built correctly and is available to the default Python interpreter, run:
661 $ python -c 'import lldb'
664 Make sure you're using the Python interpreter that matches the Python library
665 you linked against. For more details please refer to the :ref:`caveats
670 Code Signing on macOS
671 ---------------------
673 To use the in-tree debug server on macOS, lldb needs to be code signed. The
674 Debug, DebugClang and Release builds are set to code sign using a code signing
675 certificate named ``lldb_codesign``.
677 Automatic setup, run:
679 * ``scripts/macos-setup-codesign.sh``
681 Note that it's possible to build and use lldb on macOS without setting up code
682 signing by using the system's debug server. To configure lldb in this way with
683 cmake, specify ``-DLLDB_USE_SYSTEM_DEBUGSERVER=ON``.
685 If you have re-installed a new OS, please delete all old ``lldb_codesign`` items
686 from your keychain. There will be a code signing certification and a public
687 and private key. Reboot after deleting them. You will also need to delete and
688 build folders that contained old signed items. The darwin kernel will cache
689 code signing using the executable's file system node, so you will need to
690 delete the file so the kernel clears its cache.
692 When you build your LLDB for the first time, the Xcode GUI will prompt you for
693 permission to use the ``lldb_codesign`` keychain. Be sure to click "Always
694 Allow" on your first build. From here on out, the ``lldb_codesign`` will be
695 trusted and you can build from the command line without having to authorize.
696 Also the first time you debug using a LLDB that was built with this code
697 signing certificate, you will need to authenticate once.