bazelbuild / bazelbuild/bazel

Possibility to add extra outputs for cc_common.compile and cc_common.link

Open
#12,843 10 comments 6 reactions 0 assignees View on GitHub
not stale P3 team-Rules-CPP type: feature request
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### Description of the feature request:

This is a feature request to add the possibility to gather extra outputs for the compile and linking actions of the cc toolchain via `cc_common.compile` and `cc_common.link`. The interface could be as simple as adding an attribute `extra_outputs` to these 2 functions.

### Feature requests: what underlying problem are you trying to solve with this feature?

This would enable gathering artifacts like map file (-Wl,-Map=...) or stack usage files (-fstack-usage) for example.

As a workaround, one can use `cc_common.create_link_variables` + `cc_common.get_memory_inefficient_command_line` + `ctx.actions.run` but there seem to be a significant amount of code needed to achieve the same result (see [here](https://github.com/Bazel-snippets/custom_cc_rules) for example),

This would solve https://github.com/bazelbuild/bazel/issues/6718

Contributor guide

Open the contributing guide

Research direction

Start with the cc_common.compile and cc_common.link interfaces described in the request, then review the workaround using cc_common.create_link_variables, cc_common.get_memory_inefficient_command_line, and ctx.actions.run. Done means compile and link actions can expose requested artifacts such as map files or stack-usage files without requiring the custom workaround.

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
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.