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

Bazel wants full dependency graph for incompatible targets - why aren't they just skipped? #14132

Closed
carlosgalvezp opened this issue Oct 19, 2021 · 3 comments
Labels
team-Configurability platforms, toolchains, cquery, select(), config transitions type: support / not a bug (process) untriaged

Comments

@carlosgalvezp
Copy link

Description of the problem / feature request:

Hi!

I have a target that is only compatible with the aarch64 platform:

cc_binary( 
    name = "foo",
    target_compatible_with = ["@platforms//cpu:aarch64"], 
    deps = [ "//foo:bar", ] 
)

Now, the bar dependency comes in two flavors, so I have an alias:

alias(
      name = "bar",
      actual = select({ 
            # Simplified syntax here 
            "aarch64_linux" : ":bar_linux",
            "aarch64_qnx": ":bar_qnx", 
       }) 
)

Now, my problem is that when I build for x86 using wildcard, Bazel complains that it cannot find any bar for x86. And that's of course expected - there's no bar or x86! However why is Bazel complaining here? I specified that this target is incompatible with x86, so it shouldn't need to analyze it. Why is it doing that?

If I remove the bar dependency, Bazel just skips the target and exits gracefully without errors.

I could solve this problem adding a default condition for bar, but I don't want that. It will silence a useful warning. If I ever want to support a 3rd aarch64 version, the default condition will silence the warning without prompting me to add a 3rd aarch64 version of bar.

I also don't want to add a select in the deps field of the cc_binary either - it's redundant and adds noise. I already specify that the target is only compatible withaarch64. I don't need to add the deps only for aarch64.

Is this expected? Is there any other way I could solve this problem?

Thanks!

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

I want Bazel to ignore incompatible targets, without it trying to find its dependencies (which may not exist at all for an incompatible platform)

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

See above.

What operating system are you running Bazel on?

Ubuntu 18.04

What's the output of bazel info release?

release 5.0.0-pre.20210907.1

Have you found anything relevant by searching the web?

Nothing on the web. Asked in bazel-discuss without answer.

@gregestren gregestren added team-Configurability platforms, toolchains, cquery, select(), config transitions untriaged labels Nov 18, 2021
@gregestren
Copy link
Contributor

@carlosgalvezp - I see there's followup discussion on the bazel-discuss thread. Which parts of this issue are still pending?

@gregestren
Copy link
Contributor

gregestren commented Nov 29, 2021

I think #14096 will fix this, although it's a work in progress (still under review, which will tak a few more iterations to land). That fixes #12897. I'll mark this a dupe for issue queue cleanliness.

@gregestren
Copy link
Contributor

Duplicate of #12897

@gregestren gregestren marked this as a duplicate of #12897 Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Configurability platforms, toolchains, cquery, select(), config transitions type: support / not a bug (process) untriaged
Projects
None yet
Development

No branches or pull requests

2 participants