ngtc icon indicating copy to clipboard operation
ngtc copied to clipboard

Compiler-rt not properly linking

Open oneechanhax opened this issue 5 years ago • 6 comments

libc++ doesnt properly link with compiler-rt. It leaves missing symbols such as "__divti3", "__muloti4", and "__udivti3" Using alpine-lxc on the latest alpine release 3.10

oneechanhax avatar Jul 12 '19 15:07 oneechanhax

found the solution, you can compile compiler-rt from llvm9 and install it. it gives the crts we need. then install compiler-rt from llvm-8 over it, it doesnt overwrite the crts and gives proper builtins. from there, its just a matter of compiling clang-9 without stack protection(it crashes compiling itself) using gcc(alpines build crashes as above), then bootstrap with itself.

I wont impliment these, sorry. Already did it by hand.

oneechanhax avatar Jul 13 '19 01:07 oneechanhax

I haven't updated NGTC in a while, possibly there are more issues with it. I will take a look soon.

tpimh avatar Jul 13 '19 05:07 tpimh

Just had this error with libc++.so not linking properly (undefined reference to __udivti3). I tried adding -lgcc to the failing command and it worked. Now I'm building using gcc instead of clang, it generates ton of warnings, but links successfully.

tpimh avatar Jul 16 '19 19:07 tpimh

you cant tell it to use compiler rt with gcc though

oneechanhax avatar Jul 16 '19 21:07 oneechanhax

The workaround here is crude, but it works: manually edit build.ninja and add -lgcc to LINK_LIBRARIES of lib/libc++.so.1.0.

tpimh avatar Jul 17 '19 00:07 tpimh

I was finally able to compile working toolchain. Also, updated the latest binary build, it successfully compiled C and C++ test programs.

tpimh avatar Jul 18 '19 14:07 tpimh