This is an archive of the discontinued LLVM Phabricator instance.

[libc++][CMake] Clean up logic for choosing which unwinder lib to link with tests
AbandonedPublic

Authored by ldionne on Apr 15 2019, 9:10 PM.

Details

Reviewers
mstorsjo
phosek
EricWF
tstellar
Group Reviewers
Restricted Project
Summary

The main functional change in this patch is that when
LIBCXXABI_USE_LLVM_UNWINDER and LIBCXX_ENABLE_ABI_LINKER_SCRIPT are both
enabled, -lgcc_s and -lgcc will no longer be added to the linker flags
for the test suite.

In this case, linking against libgcc is unnecessary, because the linker
script adds -lunwind.

Event Timeline

tstellar created this revision.Apr 15 2019, 9:10 PM

I'd love more FIXMEs to be resolved before we move forward.

phosek added inline comments.Apr 16 2019, 12:53 PM
libcxx/utils/libcxx/test/target_info.py
245

It's needed by [LocalAddressSpace::findFunctionName](https://github.com/llvm/llvm-project/blob/master/libunwind/src/AddressSpace.hpp#L594) (and on Darwin also [_dyld_find_unwind_sections](https://github.com/llvm/llvm-project/blob/master/libunwind/src/AddressSpace.hpp#L68)). AFAIK this function is only used by __unw_get_proc_name which is not needed for C++ exception unwinding (it's not part of the _Unwind_* interface), so one possible solution for eliminating that dependency would be to separate the _Unwind_* and unw_* interfaces into two different libraries which is something I proposed in D59921, but that's likely a non-trivial effort. Alternative would be to avoid dladdr and instead read the symbol information directly from the binary file which is what https://www.nongnu.org/libunwind/ does, that's likely more feasible given the current implementation.

246

Note that libunwind also needs -lpthread which is used by https://github.com/llvm/llvm-project/blob/master/libunwind/src/RWMutex.hpp which is used by https://github.com/llvm/llvm-project/blob/master/libunwind/src/UnwindCursor.hpp when DWARF unwinding is being used. It's also used for sjlj unwinding on Darwin in https://github.com/llvm/llvm-project/blob/master/libunwind/src/Unwind-sjlj.c.

250

libgcc contains the GCC unwinder.

251

-lgcc is libgcc.a, -lgcc_s is libgcc_s.so.1, you probably only want one of those?

tstellar marked an inline comment as done.Apr 16 2019, 12:55 PM
tstellar added inline comments.
libcxx/utils/libcxx/test/target_info.py
251

This was my question. I wasn't sure why both were included.

Is this still relevant? You should now be able to specify your own linker flags in the config file by modelling your file on something like libcxx/test/configs/libcxx-trunk-shared.cfg.in.

If not relevant anymore, can this be abandoned to clean up the review queue? If still relevant, let's talk!

Herald added a reviewer: Restricted Project. · View Herald TranscriptSep 14 2020, 1:18 PM
ldionne commandeered this revision.Sep 8 2023, 6:10 AM
ldionne edited reviewers, added: tstellar; removed: ldionne.

[Github PR transition cleanup]

Abandoning since I think this is no longer relevant now that we have easy-to-create .cfg.in files for the test suite.

Herald added a project: Restricted Project. · View Herald TranscriptSep 8 2023, 6:10 AM
ldionne abandoned this revision.Sep 8 2023, 6:10 AM
ldionne marked an inline comment as not done.