annotate lldb/docs/resources/build.rst @ 222:81f6424ef0e3 llvm-original

LLVM original branch
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 18 Jul 2021 22:10:01 +0900
parents 79ff65ed7e25
children 5f17cb93ff66
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 Building
anatofuz
parents:
diff changeset
2 ========
anatofuz
parents:
diff changeset
3
anatofuz
parents:
diff changeset
4 .. contents::
anatofuz
parents:
diff changeset
5 :local:
anatofuz
parents:
diff changeset
6
anatofuz
parents:
diff changeset
7 Getting the Sources
anatofuz
parents:
diff changeset
8 -------------------
anatofuz
parents:
diff changeset
9
anatofuz
parents:
diff changeset
10 Please refer to the `LLVM Getting Started Guide
anatofuz
parents:
diff changeset
11 <https://llvm.org/docs/GettingStarted.html#getting-started-with-llvm>`_ for
anatofuz
parents:
diff changeset
12 general instructions on how to check out the LLVM monorepo, which contains the
anatofuz
parents:
diff changeset
13 LLDB sources.
anatofuz
parents:
diff changeset
14
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
15 Git browser: https://github.com/llvm/llvm-project/tree/main/lldb
150
anatofuz
parents:
diff changeset
16
anatofuz
parents:
diff changeset
17 Preliminaries
anatofuz
parents:
diff changeset
18 -------------
anatofuz
parents:
diff changeset
19
anatofuz
parents:
diff changeset
20 LLDB relies on many of the technologies developed by the larger LLVM project.
anatofuz
parents:
diff changeset
21 In particular, it requires both Clang and LLVM itself in order to build. Due to
anatofuz
parents:
diff changeset
22 this tight integration the Getting Started guides for both of these projects
anatofuz
parents:
diff changeset
23 come as prerequisite reading:
anatofuz
parents:
diff changeset
24
anatofuz
parents:
diff changeset
25 * `LLVM <https://llvm.org/docs/GettingStarted.html>`_
anatofuz
parents:
diff changeset
26 * `Clang <http://clang.llvm.org/get_started.html>`_
anatofuz
parents:
diff changeset
27
anatofuz
parents:
diff changeset
28 The following requirements are shared on all platforms.
anatofuz
parents:
diff changeset
29
anatofuz
parents:
diff changeset
30 * `CMake <https://cmake.org>`_
anatofuz
parents:
diff changeset
31 * `Ninja <https://ninja-build.org>`_ (strongly recommended)
anatofuz
parents:
diff changeset
32
anatofuz
parents:
diff changeset
33 If you want to run the test suite, you'll need to build LLDB with Python
anatofuz
parents:
diff changeset
34 scripting support.
anatofuz
parents:
diff changeset
35
anatofuz
parents:
diff changeset
36 * `Python <http://www.python.org/>`_
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
37 * `SWIG <http://swig.org/>`_ 3 or later.
150
anatofuz
parents:
diff changeset
38
anatofuz
parents:
diff changeset
39 Optional Dependencies
anatofuz
parents:
diff changeset
40 *********************
anatofuz
parents:
diff changeset
41
anatofuz
parents:
diff changeset
42 Although the following dependencies are optional, they have a big impact on
anatofuz
parents:
diff changeset
43 LLDB's functionality. It is strongly encouraged to build LLDB with these
anatofuz
parents:
diff changeset
44 dependencies enabled.
anatofuz
parents:
diff changeset
45
anatofuz
parents:
diff changeset
46 By default they are auto-detected: if CMake can find the dependency it will be
anatofuz
parents:
diff changeset
47 used. It is possible to override this behavior by setting the corresponding
anatofuz
parents:
diff changeset
48 CMake flag to ``On`` or ``Off`` to force the dependency to be enabled or
anatofuz
parents:
diff changeset
49 disabled. When a dependency is set to ``On`` and can't be found it will cause a
anatofuz
parents:
diff changeset
50 CMake configuration error.
anatofuz
parents:
diff changeset
51
anatofuz
parents:
diff changeset
52 +-------------------+------------------------------------------------------+--------------------------+
anatofuz
parents:
diff changeset
53 | Feature | Description | CMake Flag |
anatofuz
parents:
diff changeset
54 +===================+======================================================+==========================+
anatofuz
parents:
diff changeset
55 | Editline | Generic line editing, history, Emacs and Vi bindings | ``LLDB_ENABLE_LIBEDIT`` |
anatofuz
parents:
diff changeset
56 +-------------------+------------------------------------------------------+--------------------------+
anatofuz
parents:
diff changeset
57 | Curses | Text user interface | ``LLDB_ENABLE_CURSES`` |
anatofuz
parents:
diff changeset
58 +-------------------+------------------------------------------------------+--------------------------+
anatofuz
parents:
diff changeset
59 | LZMA | Lossless data compression | ``LLDB_ENABLE_LZMA`` |
anatofuz
parents:
diff changeset
60 +-------------------+------------------------------------------------------+--------------------------+
anatofuz
parents:
diff changeset
61 | Libxml2 | XML | ``LLDB_ENABLE_LIBXML2`` |
anatofuz
parents:
diff changeset
62 +-------------------+------------------------------------------------------+--------------------------+
anatofuz
parents:
diff changeset
63 | Python | Python scripting | ``LLDB_ENABLE_PYTHON`` |
anatofuz
parents:
diff changeset
64 +-------------------+------------------------------------------------------+--------------------------+
anatofuz
parents:
diff changeset
65 | Lua | Lua scripting | ``LLDB_ENABLE_LUA`` |
anatofuz
parents:
diff changeset
66 +-------------------+------------------------------------------------------+--------------------------+
anatofuz
parents:
diff changeset
67
anatofuz
parents:
diff changeset
68 Depending on your platform and package manager, one might run any of the
anatofuz
parents:
diff changeset
69 commands below.
anatofuz
parents:
diff changeset
70
anatofuz
parents:
diff changeset
71 ::
anatofuz
parents:
diff changeset
72
anatofuz
parents:
diff changeset
73 > yum install libedit-devel libxml2-devel ncurses-devel python-devel swig
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
74 > sudo apt-get install build-essential subversion swig python3-dev libedit-dev libncurses5-dev
150
anatofuz
parents:
diff changeset
75 > pkg install swig python
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
76 > pkgin install swig python36 cmake ninja-build
150
anatofuz
parents:
diff changeset
77 > brew install swig cmake ninja
anatofuz
parents:
diff changeset
78
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
79 Note that there's an `incompatibility
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
80 <https://github.com/swig/swig/issues/1321>`_ between Python version 3.7 and later
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
81 and swig versions older than 4.0.0 which makes builds of LLDB using debug
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
82 versions of python unusable. This primarily affects Windows, as debug builds of
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
83 LLDB must use debug python as well.
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
84
150
anatofuz
parents:
diff changeset
85 Windows
anatofuz
parents:
diff changeset
86 *******
anatofuz
parents:
diff changeset
87
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
88 * Visual Studio 2017.
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
89 * The latest Windows SDK.
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
90 * The Active Template Library (ATL).
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
91 * `GnuWin32 <http://gnuwin32.sourceforge.net/>`_ for CoreUtils and Make.
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
92 * `Python 3 <https://www.python.org/downloads/windows/>`_. Make sure to (1) get
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
93 the x64 variant if that's what you're targetting and (2) install the debug
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
94 library if you want to build a debug lldb.
150
anatofuz
parents:
diff changeset
95 * `Python Tools for Visual Studio
anatofuz
parents:
diff changeset
96 <https://github.com/Microsoft/PTVS/releases>`_. If you plan to debug test
anatofuz
parents:
diff changeset
97 failures or even write new tests at all, PTVS is an indispensable debugging
anatofuz
parents:
diff changeset
98 extension to VS that enables full editing and debugging support for Python
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
99 (including mixed native/managed debugging).
150
anatofuz
parents:
diff changeset
100
anatofuz
parents:
diff changeset
101 The steps outlined here describes how to set up your system and install the
anatofuz
parents:
diff changeset
102 required dependencies such that they can be found when needed during the build
anatofuz
parents:
diff changeset
103 process. They only need to be performed once.
anatofuz
parents:
diff changeset
104
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
105 #. Install Visual Studio with the Windows SDK and ATL components.
150
anatofuz
parents:
diff changeset
106 #. Install GnuWin32, making sure ``<GnuWin32 install dir>\bin`` is added to
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
107 your PATH environment variable. Verify that utilities like ``dirname`` and
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
108 ``make`` are available from your terminal.
150
anatofuz
parents:
diff changeset
109 #. Install SWIG for Windows, making sure ``<SWIG install dir>`` is added to
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
110 your PATH environment variable. Verify that ``swig`` is available from your
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
111 terminal.
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
112 #. Register the Debug Interface Access DLLs with the Registry from a privileged
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
113 terminal.
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
114
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
115 ::
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
116
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
117 > regsvr32 "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\DIA SDK\bin\msdia140.dll"
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
118 > regsvr32 "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\DIA SDK\bin\amd64\msdia140.dll"
150
anatofuz
parents:
diff changeset
119
anatofuz
parents:
diff changeset
120 Any command prompt from which you build LLDB should have a valid Visual Studio
anatofuz
parents:
diff changeset
121 environment setup. This means you should run ``vcvarsall.bat`` or open an
anatofuz
parents:
diff changeset
122 appropriate Visual Studio Command Prompt corresponding to the version you wish
anatofuz
parents:
diff changeset
123 to use.
anatofuz
parents:
diff changeset
124
anatofuz
parents:
diff changeset
125 macOS
anatofuz
parents:
diff changeset
126 *****
anatofuz
parents:
diff changeset
127
anatofuz
parents:
diff changeset
128 * To use the in-tree debug server on macOS, lldb needs to be code signed. For
anatofuz
parents:
diff changeset
129 more information see :ref:`CodeSigning` below.
anatofuz
parents:
diff changeset
130 * If you are building both Clang and LLDB together, be sure to also check out
anatofuz
parents:
diff changeset
131 libc++, which is a required for testing on macOS.
anatofuz
parents:
diff changeset
132
anatofuz
parents:
diff changeset
133 Building LLDB with CMake
anatofuz
parents:
diff changeset
134 ------------------------
anatofuz
parents:
diff changeset
135
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
136 The LLVM project is migrating to a single monolithic repository for LLVM and
150
anatofuz
parents:
diff changeset
137 its subprojects. This is the recommended way to build LLDB. Check out the
anatofuz
parents:
diff changeset
138 source-tree with git:
anatofuz
parents:
diff changeset
139
anatofuz
parents:
diff changeset
140 ::
anatofuz
parents:
diff changeset
141
anatofuz
parents:
diff changeset
142 > git clone https://github.com/llvm/llvm-project.git
anatofuz
parents:
diff changeset
143
anatofuz
parents:
diff changeset
144 CMake is a cross-platform build-generator tool. CMake does not build the
anatofuz
parents:
diff changeset
145 project, it generates the files needed by your build tool. The recommended
anatofuz
parents:
diff changeset
146 build tool for LLVM is Ninja, but other generators like Xcode or Visual Studio
anatofuz
parents:
diff changeset
147 may be used as well. Please also read `Building LLVM with CMake
anatofuz
parents:
diff changeset
148 <https://llvm.org/docs/CMake.html>`_.
anatofuz
parents:
diff changeset
149
anatofuz
parents:
diff changeset
150 Regular in-tree builds
anatofuz
parents:
diff changeset
151 **********************
anatofuz
parents:
diff changeset
152
anatofuz
parents:
diff changeset
153 Create a new directory for your build-tree. From there run CMake and point it
anatofuz
parents:
diff changeset
154 to the ``llvm`` directory in the source-tree:
anatofuz
parents:
diff changeset
155
anatofuz
parents:
diff changeset
156 ::
anatofuz
parents:
diff changeset
157
anatofuz
parents:
diff changeset
158 > cmake -G Ninja -DLLVM_ENABLE_PROJECTS="clang;lldb" [<cmake options>] path/to/llvm-project/llvm
anatofuz
parents:
diff changeset
159
anatofuz
parents:
diff changeset
160 We used the ``LLVM_ENABLE_PROJECTS`` option here to tell the build-system which
anatofuz
parents:
diff changeset
161 subprojects to build in addition to LLVM (for more options see
anatofuz
parents:
diff changeset
162 :ref:`CommonCMakeOptions` and :ref:`CMakeCaches`). Parts of the LLDB test suite
anatofuz
parents:
diff changeset
163 require ``lld``. Add it to the list in order to run all tests. Once CMake is done,
anatofuz
parents:
diff changeset
164 run ninja to perform the actual build. We pass ``lldb`` here as the target, so
anatofuz
parents:
diff changeset
165 it only builds what is necessary to run the lldb driver:
anatofuz
parents:
diff changeset
166
anatofuz
parents:
diff changeset
167 ::
anatofuz
parents:
diff changeset
168
anatofuz
parents:
diff changeset
169 > ninja lldb
anatofuz
parents:
diff changeset
170
anatofuz
parents:
diff changeset
171 Standalone builds
anatofuz
parents:
diff changeset
172 *****************
anatofuz
parents:
diff changeset
173
anatofuz
parents:
diff changeset
174 This is another way to build LLDB. We can use the same source-tree as we
anatofuz
parents:
diff changeset
175 checked out above, but now we will have multiple build-trees:
anatofuz
parents:
diff changeset
176
anatofuz
parents:
diff changeset
177 * the main build-tree for LLDB in ``/path/to/lldb-build``
anatofuz
parents:
diff changeset
178 * one or more provided build-trees for LLVM and Clang; for simplicity we use a
anatofuz
parents:
diff changeset
179 single one in ``/path/to/llvm-build``
anatofuz
parents:
diff changeset
180
anatofuz
parents:
diff changeset
181 Run CMake with ``-B`` pointing to a new directory for the provided
anatofuz
parents:
diff changeset
182 build-tree\ :sup:`1` and the positional argument pointing to the ``llvm``
anatofuz
parents:
diff changeset
183 directory in the source-tree. Note that we leave out LLDB here and only include
anatofuz
parents:
diff changeset
184 Clang. Then we build the ``ALL`` target with ninja:
anatofuz
parents:
diff changeset
185
anatofuz
parents:
diff changeset
186 ::
anatofuz
parents:
diff changeset
187
anatofuz
parents:
diff changeset
188 > cmake -B /path/to/llvm-build -G Ninja \
anatofuz
parents:
diff changeset
189 -DLLVM_ENABLE_PROJECTS=clang \
anatofuz
parents:
diff changeset
190 [<more cmake options>] /path/to/llvm-project/llvm
anatofuz
parents:
diff changeset
191 > ninja
anatofuz
parents:
diff changeset
192
anatofuz
parents:
diff changeset
193 Now run CMake a second time with ``-B`` pointing to a new directory for the
anatofuz
parents:
diff changeset
194 main build-tree and the positional argument pointing to the ``lldb`` directory
anatofuz
parents:
diff changeset
195 in the source-tree. In order to find the provided build-tree, the build system
anatofuz
parents:
diff changeset
196 looks for the path to its CMake modules in ``LLVM_DIR``. If you use a separate
anatofuz
parents:
diff changeset
197 build directory for Clang, remember to pass its module path via ``Clang_DIR``
anatofuz
parents:
diff changeset
198 (CMake variables are case-sensitive!):
anatofuz
parents:
diff changeset
199
anatofuz
parents:
diff changeset
200 ::
anatofuz
parents:
diff changeset
201
anatofuz
parents:
diff changeset
202 > cmake -B /path/to/lldb-build -G Ninja \
anatofuz
parents:
diff changeset
203 -DLLVM_DIR=/path/to/llvm-build/lib/cmake/llvm \
anatofuz
parents:
diff changeset
204 [<more cmake options>] /path/to/llvm-project/lldb
anatofuz
parents:
diff changeset
205 > ninja lldb
anatofuz
parents:
diff changeset
206
anatofuz
parents:
diff changeset
207 .. note::
anatofuz
parents:
diff changeset
208
anatofuz
parents:
diff changeset
209 #. The ``-B`` argument was undocumented for a while and is only officially
anatofuz
parents:
diff changeset
210 supported since `CMake version 3.14
anatofuz
parents:
diff changeset
211 <https://cmake.org/cmake/help/v3.14/release/3.14.html#command-line>`_
anatofuz
parents:
diff changeset
212
anatofuz
parents:
diff changeset
213 .. _CommonCMakeOptions:
anatofuz
parents:
diff changeset
214
anatofuz
parents:
diff changeset
215 Common CMake options
anatofuz
parents:
diff changeset
216 ********************
anatofuz
parents:
diff changeset
217
anatofuz
parents:
diff changeset
218 Following is a description of some of the most important CMake variables which
anatofuz
parents:
diff changeset
219 you are likely to encounter. A variable FOO is set by adding ``-DFOO=value`` to
anatofuz
parents:
diff changeset
220 the CMake command line.
anatofuz
parents:
diff changeset
221
anatofuz
parents:
diff changeset
222 If you want to debug the lldb that you're building -- that is, build it with
anatofuz
parents:
diff changeset
223 debug info enabled -- pass two additional arguments to cmake before running
anatofuz
parents:
diff changeset
224 ninja:
anatofuz
parents:
diff changeset
225
anatofuz
parents:
diff changeset
226 ::
anatofuz
parents:
diff changeset
227
anatofuz
parents:
diff changeset
228 > cmake -G Ninja \
anatofuz
parents:
diff changeset
229 -DLLDB_EXPORT_ALL_SYMBOLS=1 \
anatofuz
parents:
diff changeset
230 -DCMAKE_BUILD_TYPE=Debug
anatofuz
parents:
diff changeset
231 <path to root of llvm source tree>
anatofuz
parents:
diff changeset
232
anatofuz
parents:
diff changeset
233 If you want to run the test suite, you will need a compiler to build the test
anatofuz
parents:
diff changeset
234 programs. If you have Clang checked out, that will be used by default.
anatofuz
parents:
diff changeset
235 Alternatively, you can specify a C and C++ compiler to be used by the test
anatofuz
parents:
diff changeset
236 suite.
anatofuz
parents:
diff changeset
237
anatofuz
parents:
diff changeset
238 ::
anatofuz
parents:
diff changeset
239
anatofuz
parents:
diff changeset
240 > cmake -G Ninja \
anatofuz
parents:
diff changeset
241 -DLLDB_TEST_COMPILER=<path to C compiler> \
anatofuz
parents:
diff changeset
242 <path to root of llvm source tree>
anatofuz
parents:
diff changeset
243
anatofuz
parents:
diff changeset
244 It is strongly recommend to use a release build for the compiler to speed up
anatofuz
parents:
diff changeset
245 test execution.
anatofuz
parents:
diff changeset
246
anatofuz
parents:
diff changeset
247 Windows
anatofuz
parents:
diff changeset
248 ^^^^^^^
anatofuz
parents:
diff changeset
249
anatofuz
parents:
diff changeset
250 On Windows the LLDB test suite requires lld. Either add ``lld`` to
anatofuz
parents:
diff changeset
251 ``LLVM_ENABLE_PROJECTS`` or disable the test suite with
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
252 ``LLDB_INCLUDE_TESTS=OFF``.
150
anatofuz
parents:
diff changeset
253
anatofuz
parents:
diff changeset
254 Although the following CMake variables are by no means Windows specific, they
anatofuz
parents:
diff changeset
255 are commonly used on Windows.
anatofuz
parents:
diff changeset
256
anatofuz
parents:
diff changeset
257 * ``LLDB_TEST_DEBUG_TEST_CRASHES`` (Default=0): If set to 1, will cause Windows
anatofuz
parents:
diff changeset
258 to generate a crash dialog whenever lldb.exe or the python extension module
anatofuz
parents:
diff changeset
259 crashes while running the test suite. If set to 0, LLDB will silently crash.
anatofuz
parents:
diff changeset
260 Setting to 1 allows a developer to attach a JIT debugger at the time of a
anatofuz
parents:
diff changeset
261 crash, rather than having to reproduce a failure or use a crash dump.
anatofuz
parents:
diff changeset
262 * ``PYTHON_HOME`` (Required): Path to the folder where the Python distribution
anatofuz
parents:
diff changeset
263 is installed. For example, ``C:\Python35``.
anatofuz
parents:
diff changeset
264 * ``LLDB_RELOCATABLE_PYTHON`` (Default=0): When this is 0, LLDB will bind
anatofuz
parents:
diff changeset
265 statically to the location specified in the ``PYTHON_HOME`` CMake variable,
anatofuz
parents:
diff changeset
266 ignoring any value of ``PYTHONHOME`` set in the environment. This is most
anatofuz
parents:
diff changeset
267 useful for developers who simply want to run LLDB after they build it. If you
anatofuz
parents:
diff changeset
268 wish to move a build of LLDB to a different machine where Python will be in a
anatofuz
parents:
diff changeset
269 different location, setting ``LLDB_RELOCATABLE_PYTHON`` to 1 will cause
anatofuz
parents:
diff changeset
270 Python to use its default mechanism for finding the python installation at
anatofuz
parents:
diff changeset
271 runtime (looking for installed Pythons, or using the ``PYTHONHOME``
anatofuz
parents:
diff changeset
272 environment variable if it is specified).
anatofuz
parents:
diff changeset
273
anatofuz
parents:
diff changeset
274 Sample command line:
anatofuz
parents:
diff changeset
275
anatofuz
parents:
diff changeset
276 ::
anatofuz
parents:
diff changeset
277
anatofuz
parents:
diff changeset
278 > cmake -G Ninja^
anatofuz
parents:
diff changeset
279 -DLLDB_TEST_DEBUG_TEST_CRASHES=1^
anatofuz
parents:
diff changeset
280 -DPYTHON_HOME=C:\Python35^
anatofuz
parents:
diff changeset
281 -DLLDB_TEST_COMPILER=d:\src\llvmbuild\ninja_release\bin\clang.exe^
anatofuz
parents:
diff changeset
282 <path to root of llvm source tree>
anatofuz
parents:
diff changeset
283
anatofuz
parents:
diff changeset
284
anatofuz
parents:
diff changeset
285 Building with ninja is both faster and simpler than building with Visual Studio,
anatofuz
parents:
diff changeset
286 but chances are you still want to debug LLDB with an IDE. One solution is to run
anatofuz
parents:
diff changeset
287 cmake twice and generate the output into two different folders. One for
anatofuz
parents:
diff changeset
288 compiling (the ninja folder), and one for editing, browsing and debugging.
anatofuz
parents:
diff changeset
289
anatofuz
parents:
diff changeset
290 Follow the previous instructions in one directory, and generate a Visual Studio
anatofuz
parents:
diff changeset
291 project in another directory.
anatofuz
parents:
diff changeset
292
anatofuz
parents:
diff changeset
293 ::
anatofuz
parents:
diff changeset
294
anatofuz
parents:
diff changeset
295 > cmake -G "Visual Studio 15 2017 Win64" -Thost=x64 <cmake variables> <path to root of llvm source tree>
anatofuz
parents:
diff changeset
296
anatofuz
parents:
diff changeset
297 Then you can open the .sln file in Visual Studio, set lldb as the startup
anatofuz
parents:
diff changeset
298 project, and use F5 to run it. You need only edit the project settings to set
anatofuz
parents:
diff changeset
299 the executable and the working directory to point to binaries inside of the
anatofuz
parents:
diff changeset
300 ninja tree.
anatofuz
parents:
diff changeset
301
anatofuz
parents:
diff changeset
302
anatofuz
parents:
diff changeset
303 macOS
anatofuz
parents:
diff changeset
304 ^^^^^
anatofuz
parents:
diff changeset
305
anatofuz
parents:
diff changeset
306 On macOS the LLDB test suite requires libc++. Either add ``libcxx`` to
anatofuz
parents:
diff changeset
307 ``LLVM_ENABLE_PROJECTS`` or disable the test suite with
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
308 ``LLDB_INCLUDE_TESTS=OFF``. Further useful options:
150
anatofuz
parents:
diff changeset
309
anatofuz
parents:
diff changeset
310 * ``LLDB_BUILD_FRAMEWORK:BOOL``: Builds the LLDB.framework.
anatofuz
parents:
diff changeset
311 * ``LLDB_CODESIGN_IDENTITY:STRING``: Set the identity to use for code-signing
anatofuz
parents:
diff changeset
312 all executables. If not explicitly specified, only ``debugserver`` will be
anatofuz
parents:
diff changeset
313 code-signed with identity ``lldb_codesign`` (see :ref:`CodeSigning`).
anatofuz
parents:
diff changeset
314 * ``LLDB_USE_SYSTEM_DEBUGSERVER:BOOL``: Use the system's debugserver, so lldb is
anatofuz
parents:
diff changeset
315 functional without setting up code-signing.
anatofuz
parents:
diff changeset
316
anatofuz
parents:
diff changeset
317
anatofuz
parents:
diff changeset
318 .. _CMakeCaches:
anatofuz
parents:
diff changeset
319
anatofuz
parents:
diff changeset
320 CMake caches
anatofuz
parents:
diff changeset
321 ************
anatofuz
parents:
diff changeset
322
anatofuz
parents:
diff changeset
323 CMake caches allow to store common sets of configuration options in the form of
anatofuz
parents:
diff changeset
324 CMake scripts and can be useful to reproduce builds for particular use-cases
anatofuz
parents:
diff changeset
325 (see by analogy `usage in LLVM and Clang <https://llvm.org/docs/AdvancedBuilds.html>`_).
anatofuz
parents:
diff changeset
326 A cache is passed to CMake with the ``-C`` flag, following the absolute path to
anatofuz
parents:
diff changeset
327 the file on disk. Subsequent ``-D`` options are still allowed. Please find the
anatofuz
parents:
diff changeset
328 currently available caches in the `lldb/cmake/caches/
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
329 <https://github.com/llvm/llvm-project/tree/main/lldb/cmake/caches>`_
150
anatofuz
parents:
diff changeset
330 directory.
anatofuz
parents:
diff changeset
331
anatofuz
parents:
diff changeset
332 Common configurations on macOS
anatofuz
parents:
diff changeset
333 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
anatofuz
parents:
diff changeset
334
anatofuz
parents:
diff changeset
335 Build, test and install a distribution of LLDB from the `monorepo
anatofuz
parents:
diff changeset
336 <https://github.com/llvm/llvm-project>`_ (see also `Building a Distribution of
anatofuz
parents:
diff changeset
337 LLVM <https://llvm.org/docs/BuildingADistribution.html>`_):
anatofuz
parents:
diff changeset
338
anatofuz
parents:
diff changeset
339 ::
anatofuz
parents:
diff changeset
340
anatofuz
parents:
diff changeset
341 > git clone https://github.com/llvm/llvm-project
anatofuz
parents:
diff changeset
342
anatofuz
parents:
diff changeset
343 > cmake -B /path/to/lldb-build -G Ninja \
anatofuz
parents:
diff changeset
344 -C /path/to/llvm-project/lldb/cmake/caches/Apple-lldb-macOS.cmake \
anatofuz
parents:
diff changeset
345 -DLLVM_ENABLE_PROJECTS="clang;libcxx;lldb" \
anatofuz
parents:
diff changeset
346 llvm-project/llvm
anatofuz
parents:
diff changeset
347
anatofuz
parents:
diff changeset
348 > DESTDIR=/path/to/lldb-install ninja -C /path/to/lldb-build check-lldb install-distribution
anatofuz
parents:
diff changeset
349
anatofuz
parents:
diff changeset
350 .. _CMakeGeneratedXcodeProject:
anatofuz
parents:
diff changeset
351
anatofuz
parents:
diff changeset
352 Build LLDB standalone for development with Xcode:
anatofuz
parents:
diff changeset
353
anatofuz
parents:
diff changeset
354 ::
anatofuz
parents:
diff changeset
355
anatofuz
parents:
diff changeset
356 > git clone https://github.com/llvm/llvm-project
anatofuz
parents:
diff changeset
357
anatofuz
parents:
diff changeset
358 > cmake -B /path/to/llvm-build -G Ninja \
anatofuz
parents:
diff changeset
359 -C /path/to/llvm-project/lldb/cmake/caches/Apple-lldb-base.cmake \
anatofuz
parents:
diff changeset
360 -DLLVM_ENABLE_PROJECTS="clang;libcxx" \
anatofuz
parents:
diff changeset
361 llvm-project/llvm
anatofuz
parents:
diff changeset
362 > ninja -C /path/to/llvm-build
anatofuz
parents:
diff changeset
363
anatofuz
parents:
diff changeset
364 > cmake -B /path/to/lldb-build \
anatofuz
parents:
diff changeset
365 -C /path/to/llvm-project/lldb/cmake/caches/Apple-lldb-Xcode.cmake \
anatofuz
parents:
diff changeset
366 -DLLVM_DIR=/path/to/llvm-build/lib/cmake/llvm \
anatofuz
parents:
diff changeset
367 llvm-project/lldb
anatofuz
parents:
diff changeset
368 > open lldb.xcodeproj
anatofuz
parents:
diff changeset
369 > cmake --build /path/to/lldb-build --target check-lldb
anatofuz
parents:
diff changeset
370
anatofuz
parents:
diff changeset
371 .. note::
anatofuz
parents:
diff changeset
372
anatofuz
parents:
diff changeset
373 The ``-B`` argument was undocumented for a while and is only officially
anatofuz
parents:
diff changeset
374 supported since `CMake version 3.14
anatofuz
parents:
diff changeset
375 <https://cmake.org/cmake/help/v3.14/release/3.14.html#command-line>`_
anatofuz
parents:
diff changeset
376
anatofuz
parents:
diff changeset
377
anatofuz
parents:
diff changeset
378 Building the Documentation
anatofuz
parents:
diff changeset
379 --------------------------
anatofuz
parents:
diff changeset
380
anatofuz
parents:
diff changeset
381 If you wish to build the optional (reference) documentation, additional
anatofuz
parents:
diff changeset
382 dependencies are required:
anatofuz
parents:
diff changeset
383
anatofuz
parents:
diff changeset
384 * Sphinx (for the website)
anatofuz
parents:
diff changeset
385 * Graphviz (for the 'dot' tool)
anatofuz
parents:
diff changeset
386 * doxygen (if you wish to build the C++ API reference)
anatofuz
parents:
diff changeset
387 * epydoc (if you wish to build the Python API reference)
anatofuz
parents:
diff changeset
388
anatofuz
parents:
diff changeset
389 To install the prerequisites for building the documentation (on Debian/Ubuntu)
anatofuz
parents:
diff changeset
390 do:
anatofuz
parents:
diff changeset
391
anatofuz
parents:
diff changeset
392 ::
anatofuz
parents:
diff changeset
393
anatofuz
parents:
diff changeset
394 > sudo apt-get install doxygen graphviz python3-sphinx
anatofuz
parents:
diff changeset
395 > sudo pip install epydoc
anatofuz
parents:
diff changeset
396
anatofuz
parents:
diff changeset
397 To build the documentation, configure with ``LLVM_ENABLE_SPHINX=ON`` and build the desired target(s).
anatofuz
parents:
diff changeset
398
anatofuz
parents:
diff changeset
399 ::
anatofuz
parents:
diff changeset
400
anatofuz
parents:
diff changeset
401 > ninja docs-lldb-html
anatofuz
parents:
diff changeset
402 > ninja docs-lldb-man
anatofuz
parents:
diff changeset
403 > ninja lldb-cpp-doc
anatofuz
parents:
diff changeset
404 > ninja lldb-python-doc
anatofuz
parents:
diff changeset
405
anatofuz
parents:
diff changeset
406 Cross-compiling LLDB
anatofuz
parents:
diff changeset
407 --------------------
anatofuz
parents:
diff changeset
408
anatofuz
parents:
diff changeset
409 In order to debug remote targets running different architectures than your
anatofuz
parents:
diff changeset
410 host, you will need to compile LLDB (or at least the server component) for the
anatofuz
parents:
diff changeset
411 target. While the easiest solution is to just compile it locally on the target,
anatofuz
parents:
diff changeset
412 this is often not feasible, and in these cases you will need to cross-compile
anatofuz
parents:
diff changeset
413 LLDB on your host.
anatofuz
parents:
diff changeset
414
anatofuz
parents:
diff changeset
415 Cross-compilation is often a daunting task and has a lot of quirks which depend
anatofuz
parents:
diff changeset
416 on the exact host and target architectures, so it is not possible to give a
anatofuz
parents:
diff changeset
417 universal guide which will work on all platforms. However, here we try to
anatofuz
parents:
diff changeset
418 provide an overview of the cross-compilation process along with the main things
anatofuz
parents:
diff changeset
419 you should look out for.
anatofuz
parents:
diff changeset
420
anatofuz
parents:
diff changeset
421 First, you will need a working toolchain which is capable of producing binaries
anatofuz
parents:
diff changeset
422 for the target architecture. Since you already have a checkout of clang and
anatofuz
parents:
diff changeset
423 lldb, you can compile a host version of clang in a separate folder and use
anatofuz
parents:
diff changeset
424 that. Alternatively you can use system clang or even cross-gcc if your
anatofuz
parents:
diff changeset
425 distribution provides such packages (e.g., ``g++-aarch64-linux-gnu`` on
anatofuz
parents:
diff changeset
426 Ubuntu).
anatofuz
parents:
diff changeset
427
anatofuz
parents:
diff changeset
428 Next, you will need a copy of the required target headers and libraries on your
anatofuz
parents:
diff changeset
429 host. The libraries can be usually obtained by copying from the target machine,
anatofuz
parents:
diff changeset
430 however the headers are often not found there, especially in case of embedded
anatofuz
parents:
diff changeset
431 platforms. In this case, you will need to obtain them from another source,
anatofuz
parents:
diff changeset
432 either a cross-package if one is available, or cross-compiling the respective
anatofuz
parents:
diff changeset
433 library from source. Fortunately the list of LLDB dependencies is not big and
anatofuz
parents:
diff changeset
434 if you are only interested in the server component, you can reduce this even
anatofuz
parents:
diff changeset
435 further by passing the appropriate cmake options, such as:
anatofuz
parents:
diff changeset
436
anatofuz
parents:
diff changeset
437 ::
anatofuz
parents:
diff changeset
438
anatofuz
parents:
diff changeset
439 -DLLDB_ENABLE_PYTHON=0
anatofuz
parents:
diff changeset
440 -DLLDB_ENABLE_LIBEDIT=0
anatofuz
parents:
diff changeset
441 -DLLDB_ENABLE_CURSES=0
anatofuz
parents:
diff changeset
442 -DLLVM_ENABLE_TERMINFO=0
anatofuz
parents:
diff changeset
443
anatofuz
parents:
diff changeset
444 In this case you, will often not need anything other than the standard C and
anatofuz
parents:
diff changeset
445 C++ libraries.
anatofuz
parents:
diff changeset
446
anatofuz
parents:
diff changeset
447 Once all of the dependencies are in place, it's just a matter of configuring
anatofuz
parents:
diff changeset
448 the build system with the locations and arguments of all the necessary tools.
anatofuz
parents:
diff changeset
449 The most important cmake options here are:
anatofuz
parents:
diff changeset
450
anatofuz
parents:
diff changeset
451 * ``CMAKE_CROSSCOMPILING`` : Set to 1 to enable cross-compilation.
anatofuz
parents:
diff changeset
452 * ``CMAKE_LIBRARY_ARCHITECTURE`` : Affects the cmake search path when looking
anatofuz
parents:
diff changeset
453 for libraries. You may need to set this to your architecture triple if you do
anatofuz
parents:
diff changeset
454 not specify all your include and library paths explicitly.
anatofuz
parents:
diff changeset
455 * ``CMAKE_C_COMPILER``, ``CMAKE_CXX_COMPILER`` : C and C++ compilers for the
anatofuz
parents:
diff changeset
456 target architecture
anatofuz
parents:
diff changeset
457 * ``CMAKE_C_FLAGS``, ``CMAKE_CXX_FLAGS`` : The flags for the C and C++ target
anatofuz
parents:
diff changeset
458 compilers. You may need to specify the exact target cpu and abi besides the
anatofuz
parents:
diff changeset
459 include paths for the target headers.
anatofuz
parents:
diff changeset
460 * ``CMAKE_EXE_LINKER_FLAGS`` : The flags to be passed to the linker. Usually
anatofuz
parents:
diff changeset
461 just a list of library search paths referencing the target libraries.
anatofuz
parents:
diff changeset
462 * ``LLVM_TABLEGEN``, ``CLANG_TABLEGEN`` : Paths to llvm-tblgen and clang-tblgen
anatofuz
parents:
diff changeset
463 for the host architecture. If you already have built clang for the host, you
anatofuz
parents:
diff changeset
464 can point these variables to the executables in your build directory. If not,
anatofuz
parents:
diff changeset
465 you will need to build the llvm-tblgen and clang-tblgen host targets at
anatofuz
parents:
diff changeset
466 least.
anatofuz
parents:
diff changeset
467 * ``LLVM_HOST_TRIPLE`` : The triple of the system that lldb (or lldb-server)
anatofuz
parents:
diff changeset
468 will run on. Not setting this (or setting it incorrectly) can cause a lot of
anatofuz
parents:
diff changeset
469 issues with remote debugging as a lot of the choices lldb makes depend on the
anatofuz
parents:
diff changeset
470 triple reported by the remote platform.
anatofuz
parents:
diff changeset
471
anatofuz
parents:
diff changeset
472 You can of course also specify the usual cmake options like
anatofuz
parents:
diff changeset
473 ``CMAKE_BUILD_TYPE``, etc.
anatofuz
parents:
diff changeset
474
anatofuz
parents:
diff changeset
475 Example 1: Cross-compiling for linux arm64 on Ubuntu host
anatofuz
parents:
diff changeset
476 *********************************************************
anatofuz
parents:
diff changeset
477
anatofuz
parents:
diff changeset
478 Ubuntu already provides the packages necessary to cross-compile LLDB for arm64.
anatofuz
parents:
diff changeset
479 It is sufficient to install packages ``gcc-aarch64-linux-gnu``,
anatofuz
parents:
diff changeset
480 ``g++-aarch64-linux-gnu``, ``binutils-aarch64-linux-gnu``. Then it is possible
anatofuz
parents:
diff changeset
481 to prepare the cmake build with the following parameters:
anatofuz
parents:
diff changeset
482
anatofuz
parents:
diff changeset
483 ::
anatofuz
parents:
diff changeset
484
anatofuz
parents:
diff changeset
485 -DCMAKE_CROSSCOMPILING=1 \
anatofuz
parents:
diff changeset
486 -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
anatofuz
parents:
diff changeset
487 -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \
anatofuz
parents:
diff changeset
488 -DLLVM_HOST_TRIPLE=aarch64-unknown-linux-gnu \
anatofuz
parents:
diff changeset
489 -DLLVM_TABLEGEN=<path-to-host>/bin/llvm-tblgen \
anatofuz
parents:
diff changeset
490 -DCLANG_TABLEGEN=<path-to-host>/bin/clang-tblgen \
anatofuz
parents:
diff changeset
491 -DLLDB_ENABLE_PYTHON=0 \
anatofuz
parents:
diff changeset
492 -DLLDB_ENABLE_LIBEDIT=0 \
anatofuz
parents:
diff changeset
493 -DLLDB_ENABLE_CURSES=0
anatofuz
parents:
diff changeset
494
anatofuz
parents:
diff changeset
495 An alternative (and recommended) way to compile LLDB is with clang.
anatofuz
parents:
diff changeset
496 Unfortunately, clang is not able to find all the include paths necessary for a
anatofuz
parents:
diff changeset
497 successful cross-compile, so we need to help it with a couple of CFLAGS
anatofuz
parents:
diff changeset
498 options. In my case it was sufficient to add the following arguments to
anatofuz
parents:
diff changeset
499 ``CMAKE_C_FLAGS`` and ``CMAKE_CXX_FLAGS`` (in addition to changing
anatofuz
parents:
diff changeset
500 ``CMAKE_C(XX)_COMPILER`` to point to clang compilers):
anatofuz
parents:
diff changeset
501
anatofuz
parents:
diff changeset
502 ::
anatofuz
parents:
diff changeset
503
anatofuz
parents:
diff changeset
504 -target aarch64-linux-gnu \
anatofuz
parents:
diff changeset
505 -I /usr/aarch64-linux-gnu/include/c++/4.8.2/aarch64-linux-gnu \
anatofuz
parents:
diff changeset
506 -I /usr/aarch64-linux-gnu/include
anatofuz
parents:
diff changeset
507
anatofuz
parents:
diff changeset
508 If you wanted to build a full version of LLDB and avoid passing
anatofuz
parents:
diff changeset
509 ``-DLLDB_ENABLE_PYTHON=0`` and other options, you would need to obtain the
anatofuz
parents:
diff changeset
510 target versions of the respective libraries. The easiest way to achieve this is
anatofuz
parents:
diff changeset
511 to use the qemu-debootstrap utility, which can prepare a system image using
anatofuz
parents:
diff changeset
512 qemu and chroot to simulate the target environment. Then you can install the
anatofuz
parents:
diff changeset
513 necessary packages in this environment (python-dev, libedit-dev, etc.) and
anatofuz
parents:
diff changeset
514 point your compiler to use them using the correct -I and -L arguments.
anatofuz
parents:
diff changeset
515
anatofuz
parents:
diff changeset
516 Example 2: Cross-compiling for Android on Linux
anatofuz
parents:
diff changeset
517 ***********************************************
anatofuz
parents:
diff changeset
518
anatofuz
parents:
diff changeset
519 In the case of Android, the toolchain and all required headers and libraries
anatofuz
parents:
diff changeset
520 are available in the Android NDK.
anatofuz
parents:
diff changeset
521
anatofuz
parents:
diff changeset
522 The NDK also contains a cmake toolchain file, which makes configuring the build
anatofuz
parents:
diff changeset
523 much simpler. The compiler, include and library paths will be configured by the
anatofuz
parents:
diff changeset
524 toolchain file and all you need to do is to select the architecture
anatofuz
parents:
diff changeset
525 (ANDROID_ABI) and platform level (``ANDROID_PLATFORM``, should be at least 21).
anatofuz
parents:
diff changeset
526 You will also need to set ``ANDROID_ALLOW_UNDEFINED_SYMBOLS=On``, as the
anatofuz
parents:
diff changeset
527 toolchain file defaults to "no undefined symbols in shared libraries", which is
anatofuz
parents:
diff changeset
528 not compatible with some llvm libraries. The first version of NDK which
anatofuz
parents:
diff changeset
529 supports this approach is r14.
anatofuz
parents:
diff changeset
530
anatofuz
parents:
diff changeset
531 For example, the following arguments are sufficient to configure an android
anatofuz
parents:
diff changeset
532 arm64 build:
anatofuz
parents:
diff changeset
533
anatofuz
parents:
diff changeset
534 ::
anatofuz
parents:
diff changeset
535
anatofuz
parents:
diff changeset
536 -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake \
anatofuz
parents:
diff changeset
537 -DANDROID_ABI=arm64-v8a \
anatofuz
parents:
diff changeset
538 -DANDROID_PLATFORM=android-21 \
anatofuz
parents:
diff changeset
539 -DANDROID_ALLOW_UNDEFINED_SYMBOLS=On \
anatofuz
parents:
diff changeset
540 -DLLVM_HOST_TRIPLE=aarch64-unknown-linux-android \
anatofuz
parents:
diff changeset
541 -DCROSS_TOOLCHAIN_FLAGS_NATIVE='-DCMAKE_C_COMPILER=cc;-DCMAKE_CXX_COMPILER=c++'
anatofuz
parents:
diff changeset
542
anatofuz
parents:
diff changeset
543 Note that currently only lldb-server is functional on android. The lldb client
anatofuz
parents:
diff changeset
544 is not supported and unlikely to work.
anatofuz
parents:
diff changeset
545
anatofuz
parents:
diff changeset
546 Verifying Python Support
anatofuz
parents:
diff changeset
547 ------------------------
anatofuz
parents:
diff changeset
548
anatofuz
parents:
diff changeset
549 LLDB has a Python scripting capability and supplies its own Python module named
anatofuz
parents:
diff changeset
550 lldb. If a script is run inside the command line lldb application, the Python
anatofuz
parents:
diff changeset
551 module is made available automatically. However, if a script is to be run by a
anatofuz
parents:
diff changeset
552 Python interpreter outside the command line application, the ``PYTHONPATH``
anatofuz
parents:
diff changeset
553 environment variable can be used to let the Python interpreter find the lldb
anatofuz
parents:
diff changeset
554 module.
anatofuz
parents:
diff changeset
555
anatofuz
parents:
diff changeset
556 The correct path can be obtained by invoking the command line lldb tool with
anatofuz
parents:
diff changeset
557 the -P flag:
anatofuz
parents:
diff changeset
558
anatofuz
parents:
diff changeset
559 ::
anatofuz
parents:
diff changeset
560
anatofuz
parents:
diff changeset
561 > export PYTHONPATH=`$llvm/build/Debug+Asserts/bin/lldb -P`
anatofuz
parents:
diff changeset
562
anatofuz
parents:
diff changeset
563 If you used a different build directory or made a release build, you may need
anatofuz
parents:
diff changeset
564 to adjust the above to suit your needs. To test that the lldb Python module is
anatofuz
parents:
diff changeset
565 built correctly and is available to the default Python interpreter, run:
anatofuz
parents:
diff changeset
566
anatofuz
parents:
diff changeset
567 ::
anatofuz
parents:
diff changeset
568
anatofuz
parents:
diff changeset
569 > python -c 'import lldb'
anatofuz
parents:
diff changeset
570
anatofuz
parents:
diff changeset
571
anatofuz
parents:
diff changeset
572 Make sure you're using the Python interpreter that matches the Python library
anatofuz
parents:
diff changeset
573 you linked against. For more details please refer to the :ref:`caveats
anatofuz
parents:
diff changeset
574 <python_caveat>`.
anatofuz
parents:
diff changeset
575
anatofuz
parents:
diff changeset
576 .. _CodeSigning:
anatofuz
parents:
diff changeset
577
anatofuz
parents:
diff changeset
578 Code Signing on macOS
anatofuz
parents:
diff changeset
579 ---------------------
anatofuz
parents:
diff changeset
580
anatofuz
parents:
diff changeset
581 To use the in-tree debug server on macOS, lldb needs to be code signed. The
anatofuz
parents:
diff changeset
582 Debug, DebugClang and Release builds are set to code sign using a code signing
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
583 certificate named ``lldb_codesign``.
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
584
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
585 Automatic setup, run:
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
586
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
587 * ``scripts/macos-setup-codesign.sh``
150
anatofuz
parents:
diff changeset
588
anatofuz
parents:
diff changeset
589 Note that it's possible to build and use lldb on macOS without setting up code
anatofuz
parents:
diff changeset
590 signing by using the system's debug server. To configure lldb in this way with
anatofuz
parents:
diff changeset
591 cmake, specify ``-DLLDB_USE_SYSTEM_DEBUGSERVER=ON``.
anatofuz
parents:
diff changeset
592
anatofuz
parents:
diff changeset
593 If you have re-installed a new OS, please delete all old ``lldb_codesign`` items
anatofuz
parents:
diff changeset
594 from your keychain. There will be a code signing certification and a public
anatofuz
parents:
diff changeset
595 and private key. Reboot after deleting them. You will also need to delete and
anatofuz
parents:
diff changeset
596 build folders that contained old signed items. The darwin kernel will cache
anatofuz
parents:
diff changeset
597 code signing using the executable's file system node, so you will need to
anatofuz
parents:
diff changeset
598 delete the file so the kernel clears its cache.
anatofuz
parents:
diff changeset
599
anatofuz
parents:
diff changeset
600 When you build your LLDB for the first time, the Xcode GUI will prompt you for
anatofuz
parents:
diff changeset
601 permission to use the ``lldb_codesign`` keychain. Be sure to click "Always
anatofuz
parents:
diff changeset
602 Allow" on your first build. From here on out, the ``lldb_codesign`` will be
anatofuz
parents:
diff changeset
603 trusted and you can build from the command line without having to authorize.
anatofuz
parents:
diff changeset
604 Also the first time you debug using a LLDB that was built with this code
anatofuz
parents:
diff changeset
605 signing certificate, you will need to authenticate once.