bazelbuild / bazelbuild/bazel

Provide other options for LINKABLE_MORE_THAN_ONCE with cc_shared_library

Open
#22,503 4 comments 0 reactions 0 assignees View on GitHub
P3 stale team-Rules-CPP type: feature request
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 18h
Merged PRs (30d)
75

Description

### Description of the feature request:

Currently if you have a large dependency tree that is linked into a cc_shared_library, but then potentially linked into other libraries as well, you have to either export all the transitive symbols, or mark every transitive dep with `tags = ["LINKABLE_MORE_THAN_ONCE"]`. For large dependency trees adding this tag everywhere feels pretty heavy handed, especially when it's likely most of those libraries don't know if they should be linked more than once or not.

In my example in llvm, there is a shared lldb library, which links many of the transitive llvm dependency libraries. This shared library only exports a very specific set of symbols, and everything else is hidden and stripped. In this case if you depend on this shared library, as well as the other llvm libraries, you would have to mark up to 750 cc_library targets with `LINKABLE_MORE_THAN_ONCE`.

I think it would be useful to consider other options for how to limit the duplicate linking here. One option could be a list of libraries on the cc_shared_library itself, so that it is the source of truth for this (ideally using some target pattern instead of individual libraries). Another option could be to have a different type of list for the ones that _aren't_ allowed to be linked more than once instead, since that's the less common case in this example.

Any other ideas?

### Which category does this issue belong to?

C++ Rules

### What underlying problem are you trying to solve with this feature?

_No response_

### Which operating system are you running Bazel on?

Linux

### What is the output of `bazel info release`?

7.1.1

### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.

_No response_

### What's the output of `git remote get-url origin; git rev-parse HEAD` ?

_No response_

### Have you found anything relevant by searching the web?

_No response_

### Any other information, logs, or outputs that you want to share?

_No response_

Contributor guide

Open the contributing guide

Research direction

No source files or tests are named. Start by tracing the cc_shared_library rule and LINKABLE_MORE_THAN_ONCE handling, then determine which alternative linking configuration the project can support and add coverage showing that large transitive dependency trees no longer require tagging every target.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.