[SERVER-55737] Evaluate feasibility and impact of removing -rdynamic when using libunwind Created: 02/Apr/21  Updated: 27/Oct/23  Resolved: 27/Oct/23

Status: Closed
Project: Core Server
Component/s: Build
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Andrew Morrow (Inactive) Assignee: [DO NOT ASSIGN] Backlog - Server Development Platform Team (SDP) (Inactive)
Resolution: Won't Do Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Assigned Teams:
Server Development Platform
Backwards Compatibility: Fully Compatible
Participants:

 Description   

We have for a long time linked all our binaries with the -rdynamic flag. This flag is unnecessary but harmless for shared library builds, and work to apply it only for program builds will be put in place under SERVER-49322.

However, the original intention of adding the -rdynamic flag was to ensure that all symbols were included in the dynamic symbol table so that backtrace_symbols would work. When using libunwind we are no longer required to do so in order to get correct backtraces.

The only remaining cases for which we would still need symbols to be exported from the program are those where we intend to look up the symbol via the dl APIs like dlsym or dladdr. This does in fact happen in our codebase, in two places:

  • In the machinery to handle fallback when libunwind fails to symbolize. We have a unit test for this situation and it does fail when built without -rdynamic.
  • The wiredtiger subsystem allows function names to be provided in its configuration which it then searches for with dlsym. If we were to build without -rdynamic, we would need to find a way to continue to ensure that those symbols were dynamic.

We can investigate what it would take to allow explicit export of those few specific functions that must be present in the dynamic symbol table. Both ld.gold and ld.lld offer an --export-dynamic-symbol flag which can be used to export symbols on a per-instance basis.



 Comments   
Comment by Githook User [ 09/Apr/21 ]

Author:

{'name': 'Andrew Morrow', 'email': 'acm@mongodb.com', 'username': 'acmorrow'}

Message: SERVER-55737 Add an experiment for not requiring -rdynamic
Branch: master
https://github.com/mongodb/mongo/commit/b40f9038d2527cecbc07a4abdf792231b82db244

Comment by Githook User [ 09/Apr/21 ]

Author:

{'name': 'Andrew Morrow', 'email': 'acm@mongodb.com', 'username': 'acmorrow'}

Message: SERVER-55737 Ensure WT entry points are exported
Branch: master
https://github.com/10gen/mongo-enterprise-modules/commit/1b80476ffdc7354c309bb8ae86fb9538c14049e1

Generated at Thu Feb 08 05:37:19 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.