[llvm-dev] libunwind is not configured with -funwind-tables when building it for ARM Linux?

Sergej Jaskiewicz via llvm-dev llvm-dev at lists.llvm.org
Mon Nov 18 04:32:24 PST 2019

There’s this bug: https://bugs.llvm.org/show_bug.cgi?id=38468.

I’ve managed to track it down to a configuration issue. The thing is that in order for libunwind to be usable on ARM Linux, it should be built with the -funwind-tables flag. This flag is conditionally set here: https://github.com/llvm/llvm-project/blob/master/libunwind/CMakeLists.txt#L294, if the compiler “supports” it.

However, the CMake check fails with the following error:

ld.lld: error: undefined symbol: __aeabi_unwind_cpp_pr0

>>> referenced by src.cxx

>>>               CMakeFiles/cmTC_e9739.dir/src.cxx.o:(.ARM.exidx.text.main+0x0)

clang++: error: linker command failed with exit code 1 (use -v to see invocation)

ninja: build stopped: subcommand failed.

Source file was:
int main() { return 0; }

No wonder! __aeabi_unwind_cpp_pr0 is defined in libunwind itself, which we haven’t built yet.

If I instead set the -funwind-tables flag unconditionally using `add_compile_flags(-funwind-tables)` instead of `add_cxx_compile_flags_if_supported(-funwind-tables)`, everything is fine and the aforementioned bug is gone.

I’ve found a PR which seemed to address this: https://reviews.llvm.org/D31858 (cc’ing @phosek, @compnerd and @beanz as participants of this PR). It mentions that the __aeabi_unwind_cpp_pr0 symbol is provided by the compiler runtime. However, as I’ve already said, it lives in libunwind, so the problem doesn’t seem to be solved.

I’m very tempted to just set the -funwind-tables flag unconditionally, but I’m afraid it’ll break something. What would be the right solution for building libunwind with this flag for ARM Linux?

More information about the llvm-dev mailing list