Search code examples
c++cmakeandroid-ndkclang++compiler-flags

-fno-unwind-tables and -fno-asynchronous-unwind-tables does not work NDK clang++


I'm compiling my C++ code using clang++ that comes with ndk21. I've set both compiler flags -fno-unwind-tables and -fno-asynchronous-unwind-tables but the number of entries in the unwind table do not reduce. I also checked by setting the opposite -funwind-tables and -fasynchronous-unwind-tables but it doesn't increase either. setting -fno-exceptions does reduce the number of entries slightly which makes me think I'm passing the flags correctly. Does anyone have any idea why this could be the case?

My test program is very simple just 5 functions, all appending strings to strings. Is it that the minimum number of entries in the unwind table? I'm trying to reduce the binary size.


Solution

  • Typically the reason is that you're depending on some other libraries that do have unwind tables. The C++ stdlib is definitely built with them, so if you're using libc++_static.a they'll be added to your library. Since that code is already compiled, your compiler flags won't have any effect on it :)

    I should also note that there are other reasons that you might want unwind tables even if you're not using exceptions. Crash handlers that you use might depend on them, for example.