bazelbuild / bazelbuild/bazel

Return runfiles from cc_common.link

Open
#26,028 2 comments 2 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:

If you write a custom rule that uses cc_common.link, it's possible that the target depends on shared libraries, which must be available in the runfiles of the target. Whether or not shared libraries are used is based on a few factors in the cc_common.link logic. I think it would be ideal if CcLinkingOutputs provided these runfiles so that the rule doesn't have to attempt to duplicate the logic to collect these.

For example you can do this https://github.com/modular/rules_mojo/blob/7d906beee4f1d01e761925247121ae9f1d138e9e/mojo/private/mojo_binary_test.bzl#L162-L167

to collect the files, but even this is incomplete since im not taking some of the flags to force static or dynamic linking into account

### 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`?

8.2.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` ?

```text

```

### 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

Start by tracing cc_common.link and the CcLinkingOutputs API, then compare the rules_mojo example cited in the issue. Determine how shared-library runfiles are selected, including the static or dynamic linking flags mentioned, and define completion as exposing correct runfiles without requiring custom rules to duplicate that logic.

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
Active
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.