Skip to content

exec_compatible_with targets which can be built but don't match --platforms cause errors #11729

@illicitonion

Description

@illicitonion

Given this BUILD file:

cc_binary(
    name = "uname_linux",
    srcs = ["uname.c"],
    exec_compatible_with = ["@platforms//os:linux"],
)

cc_binary(
    name = "uname_macos",
    srcs = ["uname.c"],
    exec_compatible_with = ["@platforms//os:macos"],
)

Running:

bazel build \
  --incompatible_enable_cc_toolchain_resolution \
  --extra_toolchains=linux_toolchain,macos_toolchain \
  --extra_execution_platforms=linux_platform,macos_platform \
  //...

tells me:

ERROR: While resolving toolchains for target //compiles_platform_specific_c:uname_linux: No matching toolchains found for types @bazel_tools//tools/cpp:toolchain_type.

Accordingly, it appears I need to tag these as manual, and explicitly build each one in its own invocation of Bazel with the right --platforms flag set.

I know that #10945 intends to skip incompatible targets, but are there plans to be able to build compatible-but-distinctly-configured targets? As far as I can tell if these are in the middle of the graph (i.e. some rule depends on them both), this works fine, but if they're explicit roots of the graph, it fails.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions