Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include implicit output targets from cc_binary in cc_test #18018

Open
jtilahun opened this issue Apr 8, 2023 · 2 comments
Open

Include implicit output targets from cc_binary in cc_test #18018

jtilahun opened this issue Apr 8, 2023 · 2 comments
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-Rules-CPP Issues for C++ rules type: feature request

Comments

@jtilahun
Copy link
Contributor

jtilahun commented Apr 8, 2023

Description of the feature request:

The cc_binary rule adds implicit output targets for each explicit output target, as documented here. In particular, for an explicit target name defined using the cc_binary rule, the implicit target name.stripped outputs a stripped version of the binary. However, the cc_test rule does not add any such implicit output targets.

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

In order to run a test on an auxiliary target, there are two steps to perform:

  1. Build the test binary on the host machine using the appropriate toolchain. This can be accomplished by running bazel build on the test target with the appropriate options.
  2. Upload the test binary from the host machine to the target machine and run the test binary on the target machine.

The upload step takes longer the larger the binary is. Unstripped binaries can be significantly larger than stripped binaries. So uploading a stripped binary is one way to make the upload step faster. The cc_binary rule enables this through the implicit name.stripped target. However, the cc_test rule does not.

Which operating system are you running Bazel on?

Linux Ubuntu 20.04

What is the output of bazel info release?

release 4.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 master; 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

@buildbreaker2021 buildbreaker2021 added P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed untriaged labels Apr 25, 2023
copybara-service bot pushed a commit that referenced this issue May 8, 2023
#18018 implies that the implicit output targets added by the `cc_binary` rule (documented [here](https://bazel.build/reference/be/c-cpp#cc_binary_implicit_outputs)) are not mirrored by the `cc_test` rule. However, it appears that Bazel 6.0 does in fact have the implicit output targets of the `cc_binary` rule mirrored by the `cc_test` rule. Given that Bazel 6.0 already seems to have the implicit output targets mirrored by the `cc_test` rule, I figured that no source code changes are required for Bazel 6.0. However, I couldn't find documentation for this feature, and I couldn't find tests either. I did the following:

- I added documentation for the implicit output targets under the `cc_test` rule.
- I added unit tests for the implicit output targets under the `cc_test` rule.
- I added integration tests for the implicit output targets under the `cc_test` rule.

Closes #18275.

PiperOrigin-RevId: 530248329
Change-Id: I46756464d29b6840c92df704a43f63c3030b71dc
fweikert pushed a commit to fweikert/bazel that referenced this issue May 25, 2023
bazelbuild#18018 implies that the implicit output targets added by the `cc_binary` rule (documented [here](https://bazel.build/reference/be/c-cpp#cc_binary_implicit_outputs)) are not mirrored by the `cc_test` rule. However, it appears that Bazel 6.0 does in fact have the implicit output targets of the `cc_binary` rule mirrored by the `cc_test` rule. Given that Bazel 6.0 already seems to have the implicit output targets mirrored by the `cc_test` rule, I figured that no source code changes are required for Bazel 6.0. However, I couldn't find documentation for this feature, and I couldn't find tests either. I did the following:

- I added documentation for the implicit output targets under the `cc_test` rule.
- I added unit tests for the implicit output targets under the `cc_test` rule.
- I added integration tests for the implicit output targets under the `cc_test` rule.

Closes bazelbuild#18275.

PiperOrigin-RevId: 530248329
Change-Id: I46756464d29b6840c92df704a43f63c3030b71dc
@jtilahun
Copy link
Contributor Author

Given that #18275 has been approved and merged, are there other actions left to do here?

There aren't changes in the documentation here. Are there any follow-ups or things that need to be updated or refreshed?

Copy link

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale.

@github-actions github-actions bot added the stale Issues or PRs that are stale (no activity for 30 days) label Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-Rules-CPP Issues for C++ rules type: feature request
Projects
None yet
Development

No branches or pull requests

4 participants
@jtilahun @buildbreaker2021 @ShreeM01 and others