Dmitry Golovin via llvm-dev
2017-Jan-07 12:09 UTC
[llvm-dev] Compiling libraries for musl-based system
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
Carsten Mattner via llvm-dev
2017-Jan-08 10:23 UTC
[llvm-dev] Compiling libraries for musl-based system
On Sat, Jan 7, 2017 at 1:09 PM, Dmitry Golovin via llvm-dev <llvm-dev at lists.llvm.org> wrote:> Resulting libc++ is compiled as shared library with glibc dependency, > so it can't be linked with musl binaries.A two-stage process is needed here, unless your glibc host system has archives to link libc++ statically, but as it presumably depends on libstdc++, this might prove to be hard to work around. Are you doing this for a FreeBSD-like LLVM flavor of Alpine Linux? I would love to use a beast like that as the next logical step for a distro that's based on musl libc.
Jacob Carlborg via llvm-dev
2017-Jan-08 11:56 UTC
[llvm-dev] Compiling libraries for musl-based system
On 2017-01-07 13:09, Dmitry Golovin via llvm-dev wrote:> 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?Perhaps this could be of help [1] [1] https://blogs.gentoo.org/gsoc2016-native-clang/2016/05/05/build-a-freestanding-libcxx/ -- /Jacob Carlborg