I'm still working on this, off and on. I want to assemble a C++ toolchain that depends on the Linux kernel but nothing else from the distribution. Otherwise I'd use alpine.

Most of the difficulty has been in working around assumptions made by the cmake scripts in LLVM. They are subtle to configure.

Combining libunwind, libcxxabi and libc++ into a single library makes linking significantly simpler. Also makes setting rpath simpler.

crti,crtn,crtbegin,crtend can be empty files. Don't use crtbegin from bsd. 

Tools like clang, lld have dependencies on other libraries. zlib, curses etc. Disabling these in the cmake files broke apparently unrelated things. My next step is to debug that or start building the supporting libraries.

Musl itself has caused me no problems in any of the above.

Cheers

Jon

On Fri, 31 Aug 2018, 09:29 Luca Barbato, <lu_zero@gentoo.org> wrote:
On 31/08/2018 09:19, Dmitry Golovin wrote:
> There should not be any problems building LLVM and musl on glibc-based distro. The reason why I'm building on Alpine is that I want my llvm and clang to be linked against musl (this is what I need patches for). On a glibc-based distro no patches are needed and you can use musl-clang wrapper to produce binaries linked against musl.

Another way is using this
https://wiki.gentoo.org/wiki/Clang
with
http://distfiles.gentoo.org/experimental/amd64/musl/

It shouldn't have problems but I did not test it lately.

lu