[Lldb-commits] [PATCH] D158085: [LLDB][Docs] Update cross compilation docs and examples

David Spickett via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Aug 16 07:40:21 PDT 2023


DavidSpickett created this revision.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

To address https://github.com/llvm/llvm-project/issues/64616, this change
does the following:

- Links back to the "Optional Dependencies" section from the cross compilation instructions where we talk about removing libraries. In the reported issue, the host libXML was found by CMAke somehow and disabling libXML fixed it, so this link should encourage users to try as many of those options as needed.

- Removes the use of CMAKE_CROSS_COMPILING. In older CMake versions it seems you could set this manually but now the advice is to set CMAKE_SYSTEM_NAME and CMAKE_SYSTEM_PROCESSOR then let CMake figure it out.

  There is also CMAKE_SYSTEM_VERSION which the docs say you have to set too, but I can only find examples of Windows and Android builds using this. It might be needed to "cross" compile from one version of AArch64 Linux to another, but I can't confirm that.

- Removes the tablegen tools paths in favour of DLLVM_NATIVE_TOOL_DIR. This one setting deals with all build tools in llvm that must be host versions.

- Updates the explanations of the common options and orders them in some rough order of relevance with the "might be needed" later.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158085

Files:
  lldb/docs/resources/build.rst


Index: lldb/docs/resources/build.rst
===================================================================
--- lldb/docs/resources/build.rst
+++ lldb/docs/resources/build.rst
@@ -36,6 +36,8 @@
 * `Python <http://www.python.org/>`_
 * `SWIG <http://swig.org/>`_ 4 or later.
 
+.. _Optional Dependencies:
+
 Optional Dependencies
 *********************
 
@@ -458,6 +460,8 @@
   -DLLDB_ENABLE_CURSES=0
   -DLLVM_ENABLE_TERMINFO=0
 
+(see :ref:`Optional Dependencies` for more)
+
 In this case you, will often not need anything other than the standard C and
 C++ libraries.
 
@@ -465,26 +469,29 @@
 the build system with the locations and arguments of all the necessary tools.
 The most important cmake options here are:
 
-* ``CMAKE_CROSSCOMPILING`` : Set to 1 to enable cross-compilation.
-* ``CMAKE_LIBRARY_ARCHITECTURE`` : Affects the cmake search path when looking
-  for libraries. You may need to set this to your architecture triple if you do
-  not specify all your include and library paths explicitly.
+* ``CMAKE_SYSTEM_NAME`` and ``CMAKE_SYSTEM_PROCESSOR``: This tells CMake what
+  the build target is and from this it will infer that you are cross compiling.
 * ``CMAKE_C_COMPILER``, ``CMAKE_CXX_COMPILER`` : C and C++ compilers for the
-  target architecture
+  target architecture.
 * ``CMAKE_C_FLAGS``, ``CMAKE_CXX_FLAGS`` : The flags for the C and C++ target
-  compilers. You may need to specify the exact target cpu and abi besides the
+  compilers. You may need to specify the exact target cpu and ABI besides the
   include paths for the target headers.
 * ``CMAKE_EXE_LINKER_FLAGS`` : The flags to be passed to the linker. Usually
   just a list of library search paths referencing the target libraries.
-* ``LLVM_TABLEGEN``, ``CLANG_TABLEGEN`` : Paths to llvm-tblgen and clang-tblgen
-  for the host architecture. If you already have built clang for the host, you
-  can point these variables to the executables in your build directory. If not,
-  you will need to build the llvm-tblgen and clang-tblgen host targets at
-  least.
 * ``LLVM_HOST_TRIPLE`` : The triple of the system that lldb (or lldb-server)
   will run on. Not setting this (or setting it incorrectly) can cause a lot of
   issues with remote debugging as a lot of the choices lldb makes depend on the
   triple reported by the remote platform.
+* ``LLVM_NATIVE_TOOL_DIR`` : Is a path to the llvm tools compiled for the host.
+  Any tool that must be run on the host during a cross build will be configured
+  from this path, so you do not need to set them all individually. If you are
+  doing a host build just for the purpose of a cross build, you will need it
+  to include at least ``llvm-tblgen``, ``clang-tblgen`` and ``lldb-tblgen``.
+  Please be aware that that list may grow over time.
+* ``CMAKE_LIBRARY_ARCHITECTURE`` : Affects the cmake search path when looking
+  for libraries. You may need to set this to your architecture triple if you do
+  not specify all your include and library paths explicitly.
+
 
 You can of course also specify the usual cmake options like
 ``CMAKE_BUILD_TYPE``, etc.
@@ -499,12 +506,12 @@
 
 ::
 
-  -DCMAKE_CROSSCOMPILING=1 \
+  -DCMAKE_SYSTEM_NAME=Linux \
+  -DCMAKE_SYSTEM_PROCESSOR=AArch64 \
   -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
   -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \
   -DLLVM_HOST_TRIPLE=aarch64-unknown-linux-gnu \
-  -DLLVM_TABLEGEN=<path-to-host>/bin/llvm-tblgen \
-  -DCLANG_TABLEGEN=<path-to-host>/bin/clang-tblgen \
+  -DLLVM_NATIVE_TOOL_DIR=<path-to-host>/bin/ \
   -DLLDB_ENABLE_PYTHON=0 \
   -DLLDB_ENABLE_LIBEDIT=0 \
   -DLLDB_ENABLE_CURSES=0


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158085.550748.patch
Type: text/x-patch
Size: 3606 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230816/c22e3343/attachment-0001.bin>


More information about the lldb-commits mailing list