[PATCH] D142888: [compiler-rt] Fix building GWPASAN on ARM

Leandro Lupori via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 27 13:23:46 PST 2023


luporl added inline comments.


================
Comment at: compiler-rt/lib/scudo/standalone/CMakeLists.txt:48-55
+  # On ARM, we must link against an unwind lib when GWPAsan is used, otherwise
+  # we get undefined references to __aeabi_unwind_cpp_pr* symbols.
+  # This is because object files compiled with -funwind-tables end up referencing
+  # these symbols on ARM, while on other architectures, such as x86_64 and
+  # AArch64, only the .eh_frame section is added, but no references to an unwind
+  # library are made.
+  if(LIBUNWIND_ENABLE_SHARED OR LIBUNWIND_ENABLE_STATIC)
----------------
phosek wrote:
> Could we use libgcc in this case (and report an error if it's unavailable)? We already have a variable to control whether to use LLVM libunwind or libgcc. This block silently picks up libunwind even when `COMPILER_RT_USE_LLVM_UNWINDER` isn't set which is unexpected.
We could, but what if llvm is built with a compiler that is not clang nor gcc, wouldn't it fail in this case?

Also, building with clang on a system where libgcc isn't installed would fail by default on ARM, while it would work on other architectures. In this case, it would be nice to suggest the use of `COMPILER_RT_USE_LLVM_UNWINDER=ON` when reporting the error.

I see the following options here:
1. Link with libgcc if `COMPILER_RT_USE_LLVM_UNWINDER` is OFF, assuming it's ok to possibly break the build with other compilers. We could also try to detect the system unwind library and use it only when it's not libunwind, but this is probably not an easy task.
2. Always use the system unwind library when `COMPILER_RT_USE_LLVM_UNWINDER` is OFF, which may end up using libunwind. We could also try to detect if the system unwind library is libunwind and report an error in this case, to preserve the expected behavior of `COMPILER_RT_USE_LLVM_UNWINDER`.

What do you think?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142888/new/

https://reviews.llvm.org/D142888



More information about the llvm-commits mailing list