1*58b9f456SAndroid Build Coastguard Worker.. _BuildingLibcxx: 2*58b9f456SAndroid Build Coastguard Worker 3*58b9f456SAndroid Build Coastguard Worker=============== 4*58b9f456SAndroid Build Coastguard WorkerBuilding libc++ 5*58b9f456SAndroid Build Coastguard Worker=============== 6*58b9f456SAndroid Build Coastguard Worker 7*58b9f456SAndroid Build Coastguard Worker.. contents:: 8*58b9f456SAndroid Build Coastguard Worker :local: 9*58b9f456SAndroid Build Coastguard Worker 10*58b9f456SAndroid Build Coastguard Worker.. _build instructions: 11*58b9f456SAndroid Build Coastguard Worker 12*58b9f456SAndroid Build Coastguard WorkerGetting Started 13*58b9f456SAndroid Build Coastguard Worker=============== 14*58b9f456SAndroid Build Coastguard Worker 15*58b9f456SAndroid Build Coastguard WorkerOn Mac OS 10.7 (Lion) and later, the easiest way to get this library is to install 16*58b9f456SAndroid Build Coastguard WorkerXcode 4.2 or later. However if you want to install tip-of-trunk from here 17*58b9f456SAndroid Build Coastguard Worker(getting the bleeding edge), read on. 18*58b9f456SAndroid Build Coastguard Worker 19*58b9f456SAndroid Build Coastguard WorkerThe basic steps needed to build libc++ are: 20*58b9f456SAndroid Build Coastguard Worker 21*58b9f456SAndroid Build Coastguard Worker#. Checkout LLVM: 22*58b9f456SAndroid Build Coastguard Worker 23*58b9f456SAndroid Build Coastguard Worker * ``cd where-you-want-llvm-to-live`` 24*58b9f456SAndroid Build Coastguard Worker * ``svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm`` 25*58b9f456SAndroid Build Coastguard Worker 26*58b9f456SAndroid Build Coastguard Worker#. Checkout libc++: 27*58b9f456SAndroid Build Coastguard Worker 28*58b9f456SAndroid Build Coastguard Worker * ``cd where-you-want-llvm-to-live`` 29*58b9f456SAndroid Build Coastguard Worker * ``cd llvm/projects`` 30*58b9f456SAndroid Build Coastguard Worker * ``svn co http://llvm.org/svn/llvm-project/libcxx/trunk libcxx`` 31*58b9f456SAndroid Build Coastguard Worker 32*58b9f456SAndroid Build Coastguard Worker#. Checkout libc++abi: 33*58b9f456SAndroid Build Coastguard Worker 34*58b9f456SAndroid Build Coastguard Worker * ``cd where-you-want-llvm-to-live`` 35*58b9f456SAndroid Build Coastguard Worker * ``cd llvm/projects`` 36*58b9f456SAndroid Build Coastguard Worker * ``svn co http://llvm.org/svn/llvm-project/libcxxabi/trunk libcxxabi`` 37*58b9f456SAndroid Build Coastguard Worker 38*58b9f456SAndroid Build Coastguard Worker#. Configure and build libc++ with libc++abi: 39*58b9f456SAndroid Build Coastguard Worker 40*58b9f456SAndroid Build Coastguard Worker CMake is the only supported configuration system. 41*58b9f456SAndroid Build Coastguard Worker 42*58b9f456SAndroid Build Coastguard Worker Clang is the preferred compiler when building and using libc++. 43*58b9f456SAndroid Build Coastguard Worker 44*58b9f456SAndroid Build Coastguard Worker * ``cd where you want to build llvm`` 45*58b9f456SAndroid Build Coastguard Worker * ``mkdir build`` 46*58b9f456SAndroid Build Coastguard Worker * ``cd build`` 47*58b9f456SAndroid Build Coastguard Worker * ``cmake -G <generator> [options] <path to llvm sources>`` 48*58b9f456SAndroid Build Coastguard Worker 49*58b9f456SAndroid Build Coastguard Worker For more information about configuring libc++ see :ref:`CMake Options`. 50*58b9f456SAndroid Build Coastguard Worker 51*58b9f456SAndroid Build Coastguard Worker * ``make cxx`` --- will build libc++ and libc++abi. 52*58b9f456SAndroid Build Coastguard Worker * ``make check-cxx check-cxxabi`` --- will run the test suites. 53*58b9f456SAndroid Build Coastguard Worker 54*58b9f456SAndroid Build Coastguard Worker Shared libraries for libc++ and libc++ abi should now be present in llvm/build/lib. 55*58b9f456SAndroid Build Coastguard Worker See :ref:`using an alternate libc++ installation <alternate libcxx>` 56*58b9f456SAndroid Build Coastguard Worker 57*58b9f456SAndroid Build Coastguard Worker#. **Optional**: Install libc++ and libc++abi 58*58b9f456SAndroid Build Coastguard Worker 59*58b9f456SAndroid Build Coastguard Worker If your system already provides a libc++ installation it is important to be 60*58b9f456SAndroid Build Coastguard Worker careful not to replace it. Remember Use the CMake option ``CMAKE_INSTALL_PREFIX`` to 61*58b9f456SAndroid Build Coastguard Worker select a safe place to install libc++. 62*58b9f456SAndroid Build Coastguard Worker 63*58b9f456SAndroid Build Coastguard Worker * ``make install-cxx install-cxxabi`` --- Will install the libraries and the headers 64*58b9f456SAndroid Build Coastguard Worker 65*58b9f456SAndroid Build Coastguard Worker .. warning:: 66*58b9f456SAndroid Build Coastguard Worker * Replacing your systems libc++ installation could render the system non-functional. 67*58b9f456SAndroid Build Coastguard Worker * Mac OS X will not boot without a valid copy of ``libc++.1.dylib`` in ``/usr/lib``. 68*58b9f456SAndroid Build Coastguard Worker 69*58b9f456SAndroid Build Coastguard Worker 70*58b9f456SAndroid Build Coastguard WorkerThe instructions are for building libc++ on 71*58b9f456SAndroid Build Coastguard WorkerFreeBSD, Linux, or Mac using `libc++abi`_ as the C++ ABI library. 72*58b9f456SAndroid Build Coastguard WorkerOn Linux, it is also possible to use :ref:`libsupc++ <libsupcxx>` or libcxxrt. 73*58b9f456SAndroid Build Coastguard Worker 74*58b9f456SAndroid Build Coastguard WorkerIt is sometimes beneficial to build outside of the LLVM tree. An out-of-tree 75*58b9f456SAndroid Build Coastguard Workerbuild would look like this: 76*58b9f456SAndroid Build Coastguard Worker 77*58b9f456SAndroid Build Coastguard Worker.. code-block:: bash 78*58b9f456SAndroid Build Coastguard Worker 79*58b9f456SAndroid Build Coastguard Worker $ cd where-you-want-libcxx-to-live 80*58b9f456SAndroid Build Coastguard Worker $ # Check out llvm, libc++ and libc++abi. 81*58b9f456SAndroid Build Coastguard Worker $ ``svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm`` 82*58b9f456SAndroid Build Coastguard Worker $ ``svn co http://llvm.org/svn/llvm-project/libcxx/trunk libcxx`` 83*58b9f456SAndroid Build Coastguard Worker $ ``svn co http://llvm.org/svn/llvm-project/libcxxabi/trunk libcxxabi`` 84*58b9f456SAndroid Build Coastguard Worker $ cd where-you-want-to-build 85*58b9f456SAndroid Build Coastguard Worker $ mkdir build && cd build 86*58b9f456SAndroid Build Coastguard Worker $ export CC=clang CXX=clang++ 87*58b9f456SAndroid Build Coastguard Worker $ cmake -DLLVM_PATH=path/to/llvm \ 88*58b9f456SAndroid Build Coastguard Worker -DLIBCXX_CXX_ABI=libcxxabi \ 89*58b9f456SAndroid Build Coastguard Worker -DLIBCXX_CXX_ABI_INCLUDE_PATHS=path/to/libcxxabi/include \ 90*58b9f456SAndroid Build Coastguard Worker path/to/libcxx 91*58b9f456SAndroid Build Coastguard Worker $ make 92*58b9f456SAndroid Build Coastguard Worker $ make check-libcxx # optional 93*58b9f456SAndroid Build Coastguard Worker 94*58b9f456SAndroid Build Coastguard Worker 95*58b9f456SAndroid Build Coastguard WorkerExperimental Support for Windows 96*58b9f456SAndroid Build Coastguard Worker-------------------------------- 97*58b9f456SAndroid Build Coastguard Worker 98*58b9f456SAndroid Build Coastguard WorkerThe Windows support requires building with clang-cl as cl does not support one 99*58b9f456SAndroid Build Coastguard Workerrequired extension: `#include_next`. Furthermore, VS 2015 or newer (19.00) is 100*58b9f456SAndroid Build Coastguard Workerrequired. In the case of clang-cl, we need to specify the "MS Compatibility 101*58b9f456SAndroid Build Coastguard WorkerVersion" as it defaults to 2014 (18.00). 102*58b9f456SAndroid Build Coastguard Worker 103*58b9f456SAndroid Build Coastguard WorkerCMake + Visual Studio 104*58b9f456SAndroid Build Coastguard Worker~~~~~~~~~~~~~~~~~~~~~ 105*58b9f456SAndroid Build Coastguard Worker 106*58b9f456SAndroid Build Coastguard WorkerBuilding with Visual Studio currently does not permit running tests. However, 107*58b9f456SAndroid Build Coastguard Workerit is the simplest way to build. 108*58b9f456SAndroid Build Coastguard Worker 109*58b9f456SAndroid Build Coastguard Worker.. code-block:: batch 110*58b9f456SAndroid Build Coastguard Worker 111*58b9f456SAndroid Build Coastguard Worker > cmake -G "Visual Studio 14 2015" ^ 112*58b9f456SAndroid Build Coastguard Worker -T "LLVM-vs2014" ^ 113*58b9f456SAndroid Build Coastguard Worker -DLIBCXX_ENABLE_SHARED=YES ^ 114*58b9f456SAndroid Build Coastguard Worker -DLIBCXX_ENABLE_STATIC=NO ^ 115*58b9f456SAndroid Build Coastguard Worker -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=NO ^ 116*58b9f456SAndroid Build Coastguard Worker \path\to\libcxx 117*58b9f456SAndroid Build Coastguard Worker > cmake --build . 118*58b9f456SAndroid Build Coastguard Worker 119*58b9f456SAndroid Build Coastguard WorkerCMake + ninja 120*58b9f456SAndroid Build Coastguard Worker~~~~~~~~~~~~~ 121*58b9f456SAndroid Build Coastguard Worker 122*58b9f456SAndroid Build Coastguard WorkerBuilding with ninja is required for development to enable tests. 123*58b9f456SAndroid Build Coastguard WorkerUnfortunately, doing so requires additional configuration as we cannot 124*58b9f456SAndroid Build Coastguard Workerjust specify a toolset. 125*58b9f456SAndroid Build Coastguard Worker 126*58b9f456SAndroid Build Coastguard Worker.. code-block:: batch 127*58b9f456SAndroid Build Coastguard Worker 128*58b9f456SAndroid Build Coastguard Worker > cmake -G Ninja ^ 129*58b9f456SAndroid Build Coastguard Worker -DCMAKE_MAKE_PROGRAM=/path/to/ninja ^ 130*58b9f456SAndroid Build Coastguard Worker -DCMAKE_SYSTEM_NAME=Windows ^ 131*58b9f456SAndroid Build Coastguard Worker -DCMAKE_C_COMPILER=clang-cl ^ 132*58b9f456SAndroid Build Coastguard Worker -DCMAKE_C_FLAGS="-fms-compatibility-version=19.00 --target=i686--windows" ^ 133*58b9f456SAndroid Build Coastguard Worker -DCMAKE_CXX_COMPILER=clang-cl ^ 134*58b9f456SAndroid Build Coastguard Worker -DCMAKE_CXX_FLAGS="-fms-compatibility-version=19.00 --target=i686--windows" ^ 135*58b9f456SAndroid Build Coastguard Worker -DLLVM_PATH=/path/to/llvm/tree ^ 136*58b9f456SAndroid Build Coastguard Worker -DLIBCXX_ENABLE_SHARED=YES ^ 137*58b9f456SAndroid Build Coastguard Worker -DLIBCXX_ENABLE_STATIC=NO ^ 138*58b9f456SAndroid Build Coastguard Worker -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=NO ^ 139*58b9f456SAndroid Build Coastguard Worker \path\to\libcxx 140*58b9f456SAndroid Build Coastguard Worker > /path/to/ninja cxx 141*58b9f456SAndroid Build Coastguard Worker > /path/to/ninja check-cxx 142*58b9f456SAndroid Build Coastguard Worker 143*58b9f456SAndroid Build Coastguard WorkerNote that the paths specified with backward slashes must use the `\\` as the 144*58b9f456SAndroid Build Coastguard Workerdirectory separator as clang-cl may otherwise parse the path as an argument. 145*58b9f456SAndroid Build Coastguard Worker 146*58b9f456SAndroid Build Coastguard Worker.. _`libc++abi`: http://libcxxabi.llvm.org/ 147*58b9f456SAndroid Build Coastguard Worker 148*58b9f456SAndroid Build Coastguard Worker 149*58b9f456SAndroid Build Coastguard Worker.. _CMake Options: 150*58b9f456SAndroid Build Coastguard Worker 151*58b9f456SAndroid Build Coastguard WorkerCMake Options 152*58b9f456SAndroid Build Coastguard Worker============= 153*58b9f456SAndroid Build Coastguard Worker 154*58b9f456SAndroid Build Coastguard WorkerHere are some of the CMake variables that are used often, along with a 155*58b9f456SAndroid Build Coastguard Workerbrief explanation and LLVM-specific notes. For full documentation, check the 156*58b9f456SAndroid Build Coastguard WorkerCMake docs or execute ``cmake --help-variable VARIABLE_NAME``. 157*58b9f456SAndroid Build Coastguard Worker 158*58b9f456SAndroid Build Coastguard Worker**CMAKE_BUILD_TYPE**:STRING 159*58b9f456SAndroid Build Coastguard Worker Sets the build type for ``make`` based generators. Possible values are 160*58b9f456SAndroid Build Coastguard Worker Release, Debug, RelWithDebInfo and MinSizeRel. On systems like Visual Studio 161*58b9f456SAndroid Build Coastguard Worker the user sets the build type with the IDE settings. 162*58b9f456SAndroid Build Coastguard Worker 163*58b9f456SAndroid Build Coastguard Worker**CMAKE_INSTALL_PREFIX**:PATH 164*58b9f456SAndroid Build Coastguard Worker Path where LLVM will be installed if "make install" is invoked or the 165*58b9f456SAndroid Build Coastguard Worker "INSTALL" target is built. 166*58b9f456SAndroid Build Coastguard Worker 167*58b9f456SAndroid Build Coastguard Worker**CMAKE_CXX_COMPILER**:STRING 168*58b9f456SAndroid Build Coastguard Worker The C++ compiler to use when building and testing libc++. 169*58b9f456SAndroid Build Coastguard Worker 170*58b9f456SAndroid Build Coastguard Worker 171*58b9f456SAndroid Build Coastguard Worker.. _libcxx-specific options: 172*58b9f456SAndroid Build Coastguard Worker 173*58b9f456SAndroid Build Coastguard Workerlibc++ specific options 174*58b9f456SAndroid Build Coastguard Worker----------------------- 175*58b9f456SAndroid Build Coastguard Worker 176*58b9f456SAndroid Build Coastguard Worker.. option:: LIBCXX_INSTALL_LIBRARY:BOOL 177*58b9f456SAndroid Build Coastguard Worker 178*58b9f456SAndroid Build Coastguard Worker **Default**: ``ON`` 179*58b9f456SAndroid Build Coastguard Worker 180*58b9f456SAndroid Build Coastguard Worker Toggle the installation of the library portion of libc++. 181*58b9f456SAndroid Build Coastguard Worker 182*58b9f456SAndroid Build Coastguard Worker.. option:: LIBCXX_INSTALL_HEADERS:BOOL 183*58b9f456SAndroid Build Coastguard Worker 184*58b9f456SAndroid Build Coastguard Worker **Default**: ``ON`` 185*58b9f456SAndroid Build Coastguard Worker 186*58b9f456SAndroid Build Coastguard Worker Toggle the installation of the libc++ headers. 187*58b9f456SAndroid Build Coastguard Worker 188*58b9f456SAndroid Build Coastguard Worker.. option:: LIBCXX_ENABLE_ASSERTIONS:BOOL 189*58b9f456SAndroid Build Coastguard Worker 190*58b9f456SAndroid Build Coastguard Worker **Default**: ``ON`` 191*58b9f456SAndroid Build Coastguard Worker 192*58b9f456SAndroid Build Coastguard Worker Build libc++ with assertions enabled. 193*58b9f456SAndroid Build Coastguard Worker 194*58b9f456SAndroid Build Coastguard Worker.. option:: LIBCXX_BUILD_32_BITS:BOOL 195*58b9f456SAndroid Build Coastguard Worker 196*58b9f456SAndroid Build Coastguard Worker **Default**: ``OFF`` 197*58b9f456SAndroid Build Coastguard Worker 198*58b9f456SAndroid Build Coastguard Worker Build libc++ as a 32 bit library. Also see `LLVM_BUILD_32_BITS`. 199*58b9f456SAndroid Build Coastguard Worker 200*58b9f456SAndroid Build Coastguard Worker.. option:: LIBCXX_ENABLE_SHARED:BOOL 201*58b9f456SAndroid Build Coastguard Worker 202*58b9f456SAndroid Build Coastguard Worker **Default**: ``ON`` 203*58b9f456SAndroid Build Coastguard Worker 204*58b9f456SAndroid Build Coastguard Worker Build libc++ as a shared library. Either `LIBCXX_ENABLE_SHARED` or 205*58b9f456SAndroid Build Coastguard Worker `LIBCXX_ENABLE_STATIC` has to be enabled. 206*58b9f456SAndroid Build Coastguard Worker 207*58b9f456SAndroid Build Coastguard Worker.. option:: LIBCXX_ENABLE_STATIC:BOOL 208*58b9f456SAndroid Build Coastguard Worker 209*58b9f456SAndroid Build Coastguard Worker **Default**: ``ON`` 210*58b9f456SAndroid Build Coastguard Worker 211*58b9f456SAndroid Build Coastguard Worker Build libc++ as a static library. Either `LIBCXX_ENABLE_SHARED` or 212*58b9f456SAndroid Build Coastguard Worker `LIBCXX_ENABLE_STATIC` has to be enabled. 213*58b9f456SAndroid Build Coastguard Worker 214*58b9f456SAndroid Build Coastguard Worker.. option:: LIBCXX_LIBDIR_SUFFIX:STRING 215*58b9f456SAndroid Build Coastguard Worker 216*58b9f456SAndroid Build Coastguard Worker Extra suffix to append to the directory where libraries are to be installed. 217*58b9f456SAndroid Build Coastguard Worker This option overrides `LLVM_LIBDIR_SUFFIX`. 218*58b9f456SAndroid Build Coastguard Worker 219*58b9f456SAndroid Build Coastguard Worker.. option:: LIBCXX_INSTALL_PREFIX:STRING 220*58b9f456SAndroid Build Coastguard Worker 221*58b9f456SAndroid Build Coastguard Worker **Default**: ``""`` 222*58b9f456SAndroid Build Coastguard Worker 223*58b9f456SAndroid Build Coastguard Worker Define libc++ destination prefix. 224*58b9f456SAndroid Build Coastguard Worker 225*58b9f456SAndroid Build Coastguard Worker.. option:: LIBCXX_HERMETIC_STATIC_LIBRARY:BOOL 226*58b9f456SAndroid Build Coastguard Worker 227*58b9f456SAndroid Build Coastguard Worker **Default**: ``OFF`` 228*58b9f456SAndroid Build Coastguard Worker 229*58b9f456SAndroid Build Coastguard Worker Do not export any symbols from the static libc++ library. This is useful when 230*58b9f456SAndroid Build Coastguard Worker This is useful when the static libc++ library is being linked into shared 231*58b9f456SAndroid Build Coastguard Worker libraries that may be used in with other shared libraries that use different 232*58b9f456SAndroid Build Coastguard Worker C++ library. We want to avoid avoid exporting any libc++ symbols in that case. 233*58b9f456SAndroid Build Coastguard Worker 234*58b9f456SAndroid Build Coastguard Worker.. _libc++experimental options: 235*58b9f456SAndroid Build Coastguard Worker 236*58b9f456SAndroid Build Coastguard Workerlibc++experimental Specific Options 237*58b9f456SAndroid Build Coastguard Worker------------------------------------ 238*58b9f456SAndroid Build Coastguard Worker 239*58b9f456SAndroid Build Coastguard Worker.. option:: LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY:BOOL 240*58b9f456SAndroid Build Coastguard Worker 241*58b9f456SAndroid Build Coastguard Worker **Default**: ``ON`` 242*58b9f456SAndroid Build Coastguard Worker 243*58b9f456SAndroid Build Coastguard Worker Build and test libc++experimental.a. 244*58b9f456SAndroid Build Coastguard Worker 245*58b9f456SAndroid Build Coastguard Worker.. option:: LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY:BOOL 246*58b9f456SAndroid Build Coastguard Worker 247*58b9f456SAndroid Build Coastguard Worker **Default**: ``LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY AND LIBCXX_INSTALL_LIBRARY`` 248*58b9f456SAndroid Build Coastguard Worker 249*58b9f456SAndroid Build Coastguard Worker Install libc++experimental.a alongside libc++. 250*58b9f456SAndroid Build Coastguard Worker 251*58b9f456SAndroid Build Coastguard Worker 252*58b9f456SAndroid Build Coastguard Worker.. option:: LIBCXX_ENABLE_FILESYSTEM:BOOL 253*58b9f456SAndroid Build Coastguard Worker 254*58b9f456SAndroid Build Coastguard Worker **Default**: ``ON`` 255*58b9f456SAndroid Build Coastguard Worker 256*58b9f456SAndroid Build Coastguard Worker Build filesystem as a standalone library libc++fs.a. 257*58b9f456SAndroid Build Coastguard Worker 258*58b9f456SAndroid Build Coastguard Worker.. option:: LIBCXX_INSTALL_FILESYSTEM_LIBRARY:BOOL 259*58b9f456SAndroid Build Coastguard Worker 260*58b9f456SAndroid Build Coastguard Worker **Default**: ``LIBCXX_ENABLE_FILESYSTEM AND LIBCXX_INSTALL_LIBRARY`` 261*58b9f456SAndroid Build Coastguard Worker 262*58b9f456SAndroid Build Coastguard Worker Install libc++fs.a alongside libc++. 263*58b9f456SAndroid Build Coastguard Worker 264*58b9f456SAndroid Build Coastguard Worker.. _ABI Library Specific Options: 265*58b9f456SAndroid Build Coastguard Worker 266*58b9f456SAndroid Build Coastguard WorkerABI Library Specific Options 267*58b9f456SAndroid Build Coastguard Worker---------------------------- 268*58b9f456SAndroid Build Coastguard Worker 269*58b9f456SAndroid Build Coastguard Worker.. option:: LIBCXX_CXX_ABI:STRING 270*58b9f456SAndroid Build Coastguard Worker 271*58b9f456SAndroid Build Coastguard Worker **Values**: ``none``, ``libcxxabi``, ``libcxxrt``, ``libstdc++``, ``libsupc++``. 272*58b9f456SAndroid Build Coastguard Worker 273*58b9f456SAndroid Build Coastguard Worker Select the ABI library to build libc++ against. 274*58b9f456SAndroid Build Coastguard Worker 275*58b9f456SAndroid Build Coastguard Worker.. option:: LIBCXX_CXX_ABI_INCLUDE_PATHS:PATHS 276*58b9f456SAndroid Build Coastguard Worker 277*58b9f456SAndroid Build Coastguard Worker Provide additional search paths for the ABI library headers. 278*58b9f456SAndroid Build Coastguard Worker 279*58b9f456SAndroid Build Coastguard Worker.. option:: LIBCXX_CXX_ABI_LIBRARY_PATH:PATH 280*58b9f456SAndroid Build Coastguard Worker 281*58b9f456SAndroid Build Coastguard Worker Provide the path to the ABI library that libc++ should link against. 282*58b9f456SAndroid Build Coastguard Worker 283*58b9f456SAndroid Build Coastguard Worker.. option:: LIBCXX_ENABLE_STATIC_ABI_LIBRARY:BOOL 284*58b9f456SAndroid Build Coastguard Worker 285*58b9f456SAndroid Build Coastguard Worker **Default**: ``OFF`` 286*58b9f456SAndroid Build Coastguard Worker 287*58b9f456SAndroid Build Coastguard Worker If this option is enabled, libc++ will try and link the selected ABI library 288*58b9f456SAndroid Build Coastguard Worker statically. 289*58b9f456SAndroid Build Coastguard Worker 290*58b9f456SAndroid Build Coastguard Worker.. option:: LIBCXX_ENABLE_ABI_LINKER_SCRIPT:BOOL 291*58b9f456SAndroid Build Coastguard Worker 292*58b9f456SAndroid Build Coastguard Worker **Default**: ``ON`` by default on UNIX platforms other than Apple unless 293*58b9f456SAndroid Build Coastguard Worker 'LIBCXX_ENABLE_STATIC_ABI_LIBRARY' is ON. Otherwise the default value is ``OFF``. 294*58b9f456SAndroid Build Coastguard Worker 295*58b9f456SAndroid Build Coastguard Worker This option generate and installs a linker script as ``libc++.so`` which 296*58b9f456SAndroid Build Coastguard Worker links the correct ABI library. 297*58b9f456SAndroid Build Coastguard Worker 298*58b9f456SAndroid Build Coastguard Worker.. option:: LIBCXXABI_USE_LLVM_UNWINDER:BOOL 299*58b9f456SAndroid Build Coastguard Worker 300*58b9f456SAndroid Build Coastguard Worker **Default**: ``OFF`` 301*58b9f456SAndroid Build Coastguard Worker 302*58b9f456SAndroid Build Coastguard Worker Build and use the LLVM unwinder. Note: This option can only be used when 303*58b9f456SAndroid Build Coastguard Worker libc++abi is the C++ ABI library used. 304*58b9f456SAndroid Build Coastguard Worker 305*58b9f456SAndroid Build Coastguard Worker 306*58b9f456SAndroid Build Coastguard Workerlibc++ Feature Options 307*58b9f456SAndroid Build Coastguard Worker---------------------- 308*58b9f456SAndroid Build Coastguard Worker 309*58b9f456SAndroid Build Coastguard Worker.. option:: LIBCXX_ENABLE_EXCEPTIONS:BOOL 310*58b9f456SAndroid Build Coastguard Worker 311*58b9f456SAndroid Build Coastguard Worker **Default**: ``ON`` 312*58b9f456SAndroid Build Coastguard Worker 313*58b9f456SAndroid Build Coastguard Worker Build libc++ with exception support. 314*58b9f456SAndroid Build Coastguard Worker 315*58b9f456SAndroid Build Coastguard Worker.. option:: LIBCXX_ENABLE_RTTI:BOOL 316*58b9f456SAndroid Build Coastguard Worker 317*58b9f456SAndroid Build Coastguard Worker **Default**: ``ON`` 318*58b9f456SAndroid Build Coastguard Worker 319*58b9f456SAndroid Build Coastguard Worker Build libc++ with run time type information. 320*58b9f456SAndroid Build Coastguard Worker 321*58b9f456SAndroid Build Coastguard Worker.. option:: LIBCXX_INCLUDE_BENCHMARKS:BOOL 322*58b9f456SAndroid Build Coastguard Worker 323*58b9f456SAndroid Build Coastguard Worker **Default**: ``ON`` 324*58b9f456SAndroid Build Coastguard Worker 325*58b9f456SAndroid Build Coastguard Worker Build the libc++ benchmark tests and the Google Benchmark library needed 326*58b9f456SAndroid Build Coastguard Worker to support them. 327*58b9f456SAndroid Build Coastguard Worker 328*58b9f456SAndroid Build Coastguard Worker.. option:: LIBCXX_BENCHMARK_TEST_ARGS:STRING 329*58b9f456SAndroid Build Coastguard Worker 330*58b9f456SAndroid Build Coastguard Worker **Default**: ``--benchmark_min_time=0.01`` 331*58b9f456SAndroid Build Coastguard Worker 332*58b9f456SAndroid Build Coastguard Worker A semicolon list of arguments to pass when running the libc++ benchmarks using the 333*58b9f456SAndroid Build Coastguard Worker ``check-cxx-benchmarks`` rule. By default we run the benchmarks for a very short amount of time, 334*58b9f456SAndroid Build Coastguard Worker since the primary use of ``check-cxx-benchmarks`` is to get test and sanitizer coverage, not to 335*58b9f456SAndroid Build Coastguard Worker get accurate measurements. 336*58b9f456SAndroid Build Coastguard Worker 337*58b9f456SAndroid Build Coastguard Worker.. option:: LIBCXX_BENCHMARK_NATIVE_STDLIB:STRING 338*58b9f456SAndroid Build Coastguard Worker 339*58b9f456SAndroid Build Coastguard Worker **Default**:: ``""`` 340*58b9f456SAndroid Build Coastguard Worker 341*58b9f456SAndroid Build Coastguard Worker **Values**:: ``libc++``, ``libstdc++`` 342*58b9f456SAndroid Build Coastguard Worker 343*58b9f456SAndroid Build Coastguard Worker Build the libc++ benchmark tests and Google Benchmark library against the 344*58b9f456SAndroid Build Coastguard Worker specified standard library on the platform. On linux this can be used to 345*58b9f456SAndroid Build Coastguard Worker compare libc++ to libstdc++ by building the benchmark tests against both 346*58b9f456SAndroid Build Coastguard Worker standard libraries. 347*58b9f456SAndroid Build Coastguard Worker 348*58b9f456SAndroid Build Coastguard Worker.. option:: LIBCXX_BENCHMARK_NATIVE_GCC_TOOLCHAIN:STRING 349*58b9f456SAndroid Build Coastguard Worker 350*58b9f456SAndroid Build Coastguard Worker Use the specified GCC toolchain and standard library when building the native 351*58b9f456SAndroid Build Coastguard Worker stdlib benchmark tests. 352*58b9f456SAndroid Build Coastguard Worker 353*58b9f456SAndroid Build Coastguard Worker.. option:: LIBCXX_HIDE_FROM_ABI_PER_TU_BY_DEFAULT:BOOL 354*58b9f456SAndroid Build Coastguard Worker 355*58b9f456SAndroid Build Coastguard Worker **Default**: ``OFF`` 356*58b9f456SAndroid Build Coastguard Worker 357*58b9f456SAndroid Build Coastguard Worker Pick the default for whether to constrain ABI-unstable symbols to 358*58b9f456SAndroid Build Coastguard Worker each individual translation unit. This setting controls whether 359*58b9f456SAndroid Build Coastguard Worker `_LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT` is defined by default -- 360*58b9f456SAndroid Build Coastguard Worker see the documentation of that macro for details. 361*58b9f456SAndroid Build Coastguard Worker 362*58b9f456SAndroid Build Coastguard Worker 363*58b9f456SAndroid Build Coastguard Workerlibc++ ABI Feature Options 364*58b9f456SAndroid Build Coastguard Worker-------------------------- 365*58b9f456SAndroid Build Coastguard Worker 366*58b9f456SAndroid Build Coastguard WorkerThe following options allow building libc++ for a different ABI version. 367*58b9f456SAndroid Build Coastguard Worker 368*58b9f456SAndroid Build Coastguard Worker.. option:: LIBCXX_ABI_VERSION:STRING 369*58b9f456SAndroid Build Coastguard Worker 370*58b9f456SAndroid Build Coastguard Worker **Default**: ``1`` 371*58b9f456SAndroid Build Coastguard Worker 372*58b9f456SAndroid Build Coastguard Worker Defines the target ABI version of libc++. 373*58b9f456SAndroid Build Coastguard Worker 374*58b9f456SAndroid Build Coastguard Worker.. option:: LIBCXX_ABI_UNSTABLE:BOOL 375*58b9f456SAndroid Build Coastguard Worker 376*58b9f456SAndroid Build Coastguard Worker **Default**: ``OFF`` 377*58b9f456SAndroid Build Coastguard Worker 378*58b9f456SAndroid Build Coastguard Worker Build the "unstable" ABI version of libc++. Includes all ABI changing features 379*58b9f456SAndroid Build Coastguard Worker on top of the current stable version. 380*58b9f456SAndroid Build Coastguard Worker 381*58b9f456SAndroid Build Coastguard Worker.. option:: LIBCXX_ABI_NAMESPACE:STRING 382*58b9f456SAndroid Build Coastguard Worker 383*58b9f456SAndroid Build Coastguard Worker **Default**: ``__n`` where ``n`` is the current ABI version. 384*58b9f456SAndroid Build Coastguard Worker 385*58b9f456SAndroid Build Coastguard Worker This option defines the name of the inline ABI versioning namespace. It can be used for building 386*58b9f456SAndroid Build Coastguard Worker custom versions of libc++ with unique symbol names in order to prevent conflicts or ODR issues 387*58b9f456SAndroid Build Coastguard Worker with other libc++ versions. 388*58b9f456SAndroid Build Coastguard Worker 389*58b9f456SAndroid Build Coastguard Worker .. warning:: 390*58b9f456SAndroid Build Coastguard Worker When providing a custom namespace, it's the users responsibility to ensure the name won't cause 391*58b9f456SAndroid Build Coastguard Worker conflicts with other names defined by libc++, both now and in the future. In particular, inline 392*58b9f456SAndroid Build Coastguard Worker namespaces of the form ``__[0-9]+`` are strictly reserved by libc++ and may not be used by users. 393*58b9f456SAndroid Build Coastguard Worker Doing otherwise could cause conflicts and hinder libc++ ABI evolution. 394*58b9f456SAndroid Build Coastguard Worker 395*58b9f456SAndroid Build Coastguard Worker.. option:: LIBCXX_ABI_DEFINES:STRING 396*58b9f456SAndroid Build Coastguard Worker 397*58b9f456SAndroid Build Coastguard Worker **Default**: ``""`` 398*58b9f456SAndroid Build Coastguard Worker 399*58b9f456SAndroid Build Coastguard Worker A semicolon-separated list of ABI macros to persist in the site config header. 400*58b9f456SAndroid Build Coastguard Worker See ``include/__config`` for the list of ABI macros. 401*58b9f456SAndroid Build Coastguard Worker 402*58b9f456SAndroid Build Coastguard Worker.. _LLVM-specific variables: 403*58b9f456SAndroid Build Coastguard Worker 404*58b9f456SAndroid Build Coastguard WorkerLLVM-specific options 405*58b9f456SAndroid Build Coastguard Worker--------------------- 406*58b9f456SAndroid Build Coastguard Worker 407*58b9f456SAndroid Build Coastguard Worker.. option:: LLVM_LIBDIR_SUFFIX:STRING 408*58b9f456SAndroid Build Coastguard Worker 409*58b9f456SAndroid Build Coastguard Worker Extra suffix to append to the directory where libraries are to be 410*58b9f456SAndroid Build Coastguard Worker installed. On a 64-bit architecture, one could use ``-DLLVM_LIBDIR_SUFFIX=64`` 411*58b9f456SAndroid Build Coastguard Worker to install libraries to ``/usr/lib64``. 412*58b9f456SAndroid Build Coastguard Worker 413*58b9f456SAndroid Build Coastguard Worker.. option:: LLVM_BUILD_32_BITS:BOOL 414*58b9f456SAndroid Build Coastguard Worker 415*58b9f456SAndroid Build Coastguard Worker Build 32-bits executables and libraries on 64-bits systems. This option is 416*58b9f456SAndroid Build Coastguard Worker available only on some 64-bits unix systems. Defaults to OFF. 417*58b9f456SAndroid Build Coastguard Worker 418*58b9f456SAndroid Build Coastguard Worker.. option:: LLVM_LIT_ARGS:STRING 419*58b9f456SAndroid Build Coastguard Worker 420*58b9f456SAndroid Build Coastguard Worker Arguments given to lit. ``make check`` and ``make clang-test`` are affected. 421*58b9f456SAndroid Build Coastguard Worker By default, ``'-sv --no-progress-bar'`` on Visual C++ and Xcode, ``'-sv'`` on 422*58b9f456SAndroid Build Coastguard Worker others. 423*58b9f456SAndroid Build Coastguard Worker 424*58b9f456SAndroid Build Coastguard Worker 425*58b9f456SAndroid Build Coastguard WorkerUsing Alternate ABI libraries 426*58b9f456SAndroid Build Coastguard Worker============================= 427*58b9f456SAndroid Build Coastguard Worker 428*58b9f456SAndroid Build Coastguard Worker 429*58b9f456SAndroid Build Coastguard Worker.. _libsupcxx: 430*58b9f456SAndroid Build Coastguard Worker 431*58b9f456SAndroid Build Coastguard WorkerUsing libsupc++ on Linux 432*58b9f456SAndroid Build Coastguard Worker------------------------ 433*58b9f456SAndroid Build Coastguard Worker 434*58b9f456SAndroid Build Coastguard WorkerYou will need libstdc++ in order to provide libsupc++. 435*58b9f456SAndroid Build Coastguard Worker 436*58b9f456SAndroid Build Coastguard WorkerFigure out where the libsupc++ headers are on your system. On Ubuntu this 437*58b9f456SAndroid Build Coastguard Workeris ``/usr/include/c++/<version>`` and ``/usr/include/c++/<version>/<target-triple>`` 438*58b9f456SAndroid Build Coastguard Worker 439*58b9f456SAndroid Build Coastguard WorkerYou can also figure this out by running 440*58b9f456SAndroid Build Coastguard Worker 441*58b9f456SAndroid Build Coastguard Worker.. code-block:: bash 442*58b9f456SAndroid Build Coastguard Worker 443*58b9f456SAndroid Build Coastguard Worker $ echo | g++ -Wp,-v -x c++ - -fsyntax-only 444*58b9f456SAndroid Build Coastguard Worker ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu" 445*58b9f456SAndroid Build Coastguard Worker ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../x86_64-linux-gnu/include" 446*58b9f456SAndroid Build Coastguard Worker #include "..." search starts here: 447*58b9f456SAndroid Build Coastguard Worker #include <...> search starts here: 448*58b9f456SAndroid Build Coastguard Worker /usr/include/c++/4.7 449*58b9f456SAndroid Build Coastguard Worker /usr/include/c++/4.7/x86_64-linux-gnu 450*58b9f456SAndroid Build Coastguard Worker /usr/include/c++/4.7/backward 451*58b9f456SAndroid Build Coastguard Worker /usr/lib/gcc/x86_64-linux-gnu/4.7/include 452*58b9f456SAndroid Build Coastguard Worker /usr/local/include 453*58b9f456SAndroid Build Coastguard Worker /usr/lib/gcc/x86_64-linux-gnu/4.7/include-fixed 454*58b9f456SAndroid Build Coastguard Worker /usr/include/x86_64-linux-gnu 455*58b9f456SAndroid Build Coastguard Worker /usr/include 456*58b9f456SAndroid Build Coastguard Worker End of search list. 457*58b9f456SAndroid Build Coastguard Worker 458*58b9f456SAndroid Build Coastguard WorkerNote that the first two entries happen to be what we are looking for. This 459*58b9f456SAndroid Build Coastguard Workermay not be correct on other platforms. 460*58b9f456SAndroid Build Coastguard Worker 461*58b9f456SAndroid Build Coastguard WorkerWe can now run CMake: 462*58b9f456SAndroid Build Coastguard Worker 463*58b9f456SAndroid Build Coastguard Worker.. code-block:: bash 464*58b9f456SAndroid Build Coastguard Worker 465*58b9f456SAndroid Build Coastguard Worker $ CC=clang CXX=clang++ cmake -G "Unix Makefiles" \ 466*58b9f456SAndroid Build Coastguard Worker -DLIBCXX_CXX_ABI=libstdc++ \ 467*58b9f456SAndroid Build Coastguard Worker -DLIBCXX_CXX_ABI_INCLUDE_PATHS="/usr/include/c++/4.7/;/usr/include/c++/4.7/x86_64-linux-gnu/" \ 468*58b9f456SAndroid Build Coastguard Worker -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr \ 469*58b9f456SAndroid Build Coastguard Worker <libc++-source-dir> 470*58b9f456SAndroid Build Coastguard Worker 471*58b9f456SAndroid Build Coastguard Worker 472*58b9f456SAndroid Build Coastguard WorkerYou can also substitute ``-DLIBCXX_CXX_ABI=libsupc++`` 473*58b9f456SAndroid Build Coastguard Workerabove, which will cause the library to be linked to libsupc++ instead 474*58b9f456SAndroid Build Coastguard Workerof libstdc++, but this is only recommended if you know that you will 475*58b9f456SAndroid Build Coastguard Workernever need to link against libstdc++ in the same executable as libc++. 476*58b9f456SAndroid Build Coastguard WorkerGCC ships libsupc++ separately but only as a static library. If a 477*58b9f456SAndroid Build Coastguard Workerprogram also needs to link against libstdc++, it will provide its 478*58b9f456SAndroid Build Coastguard Workerown copy of libsupc++ and this can lead to subtle problems. 479*58b9f456SAndroid Build Coastguard Worker 480*58b9f456SAndroid Build Coastguard Worker.. code-block:: bash 481*58b9f456SAndroid Build Coastguard Worker 482*58b9f456SAndroid Build Coastguard Worker $ make cxx 483*58b9f456SAndroid Build Coastguard Worker $ make install 484*58b9f456SAndroid Build Coastguard Worker 485*58b9f456SAndroid Build Coastguard WorkerYou can now run clang with -stdlib=libc++. 486*58b9f456SAndroid Build Coastguard Worker 487*58b9f456SAndroid Build Coastguard Worker 488*58b9f456SAndroid Build Coastguard Worker.. _libcxxrt_ref: 489*58b9f456SAndroid Build Coastguard Worker 490*58b9f456SAndroid Build Coastguard WorkerUsing libcxxrt on Linux 491*58b9f456SAndroid Build Coastguard Worker------------------------ 492*58b9f456SAndroid Build Coastguard Worker 493*58b9f456SAndroid Build Coastguard WorkerYou will need to keep the source tree of `libcxxrt`_ available 494*58b9f456SAndroid Build Coastguard Workeron your build machine and your copy of the libcxxrt shared library must 495*58b9f456SAndroid Build Coastguard Workerbe placed where your linker will find it. 496*58b9f456SAndroid Build Coastguard Worker 497*58b9f456SAndroid Build Coastguard WorkerWe can now run CMake like: 498*58b9f456SAndroid Build Coastguard Worker 499*58b9f456SAndroid Build Coastguard Worker.. code-block:: bash 500*58b9f456SAndroid Build Coastguard Worker 501*58b9f456SAndroid Build Coastguard Worker $ CC=clang CXX=clang++ cmake -G "Unix Makefiles" \ 502*58b9f456SAndroid Build Coastguard Worker -DLIBCXX_CXX_ABI=libcxxrt \ 503*58b9f456SAndroid Build Coastguard Worker -DLIBCXX_CXX_ABI_INCLUDE_PATHS=path/to/libcxxrt-sources/src \ 504*58b9f456SAndroid Build Coastguard Worker -DCMAKE_BUILD_TYPE=Release \ 505*58b9f456SAndroid Build Coastguard Worker -DCMAKE_INSTALL_PREFIX=/usr \ 506*58b9f456SAndroid Build Coastguard Worker <libc++-source-directory> 507*58b9f456SAndroid Build Coastguard Worker $ make cxx 508*58b9f456SAndroid Build Coastguard Worker $ make install 509*58b9f456SAndroid Build Coastguard Worker 510*58b9f456SAndroid Build Coastguard WorkerUnfortunately you can't simply run clang with "-stdlib=libc++" at this point, as 511*58b9f456SAndroid Build Coastguard Workerclang is set up to link for libc++ linked to libsupc++. To get around this 512*58b9f456SAndroid Build Coastguard Workeryou'll have to set up your linker yourself (or patch clang). For example, 513*58b9f456SAndroid Build Coastguard Worker 514*58b9f456SAndroid Build Coastguard Worker.. code-block:: bash 515*58b9f456SAndroid Build Coastguard Worker 516*58b9f456SAndroid Build Coastguard Worker $ clang++ -stdlib=libc++ helloworld.cpp \ 517*58b9f456SAndroid Build Coastguard Worker -nodefaultlibs -lc++ -lcxxrt -lm -lc -lgcc_s -lgcc 518*58b9f456SAndroid Build Coastguard Worker 519*58b9f456SAndroid Build Coastguard WorkerAlternately, you could just add libcxxrt to your libraries list, which in most 520*58b9f456SAndroid Build Coastguard Workersituations will give the same result: 521*58b9f456SAndroid Build Coastguard Worker 522*58b9f456SAndroid Build Coastguard Worker.. code-block:: bash 523*58b9f456SAndroid Build Coastguard Worker 524*58b9f456SAndroid Build Coastguard Worker $ clang++ -stdlib=libc++ helloworld.cpp -lcxxrt 525*58b9f456SAndroid Build Coastguard Worker 526*58b9f456SAndroid Build Coastguard Worker.. _`libcxxrt`: https://github.com/pathscale/libcxxrt/ 527*58b9f456SAndroid Build Coastguard Worker 528*58b9f456SAndroid Build Coastguard Worker 529*58b9f456SAndroid Build Coastguard WorkerUsing a local ABI library installation 530*58b9f456SAndroid Build Coastguard Worker--------------------------------------- 531*58b9f456SAndroid Build Coastguard Worker 532*58b9f456SAndroid Build Coastguard Worker.. warning:: 533*58b9f456SAndroid Build Coastguard Worker This is not recommended in almost all cases. 534*58b9f456SAndroid Build Coastguard Worker 535*58b9f456SAndroid Build Coastguard WorkerThese instructions should only be used when you can't install your ABI library. 536*58b9f456SAndroid Build Coastguard Worker 537*58b9f456SAndroid Build Coastguard WorkerNormally you must link libc++ against a ABI shared library that the 538*58b9f456SAndroid Build Coastguard Workerlinker can find. If you want to build and test libc++ against an ABI 539*58b9f456SAndroid Build Coastguard Workerlibrary not in the linker's path you needq to set 540*58b9f456SAndroid Build Coastguard Worker``-DLIBCXX_CXX_ABI_LIBRARY_PATH=/path/to/abi/lib`` when configuring CMake. 541*58b9f456SAndroid Build Coastguard Worker 542*58b9f456SAndroid Build Coastguard WorkerAn example build using libc++abi would look like: 543*58b9f456SAndroid Build Coastguard Worker 544*58b9f456SAndroid Build Coastguard Worker.. code-block:: bash 545*58b9f456SAndroid Build Coastguard Worker 546*58b9f456SAndroid Build Coastguard Worker $ CC=clang CXX=clang++ cmake \ 547*58b9f456SAndroid Build Coastguard Worker -DLIBCXX_CXX_ABI=libc++abi \ 548*58b9f456SAndroid Build Coastguard Worker -DLIBCXX_CXX_ABI_INCLUDE_PATHS="/path/to/libcxxabi/include" \ 549*58b9f456SAndroid Build Coastguard Worker -DLIBCXX_CXX_ABI_LIBRARY_PATH="/path/to/libcxxabi-build/lib" \ 550*58b9f456SAndroid Build Coastguard Worker path/to/libcxx 551*58b9f456SAndroid Build Coastguard Worker $ make 552*58b9f456SAndroid Build Coastguard Worker 553*58b9f456SAndroid Build Coastguard WorkerWhen testing libc++ LIT will automatically link against the proper ABI 554*58b9f456SAndroid Build Coastguard Workerlibrary. 555