BuildingLibunwind.rst 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. .. _BuildingLibunwind:
  2. ==================
  3. Building libunwind
  4. ==================
  5. .. contents::
  6. :local:
  7. .. _build instructions:
  8. Getting Started
  9. ===============
  10. On Mac OS, the easiest way to get this library is to link with -lSystem.
  11. However if you want to build tip-of-trunk from here (getting the bleeding
  12. edge), read on.
  13. The basic steps needed to build libc++ are:
  14. #. Checkout LLVM, libunwind, and related projects:
  15. * ``cd where-you-want-llvm-to-live``
  16. * ``git clone https://github.com/llvm/llvm-project.git``
  17. #. Configure and build libunwind:
  18. CMake is the only supported configuration system.
  19. Clang is the preferred compiler when building and using libunwind.
  20. * ``cd where you want to build llvm``
  21. * ``mkdir build``
  22. * ``cd build``
  23. * ``cmake -G <generator> -DLLVM_ENABLE_PROJECTS=libunwind [options] <path to llvm sources>``
  24. For more information about configuring libunwind see :ref:`CMake Options`.
  25. * ``make unwind`` --- will build libunwind.
  26. * ``make check-unwind`` --- will run the test suite.
  27. Shared and static libraries for libunwind should now be present in llvm/build/lib.
  28. #. **Optional**: Install libunwind
  29. If your system already provides an unwinder, it is important to be careful
  30. not to replace it. Remember Use the CMake option ``CMAKE_INSTALL_PREFIX`` to
  31. select a safe place to install libunwind.
  32. * ``make install-unwind`` --- Will install the libraries and the headers
  33. It is sometimes beneficial to build outside of the LLVM tree. An out-of-tree
  34. build would look like this:
  35. .. code-block:: bash
  36. $ cd where-you-want-libunwind-to-live
  37. $ # Check out llvm, and libunwind
  38. $ ``svn co https://llvm.org/svn/llvm-project/llvm/trunk llvm``
  39. $ ``svn co https://llvm.org/svn/llvm-project/libunwind/trunk libunwind``
  40. $ cd where-you-want-to-build
  41. $ mkdir build && cd build
  42. $ export CC=clang CXX=clang++
  43. $ cmake -DLLVM_PATH=path/to/llvm \
  44. path/to/libunwind
  45. $ make
  46. .. _CMake Options:
  47. CMake Options
  48. =============
  49. Here are some of the CMake variables that are used often, along with a
  50. brief explanation and LLVM-specific notes. For full documentation, check the
  51. CMake docs or execute ``cmake --help-variable VARIABLE_NAME``.
  52. **CMAKE_BUILD_TYPE**:STRING
  53. Sets the build type for ``make`` based generators. Possible values are
  54. Release, Debug, RelWithDebInfo and MinSizeRel. On systems like Visual Studio
  55. the user sets the build type with the IDE settings.
  56. **CMAKE_INSTALL_PREFIX**:PATH
  57. Path where LLVM will be installed if "make install" is invoked or the
  58. "INSTALL" target is built.
  59. **CMAKE_CXX_COMPILER**:STRING
  60. The C++ compiler to use when building and testing libunwind.
  61. .. _libunwind-specific options:
  62. libunwind specific options
  63. --------------------------
  64. .. option:: LIBUNWIND_BUILD_32_BITS:BOOL
  65. **Default**: Same as LLVM_BUILD_32_BITS
  66. Toggle whether libunwind should be built with -m32.
  67. .. option:: LIBUNWIND_ENABLE_ASSERTIONS:BOOL
  68. **Default**: ``ON``
  69. Toggle assertions independent of the build mode.
  70. .. option:: LIBUNWIND_ENABLE_PEDANTIC:BOOL
  71. **Default**: ``ON``
  72. Compile with -Wpedantic.
  73. .. option:: LIBUNWIND_ENABLE_WERROR:BOOL
  74. **Default**: ``ON``
  75. Compile with -Werror
  76. .. option:: LIBUNWIND_ENABLE_SHARED:BOOL
  77. **Default**: ``ON``
  78. Build libunwind as a shared library.
  79. .. option:: LIBUNWIND_ENABLE_STATIC:BOOL
  80. **Default**: ``ON``
  81. Build libunwind as a static archive.
  82. .. option:: LIBUNWIND_ENABLE_CROSS_UNWINDING:BOOL
  83. **Default**: ``OFF``
  84. Enable cross-platform unwinding support.
  85. .. option:: LIBUNWIND_ENABLE_ARM_WMMX:BOOL
  86. **Default**: ``OFF``
  87. Enable unwinding support for ARM WMMX registers.
  88. .. option:: LIBUNWIND_ENABLE_THREADS:BOOL
  89. **Default**: ``ON``
  90. Build libunwind with threading support.
  91. .. option:: LIBUNWIND_TARGET_TRIPLE:STRING
  92. Target triple for cross compiling
  93. .. option:: LIBUNWIND_GCC_TOOLCHAIN:PATH
  94. GCC toolchain for cross compiling
  95. .. option:: LIBUNWIND_SYSROOT
  96. Sysroot for cross compiling