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

tool(tool="//some:target") doesn't declare a dependency on the target #17401

Open
jmmv opened this issue Feb 2, 2023 · 2 comments
Open

tool(tool="//some:target") doesn't declare a dependency on the target #17401

jmmv opened this issue Feb 2, 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: bug

Comments

@jmmv
Copy link
Contributor

jmmv commented Feb 2, 2023

Description of the bug:

The tool macro provided by cc_toolchain_config_lib.bzl claims the following in its arguments:

        path: Location of the tool; Can be absolute path (in case of non hermetic
            toolchain), or path relative to the cc_toolchain's package. If this
            parameter is set, tool must not be set.
        tool: The built-artifact that should be used as this tool. If this is
            set, path must not be set.

My understanding after reading this is that using tool="//some:target" should cause the given target to be built as a dependency of the tool -- but this does not seem to be the case. Even if the provided target exists and can be built correctly when given explicitly to bazel build, the target won't be picked up as a dependency of the tool.


The reason I'm trying to do this is because I need to write a wrapper script for the linker (because of #17368) and I wanted to use a genrule to auto-generate the script based on certain string replacements. Unfortunately, I've found no way to do this, and I had to end up checking in the "auto-generated" script and using that instead. This is a problem because now I have to remember to maintain this checked-in script, and I had to add logic to our toolchain definitions to attempt to spot stale files.

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

  1. Write a genrule that creates a shell script.
  2. Declare a tool, using the macro from @bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl, that depends on the genrule via the tool attribute.
  3. Try to use the tool and notice how the dependency is never built.

Which operating system are you running Bazel on?

Linux, but this is irrelevant

What is the output of bazel info release?

bazel release 6.0.0

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

@sgowroji
Copy link
Member

sgowroji commented Feb 3, 2023

Hi @jmmv, Could you please provide a sample code to reproduce the above mentioned steps. Thanks!

@buildbreaker2021 buildbreaker2021 added the P3 We're not considering working on this, but happy to review a PR. (No assignee) label Feb 10, 2023
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 May 12, 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: bug
Projects
None yet
Development

No branches or pull requests

3 participants