]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - www/build.html
Vendor import of lldb trunk r302418:
[FreeBSD/FreeBSD.git] / www / build.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
5   <link href="style.css" rel="stylesheet" type="text/css" />
6   <title>Building LLDB</title>
7 </head>
8 <body>
9   <div class="www_title">
10     The <strong>LLDB</strong> Debugger
11   </div>
12
13   <div id="container">
14     <div id="content">
15
16       <!--#include virtual="sidebar.incl"-->
17
18       <div id="middle">
19         <h1 class="postheader">Continuous Integration</h1>
20         <div class="postcontent">
21           <p>
22             The following LLVM buildbots build and test LLDB trunk:
23             <ul>
24               <li> <a href="http://lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-14.04-cmake">LLDB Ubuntu 14.04 x86_64 (CMake, clang-3.5+/gcc-4.8, i386/x86_64)</a>
25               </li>
26               <li> <a href="http://lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-14.04-android">LLDB Ubuntu 14.04 x86_64->Android (CMake, gcc-4.9 arm/arm64/x86)</a>
27               </li>
28               <li> <a href="http://lab.llvm.org:8011/builders/lldb-x86_64-darwin-13.4">LLDB Mac OS X 10.9.5 x86_64 (Xcode)</a>
29               </li>
30               <li> <a href="http://lab.llvm.org:8011/builders/lldb-x86-windows-msvc">LLDB Windows Server 2008 x86 (CMake, MSVS 2013, Windows SDK 8.1, no tests)</a>
31               </li>
32               <li> <a href="http://lab.llvm.org:8011/builders/lldb-x86-win7-msvc">LLDB Windows 7 x86 (CMake, MSVS 2013, Windows SDK 8.1, no tests)</a>
33               </li>
34               <li> <a href="http://lab.llvm.org:8011/builders/lldb-x86_64-debian-clang">LLDB Ubuntu 14.04 x86_64 build (automake, Clang 3.4, VMware Workstation)</a>
35               </li>
36               <li> <a href="http://lab.llvm.org:8011/builders/lldb-x86_64-freebsd">LLDB FreeBSD x86_64 (CMake)</a>
37               </li>
38               <li> <a href="http://lab.llvm.org:8011/builders/lldb-amd64-ninja-netbsd7">LLDB NetBSD-7.0 amd64 (GCC 4.8.5, Ninja)</a>
39               </li>
40             </ul>
41           </p>
42         </div>
43         <div class="postfooter"></div>
44         <div class="post">
45           <h1 class="postheader">Building LLDB</h1>
46           <ul>
47             <li><a href="#BuildingLldbOnWindows">Building LLDB on Windows</a></li>
48             <li><a href="#BuildingLldbOnMacOSX">Building LLDB on Mac OSX</a></li>
49             <li><a href="#BuildingLldbOnLinux">Building LLDB on Linux, FreeBSD and NetBSD</a></li>
50           </ul>
51         </div>
52         <div class="postfooter"></div>
53         <div class="post" id="BuildingLldbOnWindows">
54           <h1 class="postheader">Building LLDB on Windows</h1>
55           <div class="postcontent">
56             <h2>Required Dependencies</h2>
57             <ul>
58               <li>Visual Studio 2015 or greater</li>
59               <li>Windows SDK 8.0 or higher.  In general it is best to use the latest available version.</li>
60               <li>
61                 <a href="https://www.python.org/downloads/windows/">Python 3.5 or higher</a> or higher.  Earlier
62                 versions of Python can be made to work by compiling your own distribution from source,
63                 but this workflow is unsupported and you are own your own.
64               </li>
65               <li><a href="https://ninja-build.org/">Ninja build tool</a> (strongly recommended)</li>
66               <li><a href="http://gnuwin32.sourceforge.net/">GnuWin32</a></li>
67               <li><a href="http://www.swig.org/download.html">SWIG for Windows (version 3+)</a></li>
68             </ul>
69             <h2>Optional Dependencies</h2>
70             <ul>
71               <li><a href="https://github.com/Microsoft/PTVS/releases">Python Tools for Visual Studio</a>.  If you
72               plan to debug test failures or even write new tests at all, PTVS is an indispensable debugging extension
73               to VS that enables full editing and debugging support for Python (including mixed native/managed debugging)</li>
74             </ul>
75             <h2 id="WindowsPreliminaries">Preliminaries</h2>
76             <p>
77               This section describes how to set up your system and install the required dependencies such that
78               they can be found when needed during the build process.  The steps outlined here only need to
79               be performed once.
80             </p>
81             <ol>
82               <li><p>Install Visual Studio and the Windows SDK.</p></li>
83               <li><p>Install GnuWin32, making sure <code>&lt;GnuWin32 install dir&gt;\bin</code> is added to your <code>PATH</code> environment variable.</p></li>
84               <li><p>Install SWIG for Windows, making sure <code>&lt;SWIG install dir&gt;</code> is added to your <code>PATH</code> environment variable.</p></li>
85             </ol>
86             <h2>Building LLDB</h2>
87             <p>
88               Any command prompt from which you build LLDB should have a valid Visual Studio environment setup.
89               This means you should run <code>vcvarsall.bat</code> or open an appropriate Visual Studio Command Prompt
90               corresponding to the version you wish to use.
91             </p>
92             <p>Finally, when you are ready to build LLDB, generate CMake with the following command line:</p>
93             <code>cmake -G Ninja &lt;cmake variables&gt; &lt;path to root of llvm src tree&gt;</code>
94             <p>and run <code>ninja</code> to build LLDB. Information about running the LLDB test suite can be found on the <a href="test.html">test</a> page.</p>
95             <p>
96               Following is a description of some of the most important CMake variables which you are likely to encounter.
97               A variable <code>FOO</code> is set by adding <code>-DFOO=value</code> to the CMake command line.
98             </p>
99             <ul>
100               <li>
101                 <b>LLDB_TEST_DEBUG_TEST_CRASHES</b> (Default=0): If set to 1, will cause Windows to generate a crash
102                 dialog whenever lldb.exe or the python extension module crashes while running the test suite.  If set to
103                 0, LLDB will silently crash.  Setting to 1 allows a developer to attach a JIT debugger at the time of
104                 a crash, rather than having to reproduce a failure or use a crash dump.
105               </li>
106               <li>
107                 <b>PYTHON_HOME</b> (Required): Path to the folder where the Python distribution is installed.  For example,
108                 C:\Python35
109               </li>
110               <li>
111                 <b>LLDB_RELOCATABLE_PYTHON</b> (Default=0): When this is 0, LLDB will bind statically to the location specified
112                 in the PYTHON_HOME CMake variable, ignoring any value of PYTHONHOME set in the environment.  This is most useful for
113                 developers who simply want to run LLDB after they build it.  If you wish to move a build of LLDB to a different
114                 machine where Python will be in a different location, setting LLDB_RELOCATABLE_PYTHON to 1 will cause Python to
115                 use its default mechanism for finding the python installation at runtime (looking for installed Pythons, or using
116                 the PYTHONHOME environment variable if it is specified).
117               </li>
118               <li>
119                 <b>LLDB_TEST_COMPILER</b>: The test suite needs to be able to find a copy of clang.exe that it can use to compile
120                 inferior programs.  Note that MSVC is not supported here, it <strong>must</strong> be a path to a clang executable.
121                 Note that using a release clang.exe is strongly recommended here, as it will make the test suite run much faster.
122                 This can be a path to any recent clang.exe, including one you built yourself.
123               </li>
124             </ul>
125             Sample command line:<br/>
126             <code>cmake -G Ninja -DLLDB_TEST_DEBUG_TEST_CRASHES=1 -DPYTHON_HOME=C:\Python35 -DLLDB_TEST_COMPILER=d:\src\llvmbuild\ninja_release\bin\clang.exe ..\..\llvm</code>\r
127             <h2>Working with both Ninja and MSVC</h2>\r
128             <p>\r
129               Compiling with <code>ninja</code> is both faster and simpler than compiling with MSVC, but chances are you still want\r
130               to debug LLDB with MSVC (at least until we can debug LLDB on Windows with LLDB!).  One solution to this is to run \r
131               <code>cmake</code> twice and generate the output into two different folders.  One for compiling (the <code>ninja</code>\r
132               folder), and one for editing / browsing / debugging (the MSVC folder).\r
133             </p>\r
134             <p>\r
135               To do this, simply run <code>`cmake -G Ninja &lt;arguments&gt;`</code> from one folder, and \r
136               <code>`cmake -G "Visual Studio 14 2015" &lt;arguments&gt;`</code> in another folder.  Then you can open the .sln file\r
137               in Visual Studio, set <code>lldb</code> as the startup project, and use F5 to run it.  You need only edit the project\r
138               settings to set the executable and the working directory to point to binaries inside of the <code>ninja</code> tree.\r
139             </p>\r
140           </div>
141         </div>
142         <div class="post" id="BuildingLldbOnMacOSX">
143           <h1 class="postheader">Building LLDB on Mac OS X</h1>
144           <div class="postcontent">
145             <p>Building on Mac OS X is as easy as downloading the code and building the Xcode project or workspace:</p>
146           </div>
147           <div class="postcontent">
148             <h2>Preliminaries</h2>
149             <ul>
150               <li>XCode 4.3 or newer requires the "Command Line Tools" component (XCode->Preferences->Downloads->Components).</li>
151               <li>Mac OS X Lion or newer requires installing <a href="http://swig.org">Swig</a>.</li>
152             </ul>
153             <h2>Building LLDB</h2>
154             <ul>
155               <li><a href="download.html">Download</a> the lldb sources.</li>
156               <li>Follow the code signing instructions in <b>lldb/docs/code-signing.txt</b></li>
157               <li>In Xcode 3.x: <b>lldb/lldb.xcodeproj</b>, select the <b>lldb-tool</b> target, and build.</li>
158               <li>In Xcode 4.x: <b>lldb/lldb.xcworkspace</b>, select the <b>lldb-tool</b> scheme, and build.</li>
159             </ul>
160           </div>
161           <div class="postfooter"></div>
162         </div>
163         <div class="post" id="BuildingLldbOnLinux">
164           <h1 class="postheader">Building LLDB on Linux, FreeBSD and NetBSD</h1>
165           <div class="postcontent">
166             <p>This document describes the steps needed to compile LLDB on most Linux systems, FreeBSD and NetBSD.</a></p>
167           </div>
168           <div class="postcontent">
169             <h2>Preliminaries</h2>
170             <p>
171               LLDB relies on many of the technologies developed by the larger LLVM project.
172               In particular, it requires both Clang and LLVM itself in order to build.  Due to
173               this tight integration the <em>Getting Started</em> guides for both of these projects
174               come as prerequisite reading:
175             </p>
176             <ul>
177               <li><a href="http://llvm.org/docs/GettingStarted.html">LLVM</a></li>
178               <li><a href="http://clang.llvm.org/get_started.html">Clang</a></li>
179             </ul>
180             <p>Supported compilers for building LLDB on Linux include:</p>
181             <ul>
182               <li>Clang 3.2</li>
183               <li><a href="http://gcc.gnu.org">GCC</a> 4.6.2 (later versions should work as well)</li>
184             </ul>
185             <p>It is recommended to use libstdc++ 4.6 (or higher) to build LLDB on Linux, but using libc++ is also known to work.</p>
186             <p>
187               On FreeBSD the base system Clang and libc++ may be used to build LLDB,
188               or the GCC port or package.
189             </p>
190             <p>
191               On NetBSD the base system GCC and libstdc++ are used to build LLDB,
192               Clang/LLVM and libc++ should also work.
193             </p>
194             <p>
195               In addition to any dependencies required by LLVM and Clang, LLDB needs a few
196               development packages that may also need to be installed depending on your
197               system.  The current list of dependencies are:
198             </p>
199             <ul>
200               <li><a href="http://swig.org">Swig</a></li>
201               <li><a href="http://www.thrysoee.dk/editline">libedit</a> (Linux only)</li>
202               <li><a href="http://www.python.org">Python</a></li>
203             </ul>
204             <p>So for example, on a Fedora system one might run:</p>
205             <code>&gt; yum install libedit-devel libxml2-devel ncurses-devel python-devel swig</code>
206             <p>On a Debian or Ubuntu system one might run:</p>
207             <code>&gt; sudo apt-get install build-essential subversion swig python2.7-dev libedit-dev libncurses5-dev </code>
208             <p>or</p>
209             <code>&gt; sudo apt-get build-dep lldb-3.3 # or lldb-3.4</code>
210             <p>On FreeBSD one might run:</p>
211             <code>&gt; pkg install swig python</code>
212             <p>On NetBSD one might run:</p>
213             <code>&gt; pkgin install swig python27 cmake ninja-build</code>
214             <p>If you wish to build the optional reference documentation, additional dependencies are required:</p>
215             <ul>
216               <li> Graphviz (for the 'dot' tool).
217               </li>
218               <li> doxygen (only if you wish to build the C++ API reference)
219               </li>
220               <li> epydoc (only if you wish to build the Python API reference)
221               </li>
222             </ul>
223             <p>To install the prerequisites for building the documentation (on Debian/Ubuntu) do:</p>
224             <code>
225               <br />&gt; sudo apt-get install doxygen graphviz
226               <br />&gt; sudo pip install epydoc # or install package python-epydoc
227             </code>
228             <h2>Building LLDB</h2>
229             <p>
230               We first need to checkout the source trees into the appropriate locations.  Both
231               Clang and LLDB build as subprojects of LLVM.  This means we will be checking out
232               the source for both Clang and LLDB into the <tt>tools</tt> subdirectory of LLVM.  We
233               will be setting up a directory hierarchy looking something like this:
234             </p>
235             <p>
236               <pre><tt>  
237                   llvm
238                   |
239                   `-- tools
240                       |
241                       +-- clang
242                       |
243                       `-- lldb
244                 </tt></pre>
245             </p>
246             <p>
247               For reference, we will call the root of the LLVM project tree <tt>$llvm</tt>, and the
248               roots of the Clang and LLDB source trees <tt>$clang</tt> and <tt>$lldb</tt> respectively.
249             </p>
250             <p>Change to the directory where you want to do development work and checkout LLVM:</p>
251             <code>&gt; svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm</code>
252
253             <p>Now switch to LLVM&#8217;s tools subdirectory and checkout both Clang and LLDB:</p>
254             <code>
255               &gt; cd $llvm/tools
256               <br />&gt; svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
257               <br />&gt; svn co http://llvm.org/svn/llvm-project/lldb/trunk lldb
258             </code>
259
260             <p>
261               In general, building the LLDB trunk revision requires trunk revisions of both
262               LLVM and Clang.
263             </p>
264             <p>
265               It is highly recommended that you build the system out of tree.  Create a second
266               build directory and configure the LLVM project tree to your specifications as
267               outlined in LLVM&#8217;s <em>Getting Started Guide</em>.  A typical build procedure
268               might be:
269             </p>
270             <code>
271               &gt; cd $llvm/..
272               <br />&gt; mkdir build
273               <br />&gt; cd build
274             </code>
275             <h2>To build with CMake</h2>
276             <p>
277               Using CMake is documented on the <a href="http://llvm.org/docs/CMake.html">Building LLVM with CMake</a>
278               page. Building LLDB is possible using one of the following generators:
279             </p>
280             <ul>
281               <li> Ninja </li>
282               <li> Unix Makefiles </li>
283             </ul>
284             <h3>Using CMake + Ninja</h3>
285             <p>
286               Ninja is the fastest way to build LLDB! In order to use ninja, you need to have recent versions of CMake and
287               ninja on your system. To build using ninja:
288             </p>
289             <code>
290               &gt; cmake ../llvm -G Ninja
291               <br />&gt; ninja lldb
292               <br />&gt; ninja check-lldb
293             </code>
294             <p>
295               If you want to debug the lldb that you're building -- that is, build it with debug info enabled -- pass
296               two additional arguments to cmake before running ninja:
297             </p>
298             <code>
299               &gt; cmake ../llvm -G Ninja -DLLDB_EXPORT_ALL_SYMBOLS=1 -DCMAKE_BUILD_TYPE=Debug
300             </code>
301             <h3>Using CMake + Unix Makefiles</h3>
302             <p>If you do not have Ninja, you can still use CMake to generate Unix Makefiles that build LLDB:</p>
303             <code>
304               &gt; cmake ..
305               <br />&gt; make
306               <br />&gt; make check-lldb
307             </code>
308             <h2>Building API reference documentation</h2>
309             <p>
310               LLDB exposes a C++ as well as a Python API. To build the reference documentation for these two APIs, ensure you have
311               the required dependencies installed, and build the <tt>lldb-python-doc</tt> and <tt>lldb-cpp-doc</tt> CMake targets.
312             </p>
313             <p> The output HTML reference documentation can be found in <tt>&lt;build-dir&gt;/tools/lldb/docs/</tt>.</p><p>
314               <h2>Additional Notes</h2>
315             </p>
316             <p>
317               LLDB has a Python scripting capability and supplies its own Python module named <tt>lldb</tt>.
318               If a script is run inside the command line <tt>lldb</tt> application, the Python module
319               is made available automatically.  However, if a script is to be run by a Python interpreter
320               outside the command line application, the <tt>PYTHONPATH</tt> environment variable can be used
321               to let the Python interpreter find the <tt>lldb</tt> module.
322             </p>
323             <p>
324               Current stable NetBSD release doesn't ship with libpanel(3), therefore it's required to disable curses(3) support with
325               the <tt>-DLLDB_DISABLE_CURSES:BOOL=TRUE</tt> option. To make sure check if <tt>/usr/include/panel.h</tt> exists in your
326               system.
327             </p>
328             <p>The correct path can be obtained by invoking the command line <tt>lldb</tt> tool with the -P flag:</p>
329             <code>&gt; export PYTHONPATH=`$llvm/build/Debug+Asserts/bin/lldb -P`</code>
330             <p>
331               If you used a different build directory or made a release build, you may need to adjust the
332               above to suit your needs. To test that the lldb Python module
333               is built correctly and is available to the default Python interpreter, run:
334             </p>
335             <code>&gt; python -c 'import lldb'</code></p>
336
337             <h2 id="cross-compilation">Cross-compiling LLDB</h2>
338             <p>
339               In order to debug remote targets running different architectures than your host, you
340               will need to compile LLDB (or at least the server component) for the target. While
341               the easiest solution is to just compile it locally on the target, this is often not
342               feasible, and in these cases you will need to cross-compile LLDB on your host.
343             </p>
344
345             <p>
346               Cross-compilation is often a daunting task and has a lot of quirks which depend on
347               the exact host and target architectures, so it is not possible to give a universal
348               guide which will work on all platforms. However, here we try to provide an overview
349               of the cross-compilation process along with the main things you should look out for.
350             </p>
351
352             <p>
353               First, you will need a working toolchain which is capable of producing binaries for
354               the target architecture. Since you already have a checkout of clang and lldb, you
355               can compile a host version of clang in a separate folder and use that.
356               Alternatively you can use system clang or even cross-gcc if your distribution
357               provides such packages (e.g., <code>g++-aarch64-linux-gnu</code>
358               on Ubuntu).
359             </p>
360
361             <p>
362               Next, you will need a copy of the required target headers and libraries on your
363               host. The libraries can be usually obtained by copying from the target machine,
364               however the headers are often not found there, especially in case of embedded
365               platforms. In this case, you will need to obtain them from another source, either
366               a cross-package if one is available, or cross-compiling the respective library from
367               source. Fortunately the list of LLDB dependencies is not big and if you are only
368               interested in the server component, you can reduce this even further by passing the
369               appropriate cmake options, such as:
370             </p>
371             <code>
372               -DLLDB_DISABLE_LIBEDIT=1<br/>
373               -DLLDB_DISABLE_CURSES=1<br/>
374               -DLLDB_DISABLE_PYTHON=1<br/>
375               -DLLVM_ENABLE_TERMINFO=0
376             </code>
377             <p>
378               In this case you, will often not need anything other than the standard C and C++
379               libraries.
380             </p>
381
382             <p>
383               Once all of the dependencies are in place, it's just a matter of configuring the
384               build system with the locations and arguments of all the necessary tools. The most
385               important cmake options here are:
386             </p>
387             <dl>
388                 <dt>CMAKE_CROSSCOMPILING</dt>
389                 <dd>Set to 1 to enable cross-compilation.</dd>
390
391                 <dt>CMAKE_LIBRARY_ARCHITECTURE</dt>
392                 <dd>Affects the cmake search path when looking for libraries. You may need to set
393                 this to your architecture triple if you do not specify all your include and
394                 library paths explicitly.</dd>
395
396                 <dt>CMAKE_C_COMPILER, CMAKE_CXX_COMPILER</dt>
397                 <dd>C and C++ compilers for the target architecture</dd>
398
399                 <dt>CMAKE_C_FLAGS, CMAKE_CXX_FLAGS</dt>
400                 <dd>The flags for the C and C++ target compilers. You may need to specify the
401                 exact target cpu and abi besides the include paths for the target headers.</dd>
402
403                 <dt>CMAKE_EXE_LINKER_FLAGS</dt>
404                 <dd>The flags to be passed to the linker. Usually just a list of library search
405                 paths referencing the target libraries.</dd>
406
407                 <dt>LLVM_TABLEGEN, CLANG_TABLEGEN</dt>
408                 <dd>Paths to llvm-tblgen and clang-tblgen for the <em>host</em> architecture. If
409                 you already have built clang for the host, you can point these variables to the
410                 executables in your build directory. If not, you will need to build the
411                 llvm-tblgen and clang-tblgen host targets at least.<dd>
412
413                 <dt>LLVM_HOST_TRIPLE</dt>
414                 <dd>The triple of the system that lldb (or lldb-server) will run on. Not setting
415                 this (or setting it incorrectly) can cause a lot of issues with remote debugging
416                 as a lot of the choices lldb makes depend on the triple reported by the remote
417                 platform.</dd>
418             </dl>
419             <p>
420               You can of course also specify the usual cmake options like CMAKE_BUILD_TYPE, etc.
421             </p>
422
423             <h3>Example 1: Cross-compiling for linux arm64 on Ubuntu host</h3>
424
425             <p>
426               Ubuntu already provides the packages necessary to cross-compile LLDB for arm64. It
427               is sufficient to install packages gcc-aarch64-linux-gnu, g++-aarch64-linux-gnu,
428               binutils-aarch64-linux-gnu. Then it is possible to prepare the cmake build with the
429               following parameters:
430             </p>
431             <code>
432               -DCMAKE_CROSSCOMPILING=1 \<br/>
433               -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \<br/>
434               -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \<br/>
435               -DLLVM_HOST_TRIPLE=aarch64-unknown-linux-gnu \<br/>
436               -DLLVM_TABLEGEN=&lt;path-to-host&gt;/bin/llvm-tblgen \<br/>
437               -DCLANG_TABLEGEN=&lt;path-to-host&gt;/bin/clang-tblgen \<br/>
438               -DLLDB_DISABLE_PYTHON=1 \<br/>
439               -DLLDB_DISABLE_LIBEDIT=1 \<br/>
440               -DLLDB_DISABLE_CURSES=1
441             </code>
442
443             <p>
444               An alternative (and recommended) way to compile LLDB is with clang. Unfortunately,
445               clang is not able to find all the include paths necessary for a successful
446               cross-compile, so we need to help it with a couple of CFLAGS options. In my case it
447               was sufficient to add the following arguments to CMAKE_C_FLAGS and CMAKE_CXX_FLAGS
448               (in addition to changing CMAKE_C(XX)_COMPILER to point to clang compilers):
449             </p>
450             <code>
451               -target aarch64-linux-gnu \<br/>
452               -I /usr/aarch64-linux-gnu/include/c++/4.8.2/aarch64-linux-gnu \<br/>
453               -I /usr/aarch64-linux-gnu/include
454             </code>
455
456             <p>
457               If you wanted to build a full version of LLDB and avoid passing
458               -DLLDB_DISABLE_PYTHON and other options, you would need to obtain the target
459               versions of the respective libraries. The easiest way to achieve this is to use the
460               <code>qemu-debootstrap</code> utility, which can prepare a system image using qemu
461               and chroot to simulate the target environment. Then you can install the necessary
462               packages in this environment (python-dev, libedit-dev, etc.) and point your
463               compiler to use them using the correct -I and -L arguments.
464             </p>
465
466             <h3>Example 2: Cross-compiling for Android on Linux</h3>
467
468             <p>
469               In the case of Android, the toolchain and all required headers and
470               libraries are available in the Android NDK.
471             </p>
472
473             <p>
474               The NDK also contains a cmake toolchain file, which makes
475               configuring the build much simpler.  The compiler, include and
476               library paths will be configured by the toolchain file and all you
477               need to do is to select the architecture (ANDROID_ABI) and
478               platform level (ANDROID_PLATFORM, should be at least 21). You will
479               also need to set ANDROID_ALLOW_UNDEFINED_SYMBOLS=On, as the
480               toolchain file defaults to "no undefined symbols in shared
481               libraries", which is not compatible with some llvm libraries. The
482               first version of NDK which supports this approach is r14.
483             </p>
484             <p>
485               For example, the following arguments are sufficient to configure
486               an android arm64 build:
487             </p>
488             <code>
489               -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake \<br/>
490               -DANDROID_ABI=arm64-v8a \<br/>
491               -DANDROID_PLATFORM=android-21 \<br/>
492               -DANDROID_ALLOW_UNDEFINED_SYMBOLS=On \<br/>
493               -DLLVM_HOST_TRIPLE=aarch64-unknown-linux-android \<br/>
494               -DCROSS_TOOLCHAIN_FLAGS_NATIVE='-DCMAKE_C_COMPILER=cc;-DCMAKE_CXX_COMPILER=c++' <br/>
495             </code>
496
497             <p>
498               Note that currently only lldb-server is functional on android. The
499               lldb client is not supported and unlikely to work.
500             </p>
501           </div>
502           <div class="postfooter"></div>
503         </div>
504       </div>
505     </div>
506   </div>
507 </body>
508 </html>