Skip to content

Building libcxx & libcxxabi

Karol Szuster edited this page Jun 12, 2018 · 13 revisions

Overview

Building libcxx & libcxxabi

Only follow these steps if you're willing to compile SPMod on Linux using Clang.

Requirements

  • Git
  • CMake 3.4.3+
  • Ninja
  • Clang 5+
  • LLVM Linker (optional)

Prerequisites

  1. Clone libc++ and libc++abi repositiories
    git clone -b release_60 https://github.com/llvm-mirror/libcxx.git
    git clone -b release_60 https://github.com/llvm-mirror/libcxxabi.git
  2. Create folders outside cloned repositories, f.e. build_libcxx and build_libcxxabi
  3. Change compiler to Clang
    export CC=clang CXX=clang++
    Notice
    Some Linux distributions may have named clang differently by adding version as suffix, f.e.
    For Clang 5.0
    export CC=clang-5.0 CXX=clang++-5.0
    For Clang 6.0
    export CC=clang-6.0 CXX=clang++-6.0
  4. (Optional) Overwrite default linker
    ln -sf /path/to/ld.lld /usr/bin/ld
    Notice
    Some Linux distributions may have named linker differently by adding version as suffix, f.e.
    For Clang 5.0
    ln -sf /path/to/ld.lld-5.0 /usr/bin/ld
    For Clang 6.0
    ln -sf /path/to/ld.lld-6.0 /usr/bin/ld

Building libcxxabi

  1. Enter to build_libcxxabi
    cd /path/to/build_libcxxabi
  2. Generate build files cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=-m32 -DLIBCXXABI_LIBCXX_INCLUDES=../libcxx/include ../libcxxabi/
  3. Build
    ninja

Building libcxx

  1. Enter to build_libcxx
    cd /path/to/build_libcxx
  2. Generate build files
    cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DLIBCXX_CXX_ABI=libcxxabi -DLIBCXX_CXX_ABI_INCLUDE_PATHS=../libcxxabi/include -DLIBCXX_BUILD_32_BITS=ON -DCMAKE_SHARED_LINKER_FLAGS="-L../build_libcxxabi/lib" ../libcxx/
  3. Build
    ninja

Conclusion

If you have successfully completed all the steps above, you can follow here, otherwise please follow those steps more carefully or open an issue if you have any questions.