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 does not skip toolchain resolution for incompatible targets (target_compatible_with with --platform) #14867

Closed
nathaniel-brough opened this issue Feb 18, 2022 · 4 comments
Labels
team-Configurability platforms, toolchains, cquery, select(), config transitions type: bug untriaged

Comments

@nathaniel-brough
Copy link
Contributor

Description of the problem / feature request:

Bazel fails with;
No matching toolchains found for types @bazel_tools//tools/cpp:toolchain_type.
When target should have been skipped.

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

Create a workspace with;

  • WORKSPACE (empty)
  • main.cc (any valid cc)
  • BUILD.bazel (contents below)
cc_binary(
    name = "main",
    srcs = ["main.cc"],
    target_compatible_with = select({
        "@platforms//os:linux": [],
        "@platforms//os:macos": [],
        "@platforms//os:windows": [],
        "//conditions:default": ["@platforms//:incompatible"],
    }),
)

platform(
    name = "no_os",
    constraint_values = [
        "@platforms//os:none",
    ],
)

Try to build with no_os platform e.g.

bazel build //... --platforms=//:no_os
ERROR: /home/user/projects/bug_repro/BUILD.bazel:1:10: While resolving toolchains for target //:main: No matching toolchains found for types @bazel_tools//tools/cpp:toolchain_type. Maybe --incompatible_use_cc_configure_from_rules_cc has been flipped and there is no default C++ toolchain added in the WORKSPACE file? See https://github.com/bazelbuild/bazel/issues/10134 for details and migration instructions.
ERROR: Analysis of target '//:main' failed; build aborted: 
INFO: Elapsed time: 0.465s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)

In this case I would expect bazel to skip toolchain resolution for //:main as it is incompatible,

Note that #10134 seems to unrelated to this issue.

What operating system are you running Bazel on?

Ubuntu 20.04 under WSL2

What's the output of bazel info release?

release 5.0.0

Have you found anything relevant by searching the web?

No

Any other information, logs, or outputs that you want to share?

No

@nathaniel-brough nathaniel-brough changed the title Bazel does not skip toolchain resolution with incompatible target (target_compatible_with with --platform) Bazel does not skip toolchain resolution for incompatible targets (target_compatible_with with --platform) Feb 18, 2022
@aiuto aiuto added team-Configurability platforms, toolchains, cquery, select(), config transitions untriaged labels Feb 26, 2022
@gregestren
Copy link
Contributor

I think @philsc has an in-progress PR that addresses this. One of us will follow up to confirm.

@philsc
Copy link
Contributor

philsc commented Mar 8, 2022

Yeah, this sounds very similar to #12897.

Robotics season is consuming most of my free time. I do really want to get back to #14096. It should address this issue.
Really sorry about the delay. Other folks are welcome to take over the PR. But once robotics season slows down (end of April) I have no more excuses.

@gregestren
Copy link
Contributor

No worries. Your contributions are always welcome, whenever you have time for them!

But yes, if anyone had the bandwidth and wanted to explore that PR earlier both @philsc and I would be happy to support

@gregestren
Copy link
Contributor

Duplicate of #12897

@gregestren gregestren marked this as a duplicate of #12897 Mar 8, 2022
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: bug untriaged
Projects
None yet
Development

No branches or pull requests

4 participants