[libcxx-commits] [PATCH] D62090: [libcxx][libunwind] Support ELF dependent libraries feature on Linux

Petr Hosek via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 22 01:12:53 PDT 2019


phosek added a comment.

In D62090#1510537 <https://reviews.llvm.org/D62090#1510537>, @ldionne wrote:

> I guess I don't have any strong objection, but I think I had a preference for handling it in the build system per https://reviews.llvm.org/D54726. This would conceivably work on other platforms that support linker scripts and it's less intrusive to the source code. But if you feel strongly that this is the right way to go, I'm OK with it.


I have a slight preference for this approach for two reasons: (1) with linker scripts we have to rename the static library which may lead to some confusion, e.g. simply running `readelf -sW libc++.a` will fail because `libc++.a` is now a linker script; (2) it localizes the dependency information to where it's needed, e.g. the `pthread` library dependency is only included if `_LIBCPP_HAS_THREAD_API_PTHREAD` is defined.

In D62090#1510816 <https://reviews.llvm.org/D62090#1510816>, @bd1976llvm wrote:

> Great to see someone wanting to use this. During the RFC we decided not to set SHF_EXCLUDE on the .deplibs ELF section that is used to store the strings from these pragmas. This means that other linkers that don't support dependent libraries will not remove the sections and they will end up in the output. This shouldn't cause any functional issues; however, it might be noticed by developers and commented on. Perhaps we should change this decision?


I think we should consider that.

In D62090#1510816 <https://reviews.llvm.org/D62090#1510816>, @bd1976llvm wrote:

> Also, have you considered the other option of having the build system invoke the clang with the --dependent-library=<specifier> switch. This is an alternative approach where modifying the source code is not appropriate, an example use is: https://reviews.llvm.org/D61742.


That might be an option as well and is something that can be done from CMake invocation via CFLAGS. The downside is AFAICT that the information will no longer be localized to where it's needed and instead applied to all translation units inside the archive e.g. even if you use part of libc++ that doesn't need `pthread`, you'll still get the dependency. An alternative would be to set that flag on a per translation unit basis but I'm not sure whether that's better than having the `pragma` directly in the source.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62090





More information about the libcxx-commits mailing list