bazel icon indicating copy to clipboard operation
bazel copied to clipboard

New deprecation warnings coming from Bazel internals in Bazel@HEAD

Open limdor opened this issue 8 months ago • 7 comments

Description of the bug:

These 2 warnings appear when building with HEAD

WARNING: /home/limdor/.cache/bazel/_bazel_limdor/7847781caf1fd5388b007bf353d8df72/external/bazel_tools/src/conditions/BUILD:149:15: in config_setting rule @@bazel_tools//src/conditions:host_windows_arm64_constraint: select() on host_cpu is deprecated. Use platform constraints instead: https://bazel.build/docs/configurable-attributes#platforms.
WARNING: /home/limdor/.cache/bazel/_bazel_limdor/7847781caf1fd5388b007bf353d8df72/external/bazel_tools/src/conditions/BUILD:144:15: in config_setting rule @@bazel_tools//src/conditions:host_windows_x64_constraint: select() on host_cpu is deprecated. Use platform constraints instead: https://bazel.build/docs/configurable-attributes#platforms.

They are not appearing in Bazel 8 LTS. The user is not able to do anything because they are coming from Bazel internals.

They were introduced by https://github.com/bazelbuild/bazel/commit/eec052436a3f8e8f0f715128ec26964b331fe7f5

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.

Build https://github.com/limdor/accu-2025/tree/9291a9de3784a59d00f05e676901e9b5dba6853a with Bazel@HEAD

Which operating system are you running Bazel on?

Ubuntu 24.04

What is the output of bazel info release?

development version

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

Release from this version https://github.com/bazelbuild/bazel/commit/eec052436a3f8e8f0f715128ec26964b331fe7f5

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.

https://github.com/bazelbuild/bazel/commit/eec052436a3f8e8f0f715128ec26964b331fe7f5

Have you found anything relevant by searching the web?

https://github.com/bazelbuild/bazel/issues/24751 but that is just a feature request mentioning similar warnings

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

No response

limdor avatar Apr 21 '25 18:04 limdor

cc @gregestren

keith avatar Apr 21 '25 18:04 keith

https://github.com/bazelbuild/bazel/issues/24751#issuecomment-2552345553 also mentions this.

I tried fixing that instance and ran into some trouble. Let me recall what happened and where this was at...

gregestren avatar Apr 21 '25 22:04 gregestren

The challenge is while --host_cpu is considered a deprecated part of the pre-platforms API, it still auto-sets to the host machine in a way builds can check directly. There's no equivalent check for the host platform.

In other words:

  1. Build on a Windows machine
  2. According to AutoCpuConverter, --host_cpu will automatically set to x64_windows or arm64_windows
  3. `config_setting can directly check on that

The platforms API equivalent:

  1. Build on a Windows machine
  2. --host_platform is set to @platforms//host:host
  3. This auto-sets the correct constraints, like @platforms/os:windows
  4. But config_setting's constraint_values attribute matches on --platforms's constraints, not --host_platform.

config_setting can check on the host_platform flag, but that doesn't vary unless you set it explicitly. Which is non-ideal since the point is it auto-inherits the right host properties.

Ideally we can refactor this away somehow. But if there are legitimately other repos that need to select() on host properties, maybe we need a richer config_setting API to accommodate.

gregestren avatar Apr 21 '25 23:04 gregestren

I naively tried https://bazel-review.googlesource.com/c/bazel/+/269133 when this was first reported. That requires explicitly setting --host_platform, which I don't think is a good user experience.

gregestren avatar Apr 22 '25 17:04 gregestren

https://github.com/bazelbuild/bazel-skylib/pull/574 should help with this.

gregestren avatar May 30 '25 13:05 gregestren

What's the exact build for https://github.com/limdor/accu-2025/tree/9291a9de3784a59d00f05e676901e9b5dba6853a? I tried:

$ USE_BAZEL_VERSION=last_green bazelisk build --nobuild  //...

and see no related warnings.

Building https://github.com/bazelbuild/bazel at head:

$ USE_BAZEL_VERSION=last_green bazelisk build --nobuild //src:bazel
WARNING: /usr/local/google/home/gregce/bazel/bazel/src/conditions/BUILD:202:15: in config_setting rule //src/conditions:windows_arm64_flag: select() on cpu is deprecated. Use platform constraints instead: https://bazel.build/docs/configurable-attributes#platforms.
WARNING: /usr/local/google/home/gregce/bazel/bazel/src/conditions/BUILD:193:15: in config_setting rule //src/conditions:windows_x64_arm64_flag: select() on cpu is deprecated. Use platform constraints instead: https://bazel.build/docs/configurable-attributes#platforms.
WARNING: /usr/local/google/home/gregce/bazel/bazel/src/conditions/BUILD:119:15: in config_setting rule //src/conditions:darwin_arm64_flag: select() on cpu is deprecated. Use platform constraints instead: https://bazel.build/docs/configurable-attributes#platforms.
WARNING: /usr/local/google/home/gregce/.cache/bazel/_bazel_gregce/f3225a9149c7f352719f88e5dbaca22d/external/+async_profiler_repos+async_profiler_linux_x64/BUILD.bazel:4:10: in _copy_file rule @@+async_profiler_repos+async_profiler_linux_x64//:libasyncProfiler: target '@@+async_profiler_repos+async_profiler_linux_x64//:libasyncProfiler' depends on deprecated target '@@bazel_tools//src/conditions:host_windows_x64_constraint': No longer used by Bazel and will be removed in the future. Migrate to toolchains or define your own version of this setting.
WARNING: /usr/local/google/home/gregce/.cache/bazel/_bazel_gregce/f3225a9149c7f352719f88e5dbaca22d/external/c-ares+/BUILD.bazel:42:10: in _copy_file rule @@c-ares+//:ares_build_h: target '@@c-ares+//:ares_build_h' depends on deprecated target '@@bazel_tools//src/conditions:host_windows_x64_constraint': No longer used by Bazel and will be removed in the future. Migrate to toolchains or define your own version of this setting.
WARNING: /usr/local/google/home/gregce/.cache/bazel/_bazel_gregce/f3225a9149c7f352719f88e5dbaca22d/external/c-ares+/BUILD.bazel:48:10: in _copy_file rule @@c-ares+//:ares_config_h: target '@@c-ares+//:ares_config_h' depends on deprecated target '@@bazel_tools//src/conditions:host_windows_x64_constraint': No longer used by Bazel and will be removed in the future. Migrate to toolchains or define your own version of this setting.

It's not exactly the same message (cpu instead of host_cpu and I think the "No longer used by Bazel" warning masks the original host_cpu message). But same theme.

gregestren avatar May 30 '25 13:05 gregestren

@gregestren the exact command was

bazel build //...

I tried with the --nobuild as you mentioned and I also got it. You should be able to reproduce it using https://github.com/limdor/accu-2025/tree/9291a9de3784a59d00f05e676901e9b5dba6853a and for bazel version https://github.com/bazelbuild/bazel/commit/eec052436a3f8e8f0f715128ec26964b331fe7f5

You said that last_green you do not get it but you get a different one. It could be, if you tell me what hash version was the last_green that you tried, I could tell you if I get the same.

I just tried now with last_green (35c36c42455ecd273ea6ced35342d88978c598f2) and I do not get anymore a warning, also not the different ones you mentioned.

limdor avatar Jun 09 '25 17:06 limdor

This isn't a solution, per se, but interesting related proposal: https://github.com/bazelbuild/bazel/pull/26415. Just FYI.

gregestren avatar Jul 10 '25 21:07 gregestren