[PATCH] D96403: [Android] Use -l:libunwind.a with --rtlib=compiler-rt

Ryan Prichard via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 19 18:15:33 PST 2021


rprichard added a comment.

For reference, I know of four ways that LLVM's libunwind is currently linked into programs:

- Fuchsia/Windows (i.e. Clang's default behavior): it's part of libc++, e.g.:
  - Fuchsia:
    - `fuchsia/prebuilt/third_party/clang/linux-x64/lib/x86_64-unknown-fuchsia/c++/libc++.so` is `INPUT(libc++.so.2 -lunwind -lc++abi)`.
    - `fuchsia/prebuilt/third_party/clang/linux-x64/lib/x86_64-unknown-fuchsia/c++/libc++.a` is an archive that contains the libunwind object files.
  - In https://github.com/mstorsjo/llvm-mingw/releases/tag/20201020:
    - `llvm-mingw\x86_64-w64-mingw32\bin\libc++.dll` uses `_Unwind_Resume` from libunwind.dll
    - `llvm-mingw\x86_64-w64-mingw32\lib\libc++.dll.a` also seems to import `_Unwind_Resume` from libunwind.dll
    - `llvm-mingw\x86_64-w64-mingw32\lib\libc++.a` has the libunwind object files in it
- FreeBSD: libclang_rt.builtins and libunwind are repackaged into libraries that look like libgcc, linked implicitly.
- Darwin: it's part of libSystem, linked implicitly.
- crosstool in google3: I think this build system is passing --unwindlib=libunwind to the driver.

The Android team's LLVM build is used to target several OS's: host/glibc Linux, Windows, Darwin, and Android. At some point, we'd also like Android NDK to rely on the unwinder exported from libc.so (when the API level is high enough), which prevents us from using Clang's `CLANG_DEFAULT_UNWINDLIB` config setting.

Even for C programs, the unwinder has at least a couple of uses I know of:

- `_Unwind_Backtrace`
- `__attribute__((cleanup))` with `-fexceptions`

I don't really know how important these use cases are, or whether there are other important use cases I'm not thinking of. I'd prefer to keep linking the unwinder implicitly.

See D57128 <https://reviews.llvm.org/D57128> and D59109 <https://reviews.llvm.org/D59109>.

I think the Android team is happy with this driver change, though, so I expect I'll push it next week.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96403



More information about the cfe-commits mailing list