[llvm-dev] Compiling libraries for musl-based system

Dmitry Golovin via llvm-dev llvm-dev at lists.llvm.org
Sat Jan 7 04:09:01 PST 2017


I'm trying to compile LLVM-based toolchain with musl. My host is x86_64-linux-gnu and my target is x86_64-linux-musl, so I guess it should be considered cross-compiling.

I'm compiling llvm, clang, lld, compiler-rt, libunwind, lib++abi and libc++ using the following cmake options:

    CLANG_DEFAULT_CXX_STDLIB = libc++
    CLANG_DEFAULT_LINKER = lld
    CLANG_DEFAULT_RTLIB = compiler-rt
    LLVM_DEFAULT_TARGET_TRIPLE = x86_64-pc-linux-musl
    DEFAULT_SYSROOT = /path/to/musl
    GCC_INSTALL_PREFIX = /path/to/gcc-stub
    CMAKE_INSTALL_PREFIX = /path/to/llvm
    CMAKE_BUILD_TYPE = Release
    CMAKE_CROSSCOMPILING = ON
    LLVM_TARGET_ARCH = x86_64
    LLVM_TARGETS_TO_BUILD = X86

The resulting toolchain is able to compile musl and C programs, but I don't know how to compile C++ programs. Resulting libc++ is compiled as shared library with glibc dependency, so it can't be linked with musl binaries. How should I compile libunwind, lib++abi and libc++ for the target system?

Regards,
Dmitry


More information about the llvm-dev mailing list