bazel icon indicating copy to clipboard operation
bazel copied to clipboard

--platforms silently ignores multiple entries

Open moroten opened this issue 3 months ago • 6 comments

Description of the bug:

--platforms only use a single label. If multiple labels are passed, all but the first are dropped silently, without any kind of warning or error message.

Which category does this issue belong to?

No response

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

bazel build //:all --platforms=@platforms//host,this-extra-platform-is-ignored-without-warning-or-error

Which operating system are you running Bazel on?

Linux

What is the output of bazel info release?

release 9.2.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 HEAD ?


If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

Commit 81acd2a352387399914ea1ef2a5efa1b4ecc766b effectively removed the printing of a warning message.

Have you found anything relevant by searching the web?

No response

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

No response

moroten avatar Aug 12 '26 12:08 moroten

@katre What do you think of making multi-valued --platforms work by essentially a top-level split transition? With remote execution as well as all the recent improvements around cross-compiling toolchains and path mappings, this could provide real benefits over a classical CI matrix that builds or tests for one platform per job.

(sorry for hijacking this issue, but it reminded me of this other direction we might want to go)

fmeum avatar Aug 12 '26 13:08 fmeum

@katre What do you think of making multi-valued --platforms work by essentially a top-level split transition?

@gregestren and I discussed that at one point a few years ago, and I think the general consensus then was that it wasn't a bad idea but could possibly be confusing to users, and would raise issues with the top-level access to skyframe (since you'd effectively be performing a split transition in the code that sets up skyframe and makes the initial request). I think it's probably solvable but we decided then that it wasn't a priority.

katre avatar Aug 13 '26 20:08 katre

--experimental_multi_cpu is prior art. Curious why that never succeeded. FWIW I like these ideas and agree careful modeling can eliminate the API ambiguities.

gregestren avatar Aug 13 '26 20:08 gregestren

Any complexities on https://bazel.build/remote/bep?

gregestren avatar Aug 13 '26 20:08 gregestren

I reproduced this on Bazel 9.2.0 with a minimal workspace. With two local platforms, --platforms=//:p1,//:p2 exits successfully and selects //:p1; no warning is emitted, while the equivalent single-platform invocations select the expected platform.

The current source still has a warning in PlatformConfiguration.reportInvalidOptions, but PlatformOptions.getNormalized() drops every platform after the first before that validation runs. That makes the warning path unable to observe the original multi-valued input.

I have a narrow candidate fix that preserves the existing normalization and output semantics, carries a non-cache-key marker that the original option had multiple values, and lets the existing validation emit its warning. A regression test covers both the marker and the emitted warning. It does not attempt to implement true multi-platform builds or a split transition.

Would that warning-only scope be acceptable here, or should this issue be treated as part of the larger multi-platform design discussion?

audi0417 avatar Sep 23 '26 00:09 audi0417

I'd be interested in the PR to re-add the warning. @gregestren is out for a while, I can review and we can discuss with @aranguyen and @dabanki .

katre avatar Sep 23 '26 15:09 katre