[SERVER-84746] Create option for building shared libraries that don't propagate link opts transitively Created: 10/Jan/24  Updated: 29/Jan/24  Resolved: 29/Jan/24

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.3.0-rc2

Type: Improvement Priority: Major - P3
Reporter: Zack Winter Assignee: Zack Winter
Resolution: Fixed Votes: 0
Labels: req-bazel-all-variant-launch, req-bazel-ubuntu22-launch
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Build
Backwards Compatibility: Fully Compatible
Sprint: Build and Correctness OnDeck
Participants:

 Description   

Problem statement doc: https://docs.google.com/document/d/1xpvQF_h65kJ0O0QUULwyAD5poWK4oKkX2ljM_9PowvM/edit

We need to solve three problems:
1. Create a flag that can be used in select statements to determine wether or not the build is linked dynamically. Currently we're using --dynamic_mode which cannot be queried from in bzl files.
2. cc_library propogates linked opts transitively. For example, if lib_a sets linkopt_123 and lib_b has a dynamic dependency on lib_a, lib_b will inherit linkopt123. This is not desired for dynamic linking and breaks current requirements that the codebase has.
3. Only build in a single mode. We don't want to compile any objects statically when the final result is dynamic, and we don't want to compile any objects dynamically when the final result is static.

This can be accomplished with cc_shared_library without replacing cc_library with a custom rule.



 Comments   
Comment by Githook User [ 27/Jan/24 ]

Author:

{'name': 'Zack Winter', 'email': '3457246+zackwintermdb@users.noreply.github.com', 'username': 'zackwintermdb'}

Message: SERVER-84746 use cc_shared_library to avoid propagating link opts (#18014)

GitOrigin-RevId: bf7af24957728020c0c13eab0cf73afbae9c8b39
Branch: master
https://github.com/mongodb/mongo/commit/05b0c644141412dac53a607dfee713000e628278

Comment by Githook User [ 11/Jan/24 ]

Author:

{'name': 'Zack Winter', 'email': '3457246+zackwintermdb@users.noreply.github.com', 'username': 'zackwintermdb'}

Message: SERVER-84746 Add //bazel/config:linkstatic flag (#17984)

GitOrigin-RevId: afc58e6269570af56a7339a11fe17bc2801753ca
Branch: master
https://github.com/mongodb/mongo/commit/4da44f7db57f4cd58e212c0f7f23de8553189e99

Generated at Thu Feb 08 06:55:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.