I used clang-3.5 to happily create musl libc bit code versions and use the result to create great standalone executables.
Recent attempts with clang-3.8 not been so happy. The clang-3.8 bitcode seems to generate the functions defined in
compiler-rt/lib/builtins
Typical examples of functions that I consider polluting the bit code are mulxc3 , mulsc3 and muldc3 . I can solve this by contacting libgcc or even the llvm alternative if I had a clear idea of ββwhat it was. Although I would prefer to prevent the occurrence of the problem in the first place.
I saw mention of flags like rtlib=compiler-rt , etc., but found very little documentation on this.
So here are some simple questions.
Is it possible to prevent the use of clang compiler-rt/lib/builtins in the emitted bit code? Or if not
Does llvm create a version of libgcc that I could use. In fact, I would probably build its version with bit code, but this does not apply to this topic.
Love to hear some recommendations about this.
Added on 12/8/2016:. Therefore, I will illustrate my problems with a specific workflow that people can reproduce if they wish, or, more likely, just indicate where I am stupid.
So, start by checking:
musllv
and follow the instructions in README.to to compile (here I use clang-3.8 on ubuntu 14.04)
WLLVM_CONFIGURE_ONLY=1 CC=wllvm ./configure --target=LLVM --build=LLVM make cd lib extract-bc -b libc.a
You will also need the bit code of a simple executable. I will use nweb.c here.
wllvm nweb.c -o nweb extract-bc nweb
Now we can do things like:
clang -static -nostdlib nweb.bc libc.a.bc crt1.o libc.a -o nweb
This workflow runs smoothly for clang-3.5, but for clang-3.8 we get:
clang -static -nostdlib nweb.bc libc.a.bc crt1.o libc.a -o nweb /tmp/libc-f734a3.o: In function `cpowl': libc.a.bc:(.text+0xbb9a): undefined reference to `__mulxc3' /tmp/libc-f734a3.o: In function `cpowf': libc.a.bc:(.text+0x38f7d): undefined reference to `__mulsc3' /tmp/libc-f734a3.o: In function `csqrt': libc.a.bc:(.text+0x78fc3): undefined reference to `__muldc3' /tmp/libc-f734a3.o: In function `cpow': libc.a.bc:(.text+0xafafc): undefined reference to `__muldc3' clang-3.8: error: linker command failed with exit code 1 (use -v to seeinvocation)
Since @ paul-brannan indicates that we could try
clang -static -nostdlib
But here is where I am probably stupid, because I get:
clang-3.8: warning: argument unused during compilation: '--rtlib=compiler-rt'
regardless of whether I use it as a binding or compilation flag.