This post serves as a tracker of code submitted in the domain of this GSoC project.
This summer, I worked out a bunch of patches that enhance clang/llvm with support for musl-libc, and had those patches contributed upstream. With these patches, clang is now able to correctly link binaries with musl.
llvm musl-libc support:
http://llvm.org/viewvc/llvm-project?view=revision&revision=272660
http://llvm.org/viewvc/llvm-project?view=revision&revision=273726
clang musl-libc support:
http://llvm.org/viewvc/llvm-project?view=revision&revision=272662
http://llvm.org/viewvc/llvm-project?view=revision&revision=272825
http://llvm.org/viewvc/llvm-project?view=revision&revision=273735
http://llvm.org/viewvc/llvm-project?view=revision&revision=277985
There’s still a pending compatibility issue that prevents llvm itself from being built on musl as is. musl and llvm’s developers have different views on this issue [1], and I haven’t yet found a solution that pleases both side. Currently we’re using a downstream patch in Gentoo to make llvm and musl compatible [2].
To have clang not link binaries with libgcc, I contributed another patch to clang that allows compiler-rt to be used as the default runtime library:
http://llvm.org/viewvc/llvm-project?view=revision&revision=276848
With those upstream enhancements, I wrote several ebuilds for Gentoo to construct a GCC-free C++ runtime environment, including:
- create new packages for LLVM’s libunwind and libc++abi
- enhance libc++ to support libc++abi and libunwind
- make llvm compatible with musl-libc
- enhance clang to support libc++ as the default stdlib and compiler-rt as the default rtlib
- create a profile for using clang as the default compiler in Gentoo
Code submitted to Gentoo:
https://github.com/gentoo/gentoo/commits/master?author=zzlei
Code under reviewing for Gentoo:
https://github.com/gentoo/gentoo/pull/2048
https://github.com/gentoo/gentoo/pull/2049
Once the pending pull requests are merged, I’ll deliver a proper Gentoo stage3 with clang as the default compiler and all packages (except for kernel) built with clang.
[1] http://www.openwall.com/lists/musl/2014/04/15/5
[2] https://github.com/gentoo/gentoo/blob/master/sys-devel/llvm/files/llvm-3.8-musl-fixes.patch
Why don’t you try building the kernel with clang? LLVMLinux project (http://llvm.linuxfoundation.org) succeeded and I think it is now possible to build the kernel using clang (at least with defconfig).
Yeah, I’m considering maintaining a new customized kernel, something like sys-kernel/llvm-sources, with patches from LLVMLinux applied. Using that kernel, we should be able to deliver a Gentoo stage3 with no gcc at all.
I just checked their git repo; the last commit is made in Jan. 2015. It seems this project is no longer actively worked on.
Yes, the repo seems abandoned, but most of the patches have already made their way to the upstream. I guess it is now possible to compile upstream kernel with clang.
You may also want to check this out: https://aur.archlinux.org/packages/llvmlinux-git/