Building LLVM so it does not need gcc libraries anymore

I am trying to bootstrap LLVM with LLVM so it does not depend on gcc libraries anymore, but I had little success. Is it possible to do it? If yes, what am I doing wrong?

I download the llvm-8.0.1 tar.gz and build these llvm projects: llmv;libcxx;libcxxabi;clang;clang-tools-extra;compiler-rt;libunwind

I do two round of building: a bootstrap round, and a final round.

In the bootstrap round, I build llvm with clang-8 (downloaded form llvm apt-repo for ubuntu). I link with lld and I set -I, and -L to /include and /lib paths. I also set the rpath.

In the final round, I copy the llvm binaries from the last round to a new and pristine system with nothing but the llvm source code on it (to make sure I do not depend on gcc libraries). Here I try to build the source code, one more time, with the binaries form the bootstrap round. But my bootstrap compiler, among other things, depends on -lgcc, and -lgcc_s. I am wondering if it is possible to build llvm/clang so it does not depend on them. I fiddled with multiple flags and options, including -nostdinc, -nostdinc++, -stdlib=libc++, etc, but with no success.



libgcc is the compiler runtime builtins. This defaults to gnu/gcc on linux. You need to build compiler-rt builtins and crt in your first pass and then pass --rtlib=compiler-rt in your flags (or maybe there is a LLVM_USE_COMPILER_RT cmake variable but I can’t check currently).

Hopefully this points you in the right direction.

– Tobias