Open llvmbot opened 7 years ago
LLVM+clang+compiler-rt combination does not have a default unwinder. At least clang does not add one.
When built with LLVM, HandleLLVMOptions.cmake would add -z,defs
to linker flags for shared lib targets in compiler-rt, which causes the failure. The standalone build of compiler-rt does not add the flag. The same thing goes with libLLVMRuntimeDyld.so (uses __register_frame/__deregister_frame), which in shared lib build have the same failure here.
I think the correct fix to leave the choice of unwinder to the client of the shared library being built.
I created https://reviews.llvm.org/D53553 https://reviews.llvm.org/D53686
Are there some news regarting this bugreport? it still affects some linkage, specially on amd64 targets.
Using 7.0.0 version
I think I am also getting hit with this bug,
64bit Ubuntu 16.04 system, trunk sources,
my errors look like this:
projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_unwind_linux_libcdep.cc.o: In function __sanitizer::Unwind_GetIP(_Unwind_Context*)': /home/mehrlich/Code/llvm/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cc:98: undefined reference to
_Unwind_GetIP'
projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_unwind_linux_libcdep.cc.o: In function Unwind_GetIP': /home/mehrlich/Code/llvm/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cc:98: undefined reference to
_Unwind_GetIP'
projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_unwind_linux_libcdep.cc.o: In function __sanitizer::BufferedStackTrace::SlowUnwindStack(unsigned long, unsigned int)': /home/mehrlich/Code/llvm/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cc:125: undefined reference to
_Unwind_Backtrace'
projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_unwind_linux_libcdep.cc.o: In function SlowUnwindStack': /home/mehrlich/Code/llvm/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cc:125: undefined reference to
_Unwind_Backtrace'
I don't think this is a regression, so while it would be nice to get fixed, it's not blocking 3.9.
Happens to me, too.
Using Arch Linux, compiling with clang with -rtlib=compiler-rt
and asan+ubsan; get the following errors:
clang, compiler-rt, llvm, llvm-libs, libunwind and gcc-libs are installed:
I don't get the errors when remove -rtlib=compiler-rt
, or use no sanitizers.
Btw, adding -lgcc_s
fixes it:
But libgcc_s.so*
files are from gcc-libs
, so it wouldn't be compiler-rt anymore; maybe compiler-rt+libgcc hybrid at best.
Is there other way to fix it?
@petrhosek @DavidSpickett
Extended Description
Currently, compiler-rt isn't exposing some _Unwind symbols exposed by libgcc_s.so, which makes it unsuitable replacement for libgcc_s.so.
While building clang with another clang that uses compiler-rt as its runtime lib, on Linux x86_64, I get the following error:
../../sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_unwind_linux_libcdep.cc.o: In function
__sanitizer::BufferedStackTrace::SlowUnwindStack(unsigned long, unsigned int)': /sources/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cc:125: undefined reference to
_Unwind_Backtrace' ../../sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_unwind_linux_libcdep.cc.o: In functionSlowUnwindStack': /sources/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cc:125: undefined reference to
_Unwind_Backtrace' clang-3.9: error: linker command failed with exit code 1 (use -v to see invocation)Grepping for _Unwind on libgcc_s.so, I get the following:
strings libgcc_s.so.1 | grep Unwind
_Unwind_GetGR _Unwind_GetCFA _Unwind_SetGR _Unwind_GetIP _Unwind_GetIPInfo _Unwind_SetIP _Unwind_GetLanguageSpecificData _Unwind_GetRegionStart _Unwind_FindEnclosingFunction _Unwind_Find_FDE _Unwind_GetDataRelBase _Unwind_GetTextRelBase _Unwind_RaiseException _Unwind_ForcedUnwind _Unwind_Resume _Unwind_Resume_or_Rethrow _Unwind_DeleteException _Unwind_Backtrace
Doing the same for clang runtime:
strings libclang_rt.builtins-x86_64.a | grep Unwind
_Unwind_GetLanguageSpecificData _Unwind_GetIP _Unwind_GetRegionStart _Unwind_SetGR _Unwind_SetIP
The rest of the functions seems to be exposed by llvm's libunwind. The solution is to either link libunwind statically to the runtime or explicitly specify it at linker command line when adding compiler-rt runtime libs (it seemed to work manually).