What I'm trying to achieve is to compile an GNU independent and isolated LLVM toolchain using musl as clib
.
Recently LLVM 4.0 has been released with lot's of new cool features, including production ready LLD, so also the linking step could be handled by LLVM.
More or less the stack is:
Following this, it is actually possible to do so without much patching or such (apart from compiling musl
), but sadly, there is no good documentation about that.
Any suggestions?
What I'm trying to achieve is to compile an GNU independent and isolated LLVM toolchain using musl as clib. Recently LLVM 4.0 has been released with lot's of new cool features, including production ready LLD, so also the linking step could be handled by LLVM.
LLVM’s compiler runtime library provides a complete set of runtime library functions containing all functions that Clang will implicitly call, in libclang_rt.builtins.<arch>.a. You can instruct Clang to use compiler-rt with the --rtlib=compiler-rt flag.
Recently LLVM 4.0 has been released with lot's of new cool features, including production ready LLD, so also the linking step could be handled by LLVM. Following this, it is actually possible to do so without much patching or such (apart from compiling musl ), but sadly, there is no good documentation about that. Any suggestions?
In order to assemble a complete toolchain, additional tools and runtime libraries are required. Clang is designed to interoperate with existing tools and libraries for its target platforms, and the LLVM project provides alternatives for a number of these components.
I was solving the same problem with my NGTC (Non-GNU toolchain) project. Please take a look at my build scripts and patches.
I used this toolchain to build a small Linux distro without any code from GNU project: nenuzhnix.
There is an example of using Clang + Musl together to compile "Hello World" in C here: https://github.com/njlr/portable-cxx
It only requires wget
, tar
and make
to be installed. Clang and Musl are downloaded as part of the build process.
The key is to disable the usual include paths using -nostdinc
and then add the Musl ones using -isystem
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With