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